Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a self-extracting zip archive on a linux box

Due to a number of constraints that I won't get into, I have to create a self-extracting ZIP archive on a linux box. The resulting archive should be executable on Windows only. Is this at all possible? If so, what tools would do the job?

Background: when the user downloads a setup package from my linux box, I need that setup package to be pre-populated with a certain key. I only know that key at runtime; my idea was to write a simple .xml file with that key, then zip up the .msi installer with that xml file into a self-extracting archive, and send that file to the browser. If you have alternative ideas on how to make it happen, I'd love to hear those, too

like image 341
Alex Weinstein Avatar asked May 04 '09 01:05

Alex Weinstein


2 Answers

Your answer can be found at the following page: http://ubuntuforums.org/showthread.php?t=847329 Please note that I do not take credit for anything other than using Google and finding something that sounds logically like it would work. I do not guarantee that this information will work, or that you will be able to find the mentioned materials online anymore. I'm just a fan of Google. I hope this helps.

The problem A few days back I had to create a Win32 compatible self-extracting ZIP file for a friend. Sounds easy, right. The problem was that I didn't have a Windows machine nearby and I didn't want to install any archiving programs under Wine.

NOTE: A freeware ZIP program such as IZArc under Wine can be used to create a Win32 self-extracting ZIP file too. That will not be covered by this howto, sorry.

The "research" Googling around I found this forum post dated August 2003. Reading it I found out that self-extracting ZIP files are nothing more but a suitable unzip binary followed by a normal ZIP file. I used the unzipsfx.exe included in Info-ZIP UnZip 5.52.

The link on that post worked a few days ago so I got my hands on the unzipsfx.exe that I was looking for. Today, 2nd July 2008 I found the link dead. After some googling I didn't find a working link anywhere. I read the licence a few times and understood that I can redistribute the original unzipsfx.exe with a license included.

Please note that the unzipsfx-552_win32.tar.gz (80 kB) is not an official Info-ZIP package and it includes copyrighted software that I take no credit for. More info in the Info-ZIP license that is also included in the tarball. The source code for the binaries included can be found here.

The solution

Step one, getting the unzipsfx.exe and zip package: * open the Terminal (in Ubuntu press alt+f2 and type gnome-terminal) * type in the following commands Code:

wget http://kolmoskone.homelinux.org/~kaja/kamaa/unzipsfx-552_win32.tar.gz tar zxf unzipsfx-552_win32.tar.gz sudo apt-get install zip

Step two, creating a ZIP file in Ubuntu: * open the file manager (nautilus) and select the files you want to have zipped * right click and select Create an archive (or similar). Select a location for the ZIP file, using your home directory is the easiest. Select type .zip. See man zip for information on how to create a ZIP file in command line.

Step three, making the ZIP file self-extracting * type in the following commands Code:

cat unzipsfx-552_win32/unzipsfx.exe MYZIPFILE.zip > mysfxfile.exe zip -A mysfxfile.exe

mysfxfile.exe can now be opened in any Win32 compatible system (including for example Windows XP/2000/Vista and even Wine in Linux) or ANY ZIP COMPATIBLE archive program such as file-roller in Ubuntu.

like image 71
phuzion Avatar answered Oct 18 '22 14:10

phuzion


I was able to make this work with unzipsfx. There's a newer version of it available - just came out in April 2009 - version 6.0. Version 5.52 didn't support the critical functionality that I needed - launching a particular setup file after the extraction is completed.

So I downloaded the source files for 6.0. I then modified them to exclude the "prompt to launch stuff" check that is there by default. I recompiled using Visual Studio 2008, tried the steps described in the tutorial above, and it all works like a charm now.

like image 43
Alex Weinstein Avatar answered Oct 18 '22 13:10

Alex Weinstein