Building a self-extracting Windows archive under GNU/Linux
February 10th, 2009 at 1:31am |
mirror from: http://www.tu-harburg.de/rzt/tuinfo/oberflaechen/linux/sfx.html
How to build a self-extracting installation package for Microsoft Windows with your lovely GNU/Linux box — thanks to 7-zip! 7-Zip is free software distributed under the GNU LGPL.
- First of all we have to install the 7-zip linux package, type apt-get install p7zip, otherwise ask your package management.
- Pack your installation files with 7-zip; in my example the setup program is called setup.msi but could be any Windows executable. The -y switch implies “yes” for inflating the self-extracting program.
7z a -y data.7z setup.msi otherfiles.*
[Under Windows just use the 7-zip GUI.]
- To let the self-extracting file start our installation procedure after inflating, you have to write a little config file (7zip.conf) in UTF-8 encoding. If you have problems with UTF-8, have a look at the GNU iconv command in your man page.
;!@Install@!UTF-8! Title="Software Installation" BeginPrompt="Do you want to install this software?" ExecuteFile="msiexec.exe" ExecuteParameters="/i setup.msi /qb" ;!@InstallEnd@!
If you want to execute only a normal executable (setup.exe), proceed as followed:
;!@Install@!UTF-8! Title="Software Installation" BeginPrompt="Do you want to install this software?" ExecuteFile="setup.exe" ;!@InstallEnd@!
- Download the latest 7-zip extra tar-ball from here, i.e. 7z442_extra.tar.bz2, and untar it. You’ll need the file 7zS.sfx only.
- [optional] If you like to change the icon of your installer, just do this by changing the .sfx extention in .exe and use any tool for altering the resources of Windows executables. (Ideas on how to make this in a shell?)
- Now we’ve got the inflate program 7zS.sfx and a config file 7zip.conf as well as our compressed data data.7z. Putting it together with:
cat 7zS.sfx 7zip.conf data.7z >installer.exe
[Under Windows type copy ⁄b 7zS.sfx + 7zip.conf + data.7z installer.exe]
- Ready to deploy! And don’t forget to test your new self-extracting installer.
Click here to learn how to create password protected archives in linux.