Author Topic: Self-extracting archive  (Read 4507 times)

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Self-extracting archive
« on: 1 March 2006, 23:14 »
I was trying to make my own rpms but upon encountering lots of problems and just cuz it was a pain in the ass to do I found that you can actually make your own self-extracting archives ... which is really cool

http://linux.org.mt/article/selfextract

An example ... after compiling and installing the game toppler

./configure
make
make prefix=/home/USERNAME/Stuff/MAKEBIN install

add all the files inside /home/USERNAME/Stuff/MAKEBIN to a tar.gz call it toppler-1.1.2-fc4-i686-bin.tar.gz

write a header script call it toppler-header

Code: [Select]
#!/bin/sh

SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`

echo ""
echo "toppler-1.1.2-fc4-i686-bin"
echo "this package is built for Fedora Core 4 on i686 architecture"
echo ""
echo "!!! You must be root to install this package !!!"
echo ""

echo -n "Options: Type i to install, r to remove, or any other key to quit? "
read switch
if  [ "$switch" == "i" ]; then
  echo "Installing ... stand by"
  tail +$SKIP $0 | tar xz -C /usr/local
  echo "Done"
elif [ "$switch" == "r" ]; then
  echo "Removing ... stand by"
  rm /usr/local/bin/toppler
  rm /usr/local/man/man6/toppler.6
  rm /usr/local/share/applications/toppler.desktop
  rm /usr/local/share/doc/toppler/AUTHORS
  rm /usr/local/share/doc/toppler/ChangeLog
  rm /usr/local/share/doc/toppler/COPYING
  rm /usr/local/share/doc/toppler/NEWS
  rm /usr/local/share/doc/toppler/README
  rmdir /usr/local/share/doc/toppler
  rm /usr/local/share/locale/de/LC_MESSAGES/toppler.mo
  rm /usr/local/share/locale/fi/LC_MESSAGES/toppler.mo
  rm /usr/local/share/locale/fr/LC_MESSAGES/toppler.mo
  rm /usr/local/share/locale/pt/LC_MESSAGES/toppler.mo
  rm /usr/local/share/locale/sv/LC_MESSAGES/toppler.mo
  rm /usr/local/share/pixmaps/toppler.xpm
  rm /usr/local/share/toppler/abc.ttm
  rm /usr/local/share/toppler/ball2.ttm
  rm /usr/local/share/toppler/m1.ttm
  rm /usr/local/share/toppler/pasi2.ttm
  rm /usr/local/share/toppler/ball1.ttm
  rm /usr/local/share/toppler/ball3.ttm
  rm /usr/local/share/toppler/m2.ttm
  rm /usr/local/share/toppler/toppler.dat
  rmdir /usr/local/share/toppler
  rm /usr/local/var/toppler/toppler.hsc
  rmdir /usr/local/var/toppler
  echo "Done"
else
  exit 1
fi

exit 0

__ARCHIVE_FOLLOWS__

(I wrote this myself :D)

and finally ...

cat toppler-header toppler-1.1.2-fc4-i686-bin.tar.gz > toppler-1.1.2-fc4-i686-bin.sh

You might want to note that you can install and remove the package without needing rpm ... that's exactly what I wanted ... anyway I thought it was a cool

And if you wanted to, you could make it input the install location ... /usr/local is the most logical place to put it though

Aloone_Jonez

  • Administrator
  • Member
  • ***
  • Posts: 4,090
  • Kudos: 954
Re: Self-extracting archive
« Reply #1 on: 1 March 2006, 23:28 »
This looks great, it's a classic example of how UNIX's superiour scripting capabilities totally blow$ Winblow$ out of the water.
This is not a Windows help forum, however please do feel free to sign up and agree or disagree with our views on Microsoft.

Oh and FUCKMicrosoft! :fu:

mobrien_12

  • VIP
  • Member
  • ***
  • Posts: 2,138
  • Kudos: 711
    • http://www.geocities.com/mobrien_12
Re: Self-extracting archive
« Reply #2 on: 2 March 2006, 05:54 »
I'm pretty good at building RPMS if I can find some SPEC file to start with and update.  Still haven't mastered writing SPEC files from scratch.
In brightest day, in darkest night, no evil shall escape my sight....

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: Self-extracting archive
« Reply #3 on: 2 March 2006, 20:43 »
Yeah, that's the biggest problem with rpms ... the damn spec files ... and even if you do know how to make them, they gotta be done right or there will be problems

Aloone_Jonez

  • Administrator
  • Member
  • ***
  • Posts: 4,090
  • Kudos: 954
Re: Self-extracting archive
« Reply #4 on: 2 March 2006, 21:44 »
Packages suck shit in general, if I made some softwere (and I do have a little project in progress) I'd release the binary in a simple archive so all you do is make a directory and extract it, if it was large and needed to alter the desktop I'd write a script like this one.
This is not a Windows help forum, however please do feel free to sign up and agree or disagree with our views on Microsoft.

Oh and FUCKMicrosoft! :fu:

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: Self-extracting archive
« Reply #5 on: 4 March 2006, 21:50 »
Well I wrote a script that makes self-extracting and removing packages (I've tried to make it as safe as possible so it only deletes stuff you actually installed with the packaging system and only in /usr/local) I also added an extract feature so you can extract the archive inside to anywhere you want.

Code: [Select]
#!/bin/sh

if [ -a /tmp/Sirx ]; then
 rm -rf /tmp/Sirx
fi

mkdir /tmp/Sirx
mkdir /tmp/Sirx/local

echo "Build package from [s]ource or from [b]inary? "
read pack

if [ "$pack" == "s" ]; then
 mkdir /tmp/Sirx/source
 echo "Path to folder containing configure and/or Makefile? "
 read inputsource
 cd "$inputsource"
 cp -r * /tmp/Sirx/source
 cd /tmp/Sirx/source
 if [ -a configure ]; then
  if ./configure --prefix=/usr/local ; then
   echo "configure complete"
  else
   echo "!configure failed!"
   read dummy
   exit 1
  fi
 fi
 if make ; then
  echo "make complete"
 else
  echo "!make failed!"
  read dummy
  exit 1
 fi
 if make prefix=/tmp/Sirx/local install ; then
  echo "make install complete"
 else
  echo "!make install failed!"
  read dummy
  exit 1
 fi
elif [ "$pack" == "b" ]; then
 echo "Path to folder containing binary? "
 read inputbinary
 cd "$inputbinary"
 cp -r * /tmp/Sirx/local
else
 echo "!Incorrect input!"
 read dummy
 exit 1
fi

cd /tmp/Sirx/local

echo "Name of output package file? "
read outputfilename

tar -czf /tmp/Sirx/"$outputfilename".tar.gz *

find -type f > /tmp/Sirx/remove.txt

cd /tmp/Sirx/
sed 's/\./\/usr\/local/' remove.txt > removefixed.txt

echo "#!/bin/sh" > header.sh
echo SKIP=\`awk \'\/\^__ARCHIVE_FOLLOWS__\/ { print NR + 1\; exit 0\; }\' \$0\` >> header.sh
echo \echo \""$outputfilename"\" >> header.sh
echo \echo \"Select: \[i\]nstall, \[r\]emove, e\[x\]tract, or any other key to quit\? \" >> header.sh
echo "read switch" >> header.sh
echo \if  \[ \"\$switch\" == \"i\" \]\; \then >> header.sh
echo \echo \"Installing . . .\" >> header.sh
echo \tail +\$SKIP \$0 \| tar xz -C \/usr\/local >> header.sh
echo \echo \"Done\" >> header.sh
echo \elif \[ \"\$switch\" == \"r\" \]\; \then >> header.sh
echo \echo \"Removing . . .\" >> header.sh
while read line
do
 echo rm "$line" >> header.sh
done < removefixed.txt
echo \echo \"Done\" >> header.sh
echo \elif \[ \"\$switch\" == \"x\" \]\; \then >> header.sh
echo \echo \"Extract directory\? \" >> header.sh
echo "read extract" >> header.sh
echo \echo \"Extracting . . .\" >> header.sh
echo \tail +\$SKIP \$0 \| tar xz -C \"\$extract\" >> header.sh
echo \echo \"Done\" >> header.sh
echo "else" >> header.sh
echo "exit 1" >> header.sh
echo "fi" >> header.sh
echo "exit 0" >> header.sh
echo "__ARCHIVE_FOLLOWS__" >> header.sh

cat header.sh "$outputfilename".tar.gz > $HOME/"$outputfilename".sh

cd $HOME
echo "Finished, check your home folder . . . press [Enter] to quit"
read dummy
rm -rf /tmp/Sirx
exit 0

I also put it up on my site along with the home-made man page for it and further info on how to use it properly.

ReggieMicheals

  • Member
  • **
  • Posts: 186
  • Kudos: 228
    • http://osadvocacy.frih.net/
Re: Self-extracting archive
« Reply #6 on: 4 March 2006, 23:00 »
What UNIX needs is less irritating makefiles and more windows-like installers/uninstallers with actual binaries if the home market is going to accept UNIX OSes. Its a small step, but it's a step nonetheless...
Operating System Advocacy. I've given up on the Microsuck project, as well as any of the minisite spinoffs. You can still view the new beta site, though!

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: Self-extracting archive
« Reply #7 on: 5 March 2006, 03:17 »
I like binaries ... but not Window$ installers ... after switching to Linux, I realized how retarded the Window$ installers really are. They all go something like this if I remember correctly:

Double-click the exe file ... it loads after 1-2 min
"Blah, Blah, Blah, Blah, Blah, Blah ... click next" -> you click next
"Do you accept this 200 page EULA ?" Only option: Yes -> you click yes
click next 5 times
"Install to /Program File$ ?" -> yes
click next 5 more times
"Installing" ...
30-45 minutes later ... Done
And you goto the next installer and do it over again !!!

You wonder how efficient this system really is ... not at all efficient. I was really surprised by how easily and quickly RPMS install compared to the Window$ way. With rpm it takes like 2 steps max and installs nearly instantly. I'm never going back to Window$ ... or any of their inefficient bullshit.

If you want Linux installers try Loki ... too bad they went out of business.

Aloone_Jonez

  • Administrator
  • Member
  • ***
  • Posts: 4,090
  • Kudos: 954
Re: Self-extracting archive
« Reply #8 on: 5 March 2006, 16:52 »
It depends alot on the installer, I haven't had any trouble with OpenOffice, Opera and Firefox but some of the shareware shitware used to give me that kind of grief.
This is not a Windows help forum, however please do feel free to sign up and agree or disagree with our views on Microsoft.

Oh and FUCKMicrosoft! :fu:

ReggieMicheals

  • Member
  • **
  • Posts: 186
  • Kudos: 228
    • http://osadvocacy.frih.net/
Re: Self-extracting archive
« Reply #9 on: 5 March 2006, 18:37 »
Quote
You wonder how efficient this system really is ... not at all efficient. I was really surprised by how easily and quickly RPMS install compared to the Window$ way. With rpm it takes like 2 steps max and installs nearly instantly. I'm never going back to Window$ ... or any of their inefficient bullshit.

Yeah, you do have to wonder what moron came up with the idea. What would be better is something along the lines of a self extracting zip file with a self deletion program in the installed directory.
Operating System Advocacy. I've given up on the Microsuck project, as well as any of the minisite spinoffs. You can still view the new beta site, though!

Orethrius

  • Member
  • **
  • Posts: 1,783
  • Kudos: 982
Re: Self-extracting archive
« Reply #10 on: 5 March 2006, 22:10 »
Quote from: ReggieMicheals
What would be better is something along the lines of a self extracting zip file with a self deletion program in the installed directory.


You mean emerge -C? :p

Proudly posted from a Gentoo Linux system.

Quote from: Calum
even if you're renting you've got more rights than if you're using windows.

System Vitals

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: Self-extracting archive
« Reply #11 on: 5 March 2006, 22:53 »
Ok ... here's the last version of the script ... you now have the ability to install and remove a program anywhere not just /usr/local ... as for the suggestion to put an uninstall script in the install directory ... there would be a lot of scripts there after installing lots of stuff. Besides, I keep the installers for everything I install just in case I need to re-install it.

Code: [Select]
#!/bin/sh

if [ -a /tmp/Sirx ]; then
 rm -rf /tmp/Sirx
fi

mkdir /tmp/Sirx
mkdir /tmp/Sirx/local

echo "Build package from [s]ource or from [b]inary? "
read pack

echo "Install path? "
read installpath

if [ "$pack" == "s" ]; then
 mkdir /tmp/Sirx/source
 echo "Path to folder containing configure and/or Makefile? "
 read inputsource
 cd "$inputsource"
 cp -r * /tmp/Sirx/source
 cd /tmp/Sirx/source
 if [ -a configure ]; then
  if ./configure --prefix="$installpath" ; then
   echo "configure complete"
  else
   echo "!configure failed!"
   read dummy
   exit 1
  fi
 fi
 if make ; then
  echo "make complete"
 else
  echo "!make failed!"
  read dummy
  exit 1
 fi
 if make prefix=/tmp/Sirx/local install ; then
  echo "make install complete"
 else
  echo "!make install failed!"
  read dummy
  exit 1
 fi
elif [ "$pack" == "b" ]; then
 echo "Path to folder containing binary? "
 read inputbinary
 cd "$inputbinary"
 cp -r * /tmp/Sirx/local
else
 echo "!Incorrect input!"
 read dummy
 exit 1
fi

cd /tmp/Sirx/local

echo "Name of output package file? "
read outputfilename

tar -czf /tmp/Sirx/"$outputfilename".tar.gz *

find -type f > /tmp/Sirx/remove.txt

cd /tmp/Sirx/
sed 's/\.//' remove.txt > removefixed.txt

echo "#!/bin/sh" > header.sh
echo SKIP=\`awk \'\/\^__ARCHIVE_FOLLOWS__\/ { print NR + 1\; exit 0\; }\' \$0\` >> header.sh
echo 'echo' \""$outputfilename"\" >> header.sh
echo 'echo "Select: [i]nstall, [r]emove, e[x]tract, or any other key to quit? "' >> header.sh
echo "read switch" >> header.sh
echo 'if [ "$switch" == "i" ]; then' >> header.sh
echo 'echo "Installing . . ."' >> header.sh
echo 'tail +$SKIP $0 | tar xz -C '"$installpath" >> header.sh
echo 'echo "Done"' >> header.sh
echo 'elif [ "$switch" == "r" ]; then' >> header.sh
echo 'echo "Removing . . ."' >> header.sh
while read line
do
 echo rm "$installpath""$line" >> header.sh
done < removefixed.txt
echo 'echo "Done"' >> header.sh
echo 'elif [ "$switch" == "x" ]; then' >> header.sh
echo 'echo "Extract directory? "' >> header.sh
echo "read extract" >> header.sh
echo 'echo "Extracting . . ."' >> header.sh
echo 'tail +$SKIP $0 | tar xz -C "$extract"' >> header.sh
echo 'echo "Done"' >> header.sh
echo "else" >> header.sh
echo "exit 1" >> header.sh
echo "fi" >> header.sh
echo "exit 0" >> header.sh
echo "__ARCHIVE_FOLLOWS__" >> header.sh

cat header.sh "$outputfilename".tar.gz > $HOME/"$outputfilename".sh

cd $HOME
echo "Finished, check your home folder . . . press [Enter] to quit"
read dummy
rm -rf /tmp/Sirx
exit 0

piratePenguin

  • VIP
  • Member
  • ***
  • Posts: 3,027
  • Kudos: 775
    • http://piratepenguin.is-a-geek.com/~declan/
Re: Self-extracting archive
« Reply #12 on: 6 March 2006, 19:25 »
Quote from: H_TeXMeX_H
I like binaries ... but not Window$ installers ... after switching to Linux, I realized how retarded the Window$ installers really are. They all go something like this if I remember correctly:

Double-click the exe file ... it loads after 1-2 min
"Blah, Blah, Blah, Blah, Blah, Blah ... click next" -> you click next
"Do you accept this 200 page EULA ?" Only option: Yes -> you click yes
click next 5 times
"Install to /Program File$ ?" -> yes
click next 5 more times
"Installing" ...
30-45 minutes later ... Done
And you goto the next installer and do it over again !!!
Yea, heh. Doing that for like 10+ packages would be hell.
Quote

If you want Linux installers try Loki ... too bad they went out of business.
There's also autopackage and probably some others.
"What you share with the world is what it keeps of you."
 - Noah And The Whale: Give a little love



a poem by my computer, Macintosh Vigilante
Macintosh amends a damned around the requested typewriter. Macintosh urges a scarce design. Macintosh postulates an autobiography. Macintosh tolls the solo variant. Why does a winter audience delay macintosh? The maker tosses macintosh. Beneath female suffers a double scum. How will a rat cube the heavier cricket? Macintosh calls a method. Can macintosh nest opposite the headache? Macintosh ties the wrong fairy. When can macintosh stem the land gang? Female aborts underneath macintosh. Inside macintosh waffles female. Next to macintosh worries a well.

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: Self-extracting archive
« Reply #13 on: 6 March 2006, 21:24 »
Of course, the other problem is getting people to use your packaging software. So far I've only come across 1 autopackage for 1 program ... in the last year. There are far more RPMS out there than any other packaging system ... as far as I've seen. Too bad it's so hard to make them correctly.

mobrien_12

  • VIP
  • Member
  • ***
  • Posts: 2,138
  • Kudos: 711
    • http://www.geocities.com/mobrien_12
Re: Self-extracting archive
« Reply #14 on: 8 March 2006, 03:10 »
Quote from: H_TeXMeX_H

"Installing" ...
30-45 minutes later ... Done
And you goto the next installer and do it over again !!!

You forgot the fact where you have to reboot after running most windows installers.
In brightest day, in darkest night, no evil shall escape my sight....