LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2007, 07:59 AM   #1
natasha
LQ Newbie
 
Registered: Jul 2006
Distribution: Red Hat
Posts: 12

Rep: Reputation: 0
Question Linux shell programming: creation of a .bin


Good evening everybody,
I'd like and create a file MyInstaller.bin, "containing" another installer Goofy.bin and files hosted in a folder Mickey, performing following operations:

1) show inside console a text message, token by a text file, to "package" inside MyInstaller.bin
2) "Press Enter to Continue": script stops, and wait for user input
3) launches Goofy.bin, which will produce folder Donald in output
4) move folder Donald inside another folder, whom name user will have and insert in input, using as default (on "Enter" key press) /opt. Also, I've to include code for error management, if user specifies a non-existing folder
5) extract folder Mickey (to package inside MyInstaller.bin) inside another folder, whom name user will have and insert in input, using as default (on "Enter" key press) /opt. Also, I've to include code for error management, if user specifies a non-existing folder
6) ask user for a machine account, using as default (on "Enter" key press) root. If user doesn't exist on the machine, script asks if user wants to create it. If so, requires username and password, and save them in /etc/passwd; if not, come back to cycle and requires an account name.
7) insert two text rows at the top of .profile file in folder /root, or /home/<username>, depending about what user choosed in step 6). Subproblem: the file automatically executed at login, is named ".profile" on each and every distroes? If not, is there a system variable to identify it?
8) if user specified at step 6) is not root, executes a set of chmod on a set of Mickey subfolders.

Not so simple a question, I agree, so any partial help, or URL to study, is welcome.... starting, how to create a .bin! I'm a programmer and I have some experience of Linux administration, but definitely, too few knowledge of shell programming.
I opened any .bin and I noted, there's an initial serie of code instructions, followed by data in binary format; but, how to create a .bin installer, starting from data I want to install?
 
Old 03-10-2007, 11:09 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
PDV (payload delivery vehicle) does exactly that. It prepends an executable stub with help message, agreement and then unpacks a single file, tarfile or compressed tarball and will run a command or execute a script after unpacking. The program was written a long time ago and only used Z compression. But I've updated and extende the code so that it can be used with files and archives compressed with gzip or bzip2.
You can see a complete example of creating a package (auMix) and get sources and a binary tarball here:
http://distro.ibiblio.org/pub/linux/...oProjects/PDV/

I'm planning to do some more work with pdv as it may fit in with my other packaging software.

There's another project called freewrap which even includes a statically-compiled tcl GUI in the installer. I'm planning to do something similar with pdv but using small GTK dialog/messaging utilities instead of 'wish'.

Last edited by gnashley; 03-10-2007 at 11:19 AM.
 
Old 03-11-2007, 03:17 AM   #3
natasha
LQ Newbie
 
Registered: Jul 2006
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by gnashley
PDV (payload delivery vehicle) does exactly that.
Very well!
But, tell me, what differences are with makeself (http://www.megastep.org/makeself/)?
 
Old 03-11-2007, 04:23 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I wasn't really aware of makeself, though I have been hearing of .run files and even accomodate them in my package building software (src2pkg).
the first main difference I see is that makeself(and derivatives) are shell based and the .run file is a plain-text file. PDV creates a real binary file. It uses a binary stub and adds the commands and target files to create a single binary. It's supposed to support an internal decompressor, but I haven't gotten it to work. I altered the sources to produce two stubs -one each for gzip and bzip2. Basically the stubs just include commands to decompress and/or untar the contents using the programs installed on the target system.

I'll be having a look at the loki_setup and other tools and will reoprt back again.
 
Old 03-11-2007, 11:09 AM   #5
natasha
LQ Newbie
 
Registered: Jul 2006
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Hello Gnashley,
a final question: how to append two rows of text (of course separed by a CR) at the top of a given file?
 
Old 03-11-2007, 03:28 PM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Do you mean like a message? If so that can go in the help message. If you mean manipulating files after unpacking, you can do that by including commands in a script which is run after unpacking the payload. Since the payload unpacks into the current directory, it's convenient to run some sort of script, silently or ineractively to complete the setup of your program. You can include the scripts (and GUI tools) in the package. The last thing the installer should do is (usually) remove the temporary files including itself, leaving just the original .bin installer.

I've been looking at the loki_setup program which already seems to do most of what we/I want, if I can just figure out how to use it -and it's a real challenge to configure and install correctly. It unpacks a program and its' files, then runs a GUI utility to set the install paths and default options and finally copies the files into the right place and cerates a database entry.
The loki_setup program includes makeself. BTW, these both use code similar to makelf which concatenates files into a single file and then writes an ELF header at the start.

I'm wanting to put together an easy way to make installers with some flexibility in what installer features are included.
loki_setup looks like a pretty complete setup, but PDV may be even more flexible in some ways.
 
Old 03-12-2007, 05:18 AM   #7
spaesani
LQ Newbie
 
Registered: Mar 2007
Posts: 13

Rep: Reputation: 0
hello,
hey gnashley (i chekced out the other thread...thanks)

hello natasha,
yes i confess the name brings me to this thread,
yet bits before bytes

sed -i -e '1i\your first line of text' -e '1i\next line of text' yourfilename

the single quotes work from the commandline.
in a shells script double quotes might work(youll have to chk it out)
the adress selection for the second line is 1 and not 2 for the simple reason of
,yes, sed magic.
try it out.
xcheers
sp
 
Old 03-12-2007, 05:29 AM   #8
spaesani
LQ Newbie
 
Registered: Mar 2007
Posts: 13

Rep: Reputation: 0
ok ok ok
though sed's i command can take a single adress
the adress can be omitted, (it actually has no affect)
the command is used not to insert yet rather to immediately output the line.
in short i stands for immediately and not insert.
the order of execution for sed in this light is:
read in line, immediately output text, immediatley output text, print line
read in line, print,
read in line, print,
etc...
untill no lines.

all potential kidding aside;
info sed


cheers
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux LiveCD with C Shell Programming cyberquest Linux - Software 2 08-07-2006 11:59 PM
linux shell programming structure s.santhoshkumar Programming 4 04-05-2005 09:38 PM
books of linux shell programming 286 Linux - Newbie 2 11-11-2003 10:13 AM
Linux Shell programming question ducka Programming 4 09-01-2003 09:24 AM
shell programming,c/cpp in linux arunshivanandan Linux - Newbie 2 05-16-2003 04:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration