📄 msipackagegenerator.java
字号:
treeMap.put("UninstallInfo", pkgInfo.getJnlpFileHref()); treeMap.put( "Shortcut", pkgInfo.getShortcutEnabled() ? "1" : "0"); treeMap.put( "Association", pkgInfo.getAssociationEnabled() ? "1" : "0"); treeMap.put( "CacheType", pkgInfo.getSystemCacheEnabled() ? "system" : "user"); WinMsiUtility.winMsiSetProperty( msiFilePath, "Property", "Property", VI_PROPERTY_VALUE, false, treeMap); } catch (IOException e) { throw new IOException("Set MSI field property failed!"); } //Set the destination msi file summary information stream try { WinMsiUtility.setSummaryInfoProperty(msiFilePath, PID_REVISION_NUMBER, uuidProduct); WinMsiUtility.setSummaryInfoProperty(msiFilePath, PID_AUTHOR, AUTHOR_INFO); } catch (IOException e) { throw new IOException("Set MSI summary information stream failed!"); } String[] names = new String[] {"Name", "Data"}; String[] properties = new String[] {"String", "Stream"}; String[] values = new String[2]; try { // Insert into "Binary" table, "CustomDll" record String customDLLFilePath = pkgInfo.getUniqueTmpDirPath() + CUSTOM_DLL_FILE_NAME; WinUtility.extractFileFromJarFile( packagerJarFilePath, MSI_SUPPORT_FILES_HIERARCHY_PATH + CUSTOM_DLL_FILE_NAME, customDLLFilePath); values[0] = "CustomDLL"; values[1] = customDLLFilePath; WinMsiUtility.addBinaryRecord( msiFilePath, "Binary", names, properties, values); } catch (IOException e) { throw new IOException("Binary: insert CustomDLL field failed!"); } try { // Insert into "Binary" table, "JarPack" record String tempJarFilePath = pkgInfo.getUniqueTmpDirPath() + JNLP_FILES_JAR_NAME; WinUtility.jarJnlpFiles(tempJarFilePath, pkgInfo); values[0] = "JarPack"; values[1] = tempJarFilePath; WinMsiUtility.addBinaryRecord( msiFilePath, "Binary", names, properties, values); } catch (IOException e) { throw new IOException("Binary: insert JarPack field failed!"); } treeMap.clear(); try { // Modify "Binary" table, update "bannerBmp" String bannerJpgFilePath = pkgInfo.getUniqueTmpDirPath() + BANNER_JPG_FILE_NAME; if (pkgInfo.getBannerJpgFilePath() != null) { bannerJpgFilePath = pkgInfo.getBannerJpgFilePath(); } else { WinUtility.extractFileFromJarFile( packagerJarFilePath, MSI_SUPPORT_FILES_HIERARCHY_PATH + BANNER_JPG_FILE_NAME, bannerJpgFilePath); } treeMap.put("bannrbmp", bannerJpgFilePath); } catch (IOException e) { throw new IOException("Binary: pre insert bannrbmp field failed!"); } try { // Modify "Binary" table, update "panelBmp" String panelJpgFilePath = pkgInfo.getUniqueTmpDirPath() + PANEL_JPG_FILE_NAME; if (pkgInfo.getPanelJpgFilePath() != null) { panelJpgFilePath = pkgInfo.getPanelJpgFilePath(); } else { WinUtility.extractFileFromJarFile( packagerJarFilePath, MSI_SUPPORT_FILES_HIERARCHY_PATH + PANEL_JPG_FILE_NAME, panelJpgFilePath); } treeMap.put("dlgbmp", panelJpgFilePath); } catch (IOException e) { throw new IOException("Binary: pre insert dlgbmp field failed!"); } try { WinMsiUtility.winMsiSetProperty( msiFilePath, "Binary", "Name", 2, true, treeMap); } catch (IOException e) { throw new IOException( "Binary: insert bannrbmp and dlgbmp field failed!"); }} /** * Generate the template MSI file based on the rawMSI file. * @param msiFilePath The given raw msi file. * @param pkgInfo JnlpPackageInfo object. * @throws IOException If failed to generate the template msi file. */ private static void createTemplateMsiFile(String msiFilePath, JnlpPackageInfo pkgInfo) throws IOException { // Modify the template msi file ArrayList sqlStrings = new ArrayList(); //Add table Directory sqlStrings.add("CREATE TABLE Directory (Directory CHAR(72) NOT NULL, " + "Directory_Parent CHAR(72), DefaultDir CHAR(255) NOT " + "NULL LOCALIZABLE PRIMARY KEY Directory)"); sqlStrings.add("INSERT INTO Directory (Directory, Directory_Parent, " + "DefaultDir) VALUES ('TARGETDIR', '', 'SourceDir')"); sqlStrings.add("INSERT INTO Directory (Directory, Directory_Parent, " + "DefaultDir) VALUES ('ProgramFilesFolder', " + "'TARGETDIR', '.:PROGRA~1|program files')"); sqlStrings.add("INSERT INTO Directory (Directory, Directory_Parent, " + "DefaultDir) VALUES ('INSTALLDIR', 'TempFolder', " + "'.')"); sqlStrings.add("INSERT INTO Directory (Directory, Directory_Parent, " + "DefaultDir) VALUES ('TempFolder', 'TARGETDIR', " + "'.:Temp')"); //Add table Component sqlStrings.add("CREATE TABLE Component (Component CHAR(72) NOT NULL, " + "ComponentId CHAR(38), Directory_ CHAR(72) NOT NULL, " + "Attributes INT NOT NULL, Condition CHAR(255), " + "KeyPath CHAR(72) PRIMARY KEY Component)"); sqlStrings.add("INSERT INTO Component (Component, ComponentId, " + "Directory_, Attributes, Condition, KeyPath) VALUES " + "('AllOtherFiles', " + "'{31CCF52F-FCB3-4239-9D82-05CDA204867A}', " + "'INSTALLDIR', 8, '', '')"); //Add table File sqlStrings.add("CREATE TABLE File (File CHAR(72) NOT NULL, Component_ " + "CHAR(72) NOT NULL, FileName CHAR(255) NOT NULL " + "LOCALIZABLE, FileSize LONG NOT NULL, " + "Version CHAR(72), Language CHAR(20), Attributes INT, " + "Sequence INT NOT NULL PRIMARY KEY File)"); sqlStrings.add("INSERT INTO File (File, Component_, FileName, " + "FileSize, Version, Language, Attributes, Sequence) " + "VALUES ('place.txt', 'AllOtherFiles', 'place.txt', " + "18, '', '', 16384, 1)"); //Add table Media sqlStrings.add("CREATE TABLE Media (DiskId INT NOT NULL, LastSequence " + "INT NOT NULL, DiskPrompt CHAR(64) LOCALIZABLE, " + "Cabinet CHAR(255), VolumeLabel CHAR(32), Source " + "CHAR(72) PRIMARY KEY DiskId)"); sqlStrings.add("INSERT INTO Media (DiskId, LastSequence, DiskPrompt, " + "Cabinet, VolumeLabel, Source) VALUES (1, 1, '', " + "'#Data1.cab', '', '')"); //Add table Feature sqlStrings.add("CREATE TABLE Feature (Feature CHAR(38) NOT NULL, " + "Feature_Parent CHAR(38), Title CHAR(64) LOCALIZABLE, " + "Description CHAR(255) LOCALIZABLE, Display INT, " + "Level INT NOT NULL, Directory_ CHAR(72), Attributes " + "INT NOT NULL PRIMARY KEY Feature)"); sqlStrings.add("INSERT INTO Feature (Feature, Feature_Parent, Title, " + "Description, Display, Level, Directory_ , " + "Attributes) VALUES ('NewFeature1', '', " + "'NewFeature1', '', 2, 1, 'INSTALLDIR', 0)"); //Add table FeatureComponents sqlStrings.add("CREATE TABLE FeatureComponents (Feature_ CHAR(38) NOT " + "NULL, Component_ CHAR(72) NOT NULL PRIMARY KEY " + "Feature_, Component_)"); sqlStrings.add("INSERT INTO FeatureComponents (Feature_, Component_) " + "VALUES ('NewFeature1', 'AllOtherFiles')"); //Add table CustomActioni sqlStrings.add("CREATE TABLE CustomAction(Action CHAR(72) NOT NULL, " + "Type INT NOT NULL, Source CHAR(72), Target CHAR(255) " + "PRIMARY KEY Action)"); sqlStrings.add("INSERT INTO CustomAction (Action,Type,Source,Target) " + "VALUES ('CustomInstallAction', 1, 'CustomDLL', " + "'InstallAction')"); sqlStrings.add("INSERT INTO CustomAction (Action,Type,Source,Target) " + "VALUES ('CustomUninstallAction', 1, 'CustomDLL', " + "'UninstallAction')"); //Modify table property sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('Manufacturer','" + AUTHOR_INFO + "')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('ProductCode', " + "'{3D11E9FC-142F-4945-8010-861EAA24850F}')"); sqlStrings.add("INSERT INTO Property (Property,Value) " + "VALUES ('ProductName','Default')"); sqlStrings.add("INSERT INTO Property (Property,Value) " + "VALUES ('ProductVersion','1.00.0000')"); sqlStrings.add("INSERT INTO Property (Property,Value) " + "VALUES ('UpgradeCode', " + "'{20AC1669-B481-4CAD-82AF-2CD00005F304}')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('JnlpFileName','ok')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('UninstallInfo','ok')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('Locale','en')"); sqlStrings.add("UPDATE Property SET Value='" + AUTHOR_INFO + "' where Property='ARPHELPLINK'"); sqlStrings.add("UPDATE Property SET Value='" + AUTHOR_INFO + "' where Property='ComponentDownload'"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('ARPCONTACT','" + AUTHOR_INFO + "')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('ARPURLINFOABOUT','" + AUTHOR_INFO + "')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('ARPURLUPDATEINFO','" + AUTHOR_INFO + "')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('ARPCOMMENTS','Generated by JDIC Project')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('Shortcut','yes')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('Association','yes')"); sqlStrings.add("INSERT INTO Property (Property,Value) VALUES " + "('CacheType','user')"); //Modify table InstallExecuteSequence sqlStrings.add("INSERT INTO InstallExecuteSequence (Action, Condition, " + "Sequence) VALUES ('CustomInstallAction', " + "'NOT Installed', 6650)"); sqlStrings.add("INSERT INTO InstallExecuteSequence (Action, Condition, " + "Sequence) VALUES ('CustomUninstallAction', " + "'Installed', 6651)"); //Modify table Dialog sqlStrings.add("UPDATE Dialog SET Control_Cancel='RemoveButton' where " + "Dialog='MaintenanceTypeDlg'"); //Modify table Control sqlStrings.add("UPDATE Control SET Attributes=0 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='ChangeLabel'"); sqlStrings.add("UPDATE Control SET Attributes=5767168 where " + "Dialog_='MaintenannceTypeDlg' and " + "Control='ChangeButton'"); sqlStrings.add("UPDATE Control SET Attributes=0 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='ChangeText'"); sqlStrings.add("UPDATE Control SET Attributes=0 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RepairLabel'"); sqlStrings.add("UPDATE Control SET Attributes=5767168 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RepairButton'"); sqlStrings.add("UPDATE Control SET Attributes=0 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RepairText'"); sqlStrings.add("UPDATE Control SET Y=65 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RemoveButton'"); sqlStrings.add("UPDATE Control SET Y=65 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RemoveLabel'"); sqlStrings.add("UPDATE Control SET Y=78 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RemoveText'"); sqlStrings.add("UPDATE Control SET Y=78 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='RemoveText'"); sqlStrings.add("UPDATE Control SET " + "Text='[DlgTitleFont]Remove installation' where " + "Dialog_='MaintenanceTypeDlg' and Control='Title'"); sqlStrings.add("UPDATE Control SET Attributes=196608 where " + "Dialog_='MaintenanceTypeDlg' and " + "Control='Description'"); sqlStrings.add("UPDATE Control SET Text='The [Wizard] is ready to " + "begin the installation' where " + "Dialog_='VerifyReadyDlg' and Control='Description'"); sqlStrings.add("UPDATE Control SET Text='Click Install to begin the " + "installation. Click Cancel to exit the wizard.' " + "where Dialog_='VerifyReadyDlg' and Control='Text'"); sqlStrings.add("UPDATE Control SET Text='The [Wizard] will allow you to" + "remove [ProductName] from your computer. Click Next " + "to continue or Cancel to exit the [Wizard].' where " + "Dialog_='MaintenanceWelcomeDlg' and " + "Control='Description'"); sqlStrings.add("UPDATE Control SET Text='Click Remove to remove " + "[ProductName] from your computer. Click Cancel to " + "exit the wizard.' where Dialog_='VerifyRemoveDlg' " + "and Control='Text'"); sqlStrings.add("UPDATE Control SET Text='{\\DlgFontBold8}Remove " + "[ProductName]' where Dialog_='VerifyRemoveDlg' " + "and Control='Title'"); sqlStrings.add("UPDATE Control SET Text='SunButton' where " + "Dialog_='WelcomeDlg' and Control='Next'"); sqlStrings.add("UPDATE Control SET Text='WelcomeDescription' where " + "Dialog_='WelcomeDlg' and Control='Description'"); sqlStrings.add("UPDATE Control SET Text='[ButtonText_Remove]' where " + "Dialog_='MaintenanceWelcomeDlg' and Control='Next'"); sqlStrings.add("UPDATE Control SET Text='The [Wizard] will allow you " + "to remove [ProductName] from your computer. Click " + "Remove to continue or Cancel to exit the [Wizard].' " + "where Dialog_='MaintenanceWelcomeDlg' and " + "Control='Description'"); // Modify the ControlEvent table sqlStrings.add("DELETE FROM ControlEvent where Dialog_='WelcomeDlg' " + "and Control_='Next'"); sqlStrings.add("INSERT INTO ControlEvent (Dialog_, Control_, Event, " + "Argument, Condition) VALUES ('WelcomeDlg', 'Next', " + "'NewDialog', 'AfterWelcomeDlg', 1)"); sqlStrings.add("DELETE from ControlEvent where " + "Dialog_='LicenseAgreementDlg' and Control_='Next' " + "and Event='NewDialog'"); sqlStrings.add("INSERT INTO ControlEvent (Dialog_, Control_,Event, " + "Argument, Condition, Ordering) VALUES " + "('LicenseAgreementDlg', 'Next', 'EndDialog', " + "'Return', 'IAgree = \"Yes\"', 1)"); sqlStrings.add("DELETE FROM ControlEvent where " + "Dialog_='MaintenanceWelcomeDlg' and Control_='Next'"); sqlStrings.add("INSERT INTO ControlEvent (Dialog_, Control_, Event, " + "Argument, Condition, Ordering) VALUES " + "('MaintenanceWelcomeDlg', 'Next', '[InstallMode]', " + "'Remove', '1', 1)"); sqlStrings.add("INSERT INTO ControlEvent (Dialog_, Control_, Event, " + "Argument, Condition, Ordering) VALUES " + "('MaintenanceWelcomeDlg', 'Next', '[Progress1]', "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -