Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-01

creating a standalone executable (eg: application installation file)

11 messages · 7 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I have seen a few Linux application that have standalone executables that are installation programs. Once run, it installs the application in the appropriate directory location, can run as root or normal user and creates a desktop and Application menu icon. Similar to Windows's setup.exe idea. An example of such a Linux application is 'installpixel32' from the Pixel32 project, or Kylix 3 installation.

* How does one create such a standalone application?
* How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable?

I'm trying to create (mainly for our company, but probably open-source in the end) such a standalone setup creation for our projects. This way it will be Linux distro independent. I also don't want to go the route of projects like AutoPackage that first requires a setup runtime to be installed. I want a installation file like what Pixel32 did. One installation executable without any installation runtime etc. and after the installation, I can simply click on 'uninstall' or run 'setup -u' and a graphical uninstaller is launched.

I'm going to look at Loki Games's setup program to see if I can port it to fpGUI Toolkit, or at least get some ideas of how to create such a setup application. Basically I'm trying to create a "InstallShield Lite" but for Linux. :-) The nice thing of Loki Games is that it run run as a console installation or a GUI installation - again, no idea how they managed that, but it was possible (Kylix 3 installation did that).

Anybody have pointers or internet links I can read up on the subject?

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Andreas Schneider
to Graeme Geldenhuys

Hi,

that works the same as in Windows and can probably be done with every executable format. Simply append the data to the end of the file and store the offset or length of that data at the end. All you have to do then is to let the program open "itself" (ParamStr(0)), seek to the end - SizeOf(Integer), read that integer to know the offset of the data, seek to that position, and read all you need from there. So essentially your file looks like: <original executable><install data><data offset>

(Of course you can also include the data offset "hardcoded" into the executable, but that's a bit harder to manage ... first compile to know the exe size, then change the constant storing that size, and recompile again ...)

Best regards,
Andreas.

Graeme Geldenhuys wrote 33 lines
Hi, I have seen a few Linux application that have standalone executables that are installation programs. Once run, it installs the application in the appropriate directory location, can run as root or normal user and creates a desktop and Application menu icon. Similar to Windows's setup.exe idea. An example of such a Linux application is 'installpixel32' from the Pixel32 project, or Kylix 3 installation. * How does one create such a standalone application? * How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable? I'm trying to create (mainly for our company, but probably open-source in the end) such a standalone setup creation for our projects. This way it will be Linux distro independent. I also don't want to go the route of projects like AutoPackage that first requires a setup runtime to be installed. I want a installation file like what Pixel32 did. One installation executable without any installation runtime etc. and after the installation, I can simply click on 'uninstall' or run 'setup -u' and a graphical uninstaller is launched. I'm going to look at Loki Games's setup program to see if I can port it to fpGUI Toolkit, or at least get some ideas of how to create such a setup application. Basically I'm trying to create a "InstallShield Lite" but for Linux. :-) The nice thing of Loki Games is that it run run as a console installation or a GUI installation - again, no idea how they managed that, but it was possible (Kylix 3 installation did that). Anybody have pointers or internet links I can read up on the subject?

Reply by email

Milan Marusinec
to Graeme Geldenhuys: I have seen a few Linux application that have standalone executables that are…
Graeme Geldenhuys wrote
* How does one create such a standalone application? * How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable?

Hello Graeme,

I did this on Windows in Delphi, but the principle is pretty the same for linux app.

1. Create your own file structure archive format or pack all installation files inside one .zip
(later you should be able to extract files in
memory from that .zip or own format file).

2. Use bin2obj.exe utility, to convert that .zip (or own) archive file into the pascal source code "Const statement". (eg. Const inst_arch : Array[0..xx] of byte = (0,1,2,...);).

3. Embed converted inst_arch constant into your app source code. (If you use is as {$I my_istall_file.inc}, you can rebuild installation data file from outside the installer app src code).

4. On RunTime, map inst_arch (you know its size) to TStream and use it as the source memory file with all your installation stuff inside (text, image, sound files etc).

The whole installer is in fact just an ordinary app with embedded data block through const statement.

If you want to see this kind of installer (on windows), have a look at: http://www.crossgl.com/CrossGL-SnapDraw-Installer.exe

Milan

Reply by email

ik
to Graeme Geldenhuys: I have seen a few Linux application that have standalone executables that are…

Graeme,

That's not how it's been done in Linux (and unix). In linux you have files that starts as bash (or any other format) and tools that adds after the script the binary information to extract it.

I do not remember at the moment the names of the tools, but you should take a knows how to add more then one binary content to such file, and it generate the bash script on it's own.

Ido

Graeme Geldenhuys wrote 45 lines
Hi, I have seen a few Linux application that have standalone executables that are installation programs. Once run, it installs the application in the appropriate directory location, can run as root or normal user and creates a desktop and Application menu icon. Similar to Windows's setup.exe idea. An example of such a Linux application is 'installpixel32' from the Pixel32 project, or Kylix 3 installation. * How does one create such a standalone application? * How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable? I'm trying to create (mainly for our company, but probably open-source in the end) such a standalone setup creation for our projects. This way it will be Linux distro independent. I also don't want to go the route of projects like AutoPackage that first requires a setup runtime to be installed. I want a installation file like what Pixel32 did. One installation executable without any installation runtime etc. and after the installation, I can simply click on 'uninstall' or run 'setup -u' and a graphical uninstaller is launched. I'm going to look at Loki Games's setup program to see if I can port it to fpGUI Toolkit, or at least get some ideas of how to create such a setup application. Basically I'm trying to create a "InstallShield Lite" but for Linux. :-) The nice thing of Loki Games is that it run run as a console installation or a GUI installation - again, no idea how they managed that, but it was possible (Kylix 3 installation did that). Anybody have pointers or internet links I can read up on the subject? -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Milan Marusinec
to Andreas Schneider: that works the same as in Windows and can probably be done with every executable format.…
Andreas Schneider wrote 9 lines
Hi, that works the same as in Windows and can probably be done with every executable format. Simply append the data to the end of the file and store the offset or length of that data at the end. All you have to do then is to let the program open "itself" (ParamStr(0)), seek to the end - SizeOf(Integer), read that integer to know the offset of the data, seek to that position, and read all you need from there. So essentially your file looks like: <original executable><install data><data offset>

Andreas,

Will this method work when the exe is digitally
signed afterwards (or before) ?

(tough, for linux it doesn't matter)

Milan

Reply by email

Andreas Schneider
to Milan Marusinec

I think if digital signing is required, using Windows Resources would be the better way. Now that I think about it, with FPC 2.4 that should even be possible on Linux (and other platforms). Many roads lead to rome :D

Milan Marusinec wrote 24 lines
Andreas Schneider wrote: > Hi, > > that works the same as in Windows and can probably be done with every > executable format. Simply append the data to the end of the file and > store the offset or length of that data at the end. All you have to do > then is to let the program open "itself" (ParamStr(0)), seek to the end - > SizeOf(Integer), read that integer to know the offset of the data, seek > to that position, and read all you need from there. So essentially your > file looks like: <original executable><install data><data offset> Andreas, Will this method work when the exe is digitally signed afterwards (or before) ? (tough, for linux it doesn't matter) Milan _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Rainer Stratmann
to Graeme Geldenhuys: I have seen a few Linux application that have standalone executables that are…
Graeme Geldenhuys wrote 13 lines
Hi, I have seen a few Linux application that have standalone executables that are installation programs. Once run, it installs the application in the appropriate directory location, can run as root or normal user and creates a desktop and Application menu icon. Similar to Windows's setup.exe idea. An example of such a Linux application is 'installpixel32' from the Pixel32 project, or Kylix 3 installation. * How does one create such a standalone application? * How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable?

A similar question I posted already (23.03.2009 15:37)  
The simplest way would be like this:

// include binary data of the file 'myfile.dat' to the var mydata
{$incdata myfile.dat mydata}
// fpc compiler makes this
const
 mydata : array[ 0 .. filesizeof( myfile.dat ) - 1 ] of byte =
 ( d1, d2, d3, d4, d5, ... , dn );

Easy, and userfriendly.

Rainer

Reply by email

Graeme Geldenhuys
to ik: That's not how it's been done in Linux (and unix). In linux you have files that starts as…
ik wrote
That's not how it's been done in Linux (and unix). In linux you have files that starts as bash (or any other format) and tools that adds after the script the binary information to extract it.

I believe the tool is called 'makeself', but I don't like the bash part in the front, I would prefer a 100% binary, so nobody would be tempted to try and edit it with a text editor. 100% binary would help the idea of simply double clicking on the executable to install the app - otherwise Gnome (and probably other DE and WM too) would prompt the user first: "Run in Terminal, Edit, Cancel" because they think it's a standard script.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Andreas Schneider: that works the same as in Windows and can probably be done with every executable format.…
Andreas Schneider wrote
read all you need from there. So essentially your file looks like: <original executable><install data><data offset>

Interesting, I never thought of trying that, or that that would work. I'll try and create proof of concept tonight to see how it works.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Krishna
to Graeme Geldenhuys: I have seen a few Linux application that have standalone executables that are…

Hi Graeme,

Graeme Geldenhuys wrote 13 lines
Hi, I have seen a few Linux application that have standalone executables that are installation programs. Once run, it installs the application in the appropriate directory location, can run as root or normal user and creates a desktop and Application menu icon. Similar to Windows's setup.exe idea. An example of such a Linux application is 'installpixel32' from the Pixel32 project, or Kylix 3 installation. * How does one create such a standalone application? * How do you include the application executable and other resources (text, image, sound files etc) inside such an installation executable?

InstallerJammer is a nice free install builder for building cross-platform installers from a single specification. If you are willing to shell money then I'd recommend BitRock install builder. BitRock also gives away licenses for opensource projects.

Cheers,
--Krishna

I long to accomplish a great and noble task, but it is my chief duty to accomplish small tasks as if they were great and noble ! -- Helen Keller

Reply by email

JoshyFun
to Graeme Geldenhuys: Interesting, I never thought of trying that, or that that would work. I'll try and create…

Hello FPC-Pascal,

Tuesday, January 12, 2010, 5:16:20 PM, you wrote:

GG> Interesting, I never thought of trying that, or that that would work. GG> I'll try and create proof of concept tonight to see how it works.

This works at least in Windows, in fact I'm using it in a self contained EXE/Data where the EXE and all the data files are in the same EXE with an attached "virtual file system" at the end. Of course the write procedure in the EXE raises many antivirus alarms but for that application is convenient (no antivirus, no internet, no nothing).

Other "mini-project" is the same but with a ZIP attached at the end where the application read its internal data structures and some graphics.

Best regards, JoshyFun

Reply by email