LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices

Reply
 
Search this Thread
Old 05-29-2012, 05:19 PM   #1
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Rep: Reputation: Disabled
BASH script for package files


UPDATE
I found some 'used' linux isos from a year or so ago. The Puppy ones had the best results. The info from the posts from pan64 and David the H. was helpful. POSIX-compliancy (as well as scripting) has been improved. I used a script from the debian devscripts package (checkbashisms) for check, and actually booted into 3 linux distros with dash and 3 Puppy Linux versions. The Puppy tests proved OK with the removal of -n from cp -r -n. The other distros were not as successful. I did manage to get most out of this script, with the caveat of downloading squashfs-tools and unzip. The cp commands did not bode well. Remember that the results were from a small selection and are not indicative of all possibilities -- watch out for issues - also not bug tested or foolproof

Total revisions: 3


The code is below, ready for copy/paste into a shell scipt.

The script I present (only tested on Puppy 5.2.8) is a simple installer written in BASH and is very simple to use. It is designed to be used as either a quick call for other scripts or directly in a terminal. It supports pet, deb, tar (just -xf)*, sfs, zip*, and pup* formats. It is composed of about 100 lines of code and can be freely modified. It is transparent in the sense that it does not execute scripts - just extract/installs.
*not directly installed, default path = /TEMP, tar path can be modified

It definitely proved useful to me, and can easily be modified, if you know BASH.
Because it was not extensively tested, it may prove buggy, especially in other
versions.
Caution: /TEMP is used so if you have /TEMP rename/move it

Usage: '# fexti [argument] [/filename]'

Destination: 'export D="/usr/bin"' (for tar option, else extracts to /TEMP)

# fexti -h displays in more detail - It is relatively silent.

I hope this can be useful to anyone out there.

Code: (copy/pasted)
Code:
#!/bin/sh

# This file is open to the public and may be freely modified, on the 
# conditions of avoiding the need for X and remaining simple
# currently 100 lines of code

#Major update: checked with
#              checkbashisms, sfs funtion not working in dash

xtar() { # uses the exported D variable for destination path
	echo "...extracting (installing optional) tar $1"
	tar -xf "$1" -C /TEMP 2> /dev/null
	if [ "$D" != "" ]; then
	 cd /TEMP
	 cp -r -n * "$D" # may need to remove -n
	fi
	return	
	}
xzip() {
	echo "...extracting zip $1"
	echo;
	cp "$1" /TEMP
	cd /TEMP
	unzip *.zip > /dev/null
	rm *.zip	
	return
	}
xpup() {
	echo "...extracting pup $1"
	echo;
	cp "$1" /TEMP
	cd /TEMP
	unzip *.pup > /dev/null
	rm *.pup
	mv FILESYSTEM.tbz FILESYSTEM
	T=*.tbz
	tar -xf $T 2> /dev/null
	echo "Check in folder:" 
	du --max-depth 1 /TEMP | grep "/TEMP/"
	return
	}	
xdeb() {
	echo "...installing deb $1"
	dpkg-deb -x "$1" /TEMP 2> /dev/null
	cp -r -n /TEMP/* / #may have to remove the -n option
	return
	}
xpet() {
	echo "...installing pet $1"
	tar -xf "$1" -C /TEMP 2> /dev/null
    cp -r -n /TEMP/*/* / #may have to remove the -n option
	return
	}
xsfs() {
	echo "...installing sfs $1" #large sfs files can be risky for low RAM	
	cp "$1" /TEMP
	cd /TEMP
	unsquashfs *.sfs
	cp -r -n squashfs-root/* / #may have to remove the -n option
    rm -r squashfs-root
	return
	}

#main 
 if [ "$1" = "" -a "$2" = "" ]; then
  echo ; echo
  echo "-fexti-"
  echo "Script for faster extraction/installation"
  echo "Caution:  /TEMP is used so if you have /TEMP rename/move it"
  echo "Not compatible with 'scripted' packages"
  echo "Only tested with Puppy Lucid 5.2.8 - source is easy to edit"
  echo "Use -h for help.";echo;
 fi
 if [ "$1" = "-h" ]; then 
  echo "This is a simple shell script to extract (installs most) packages"
  echo "Caution:  /TEMP is used so if you have /TEMP rename/move it"
  echo "Usage '# fexti [argument] [/filename]";echo;
  echo "Arguments: (at least one required to extract)"
  echo " -h...................help"
  echo " -pet.................extracts and installs pet file"
  echo " -deb.................extracts and installs deb file"
  echo " -tar.................extracts tar file (install optional)"
  echo "                      works for gz, tgz as well (-xf)"
  echo " -sfs.................extracts and installs sfs file"
  echo " -zip.................simply extracts to /TEMP"
  echo " -pup.................simply extracts to /TEMP"
  echo "Note:"
  echo " export D=\"/usr/bin\" gives tar specific destination"
 fi
 rm -r /TEMP 2> /dev/null #If /TEMP is used prior rename/move it
 mkdir /TEMP 
 if [ "$1" = "-pet" ]; then xpet "$2"; EXT="R";fi
 if [ "$1" = "-sfs" ]; then xsfs "$2"; EXT="R"; fi
 if [ "$1" = "-zip" ]; then xzip "$2"; fi
 if [ "$1" = "-pup" ]; then xpup "$2"; fi
 if [ "$1" = "-deb" ]; then xdeb "$2"; EXT="R"; fi
 if [ "$1" = "-tar" ]; then xtar "$2"; fi
 if [ "$EXT" = "R" ]; then rm -r /TEMP;fi
 export D=""
#EOF

Last edited by bobbobbix; 06-02-2012 at 07:26 AM. Reason: fix
 
Old 05-30-2012, 04:01 AM   #2
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Original Poster
Rep: Reputation: Disabled
Testing Successful

I copied/pasted the code, using the right click menu in ROX-Filer, and it works for my version of Puppy Linux (Lucid 5.2.8) Again, only tested in that version.

I noticed a couple of minor technical oversights:
1) init variables line: 'export USR=""'
2) couple indentation problems from copy/pasting

1) That can be removed - came from revisions: like the commonality of leaving in past-revision remarks

2) Obvious from past c++ experiences. My coding has most likely become sloppy from lack of use over a long time

I made a second post because I want to keep my original post pristine - acceptable?
 
Old 05-30-2012, 04:06 AM   #3
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,928

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
if you use variables only inside a shell script you need not use export.
 
Old 05-30-2012, 04:31 AM   #4
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks for the reply. If you look more closely, you will see some variables use export some don't. I used export for 2 purposes:
1) It was the only way I found to get variables passed into functions (global style)
2) Use as an external method "D" for the user to optionally specify destination for tar function

Init variable declaration has also been common practice in the past. In this case, the variable EXT is cleared on init

EDIT:
Code is now fixed. Below is a sample script of how to use it

Code:
#!/bin/sh

#remember to rm -r or mv /TEMP if needed
fexti -sfs /mnt/+mnt+sr0+dvd.sfs/tools/LibreOfc_3.3.0_rc4_sfs4.sfs 
fexti -pet /mnt/+mnt+sr0+dvd.sfs/internet/Opera-11.50-Lucid.pet 
fexti -zip  /mnt/+mnt+sr0+dvd.sfs/internet/QtWeb-elf386.zip
mv /TEMP /qtweb
#fixed careless omission in script
export D="/usr/bin"

#fexti -tar /mnt/+mnt+sr0+dvd.sfs/internet/w3m-0.5.3-4_SLXR.tgz
#no longer works by default but still works with tampering

#prep
chmod -x /qtweb/QtWeb
chmod 777 /qtweb/QtWeb

#ln -s /usr/lib/libtermcap.so /usr/lib/libtermcap.so.2 #w3m 
#see above for w3m

#now some fun
libreoffice &
opera &
xterm -e w3m google.com &
./qtweb/QtWeb &

Last edited by bobbobbix; 05-30-2012 at 07:22 PM. Reason: fix
 
Old 05-31-2012, 10:12 AM   #5
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Original Poster
Rep: Reputation: Disabled
I have a compiled a list of actual packages that worked with the main script, using the right-click menu of ROX-Filer to 'Set Run action'

I have included the contents of the file that lists what works and what has not been found to work.

Fair warning that the following is around 200 lines, so prepare for a lot of reading/skimming.

Missed Finding
An uncomfortably large "mini" ratio of unsuccessful pup files are not successful in this one test. No guarantees.

Quote:
dvd.sfs (md5sum: 99e4131fb2852173a79fb05fee203d46)
Revision Script: 3
Be careful with wildcards
Packages
Improvement:
WORKS/DOESN'T WORK/TOTAL: 105 (count *)/ 49 / 154 (counted and double checked)
Doesn't Work
25 Drivers (mesa?)(circumstance)
8 Already Present in 5.2.8 (older versions included)(circumstance)
7 Scripted/Sequenced
5 Bad Downloads* (circumstance)
4 Unknown
Fair Odds: 11 bad (7+4) to 105 good

|-- booklet
|-- desktop
| |-- Lucid_Wallpapers.pet (bad download)
| `-- ReallySlickScreensavers-0.9.1-lucid52.pet (bad download)
|-- drivers
| |-- ath5k-patched-k2.6.33.2.pet
| |-- ATI_fglrx-10.10-Lucid.pet
| |-- broadcom_wl-K2.6.37.6-spup.pet
| |-- canon-ip2600-dpup.pet
| |-- flsynclient-.6.pet
| |-- hal-0.5.14-Lucid52.pet
| |-- hpijs-3.10.6-dynppd.pet
| |-- hplip-3.9.12-scan.pet
| |-- Litescribe-1.4.pup
| |-- Lucid511-FullNvidia_260.19.12-k2.6.33.2.pet
| |-- Lucid511-nvidia_260.19.12-k2.6.33.2.pet
| |-- Luci_Nvidia-256.35-k2.6.33.2-p5.pet
| |-- mesa-7.9.2.pet
| |-- Mesa-utils-7.7.1-Lucid.pet
| |-- MultipleSoundcardWizard-lucid525.pet
| |-- nouveau_drv-0.0.15-Lucid.pet
| |-- nouveau_firmware-20091212-Lucid.pet
| |-- nouveau_video-b82312.pet
| |-- NVIDIA-173.14.25_lupu500-k2.6.33.2.pet
| |-- nvidia-195.36.15-k2.6.33.2.pet
| |-- nvidia-195.36.24-k2.6.33.2-L3glx.pet
| |-- Nvidia-256.35_lupu500-k2.6.33.2.pet
| |-- NVIDIA-96.43.16_lupu500-k2.6.33.2.pet
| |-- nvidia_lucid_a-256.36-k2.6.33.2-p5.pet
| |-- Xorg_High-1.1-Lucid.pet*
| `-- xorg_xvesa-7.3-1.pet
|-- epdfview
| |-- epdfview_0.1.7-4_i386.deb (already have)
| `-- libpoppler-glib4_0.12.4-1.2_i386.deb (already have)
|-- epsxe
| |-- padJoy081epsxe.tgz*
|-- games
| |-- 5-Voyager-5G.sfs*
| |-- rubix-1.03.tar.gz*
| |-- SDL_jewels-1.1.0-i486.pet*
| |-- sudoku-1.0.1.pet*
| |-- Supertuxkart-0.6.1a1-sfs4.sfs* (/usr/games)
| |-- xbubble-0.5.11.2.orig-i486.pet*
| `-- xmahjongg-3.7.pet*
|-- hardinfo
| |-- hardinfo_0.4.2.3-4_i386.deb (already have)
| `-- libsoup2.2-8_2.2.105-4_i386.deb (already have)
|-- internet
| |-- amaya
| | |-- Amaya-8.52.pet*
| | |-- Amaya_print-8.52.pet*
| | `-- gtk_all-1.2.10-12.pet*
| |-- bmon_2.0.1-3_i386.deb*
| |-- Chromium-15-Lucid.pet*
| |-- Firefox-6.0-lucid525.pet*
| |-- Flashplayer-10.1r85-Lucid51x.pet*
| |-- Flashplayer-10.3r181-lucid.pet*
| |-- flashplayer-9.0.48.0.pet*
| |-- Frisbee-beta-2.pet*
| |-- Google_Chrome-13-Lucid.pet*
| |-- GoogleEarth-5.2.1.sfs*
| |-- Google_Earth-6.0.3.2197-lucid525.pet*
| |-- gtk_youtube-viewer-2.0.3.pet*
| |-- install_flash_player_10_linux.deb (unknown)
| |-- Iron-13-lucid528.pet*
| |-- jre-1.6.0.20.pet*
| |-- kompozer-0.8-dpup.pet* (/opt/kompozer-0.8a4)
| |-- links2_2.3~pre1-1_i386.deb*
| |-- netsurf2-2.5-lupu.pet*
| |-- Opera-11.50-Lucid.pet*
| |-- opera_11.51.1087_i386.deb*
| |-- pidgin-basics-2.5.5-i486-uj.pet*
| |-- QtWeb-elf386.zip* (permissons -x, then 777)
| |-- Seamonkey-2.3-lucid525.pet*
| |-- seamonkey_pb-1.0-lucid.pet (bad download)
| |-- Skype-2.1.0-Lucid.pet*
| |-- w3m-0.5.3-4_SLXR.tgz* (ln -s needed)
| |-- weechat-0.3.1-i486-dpup.pet*
| |-- wondershaper_1.1a-5_all.deb*
| |-- xchat-2.8.6-dpup.pet (already have-downgrade)
| |-- Xchat-gnome-2.8.8-Lucid.pet (already have)
| `-- youtube-dl_2012.01.05-2_all.deb*
|-- libs
| |-- gtk+12-1.2.10.pet*
| |-- libglib-1.2.pet*
| |-- libgmodule-1.2.pet (bad download)
| |-- libgmodule-1.2.tar.gz*
| `-- libpng-1.2.34.pet*
|-- m64
| |-- libsamplerate0_0.1.7-3_i386.deb*
| |-- libsdl-ttf2.0-0_2.0.9-1_i386.deb*
| |-- libxdg-basedir1_1.1.1-1_i386.deb*
| |-- mupen64plus_1.5+dfsg1-13_i386.deb*
|-- network
| |-- file-roller-2.30.0.pet* (archive manager - oops)
| |-- FileZilla-3.3.0.1-i686-dpup.pet*
| |-- FileZilla-3.3.3-Lucid.pet*
| |-- Samba-3.4.7-Lucid.pet (scripted)
| `-- unison-2.27.57-i486-dpup.pet*
|-- pcmanfm
| |-- gvfs-fuse_1.6.4-3_i386.deb*
| |-- libfm0_0.1.12-1_i386.deb*
| |-- libfm-gtk0_0.1.12-1_i386.deb*
| |-- libmenu-cache1_0.3.2-2_i386.deb*
| |-- lxmenu-data_0.1.1-1_all.deb*
| |-- OtherFileManagers
| | |-- Emelfm2-2006-12-22.pup (script)
| | |-- Endeavour-2.6.1.pup (script)
| | |-- gnome-commander-1.2.8.9-lucid.pet*
| | |-- thunar-1.0.2-1-i486.pet*
| | `-- xfe-1.32.2-lucid52.pet*
| `-- pcmanfm_0.9.7-1_i386.deb*
|-- random
| |-- 1337-generator-0.2.pet*
| |-- freeglut3_2.6.0-1_i386.deb*
| |-- nerolinux-4.0.0.0b-x86.deb*
| |-- tree_1.5.3-1_i386.deb*
| |-- wipe_0.21-9_i386.deb*
|-- timidity
| |-- freepats_20060219-1_all.deb*
| |-- timidity_2.13.2-39+b1_i386.deb*
| `-- timidity-daemon_2.13.2-39_all.deb*
`-- tools
|-- alien_8.81_all.deb*
|-- avidemux2-2.5.1-i486-dpup.pet*
|-- Beryl-0.2.1-9-SINGLE_GO-p43nl5-i686-1.pet (sequence)
|-- Compiz-0.8.4-Lucid.pet (scripted)
|-- Conky-1.8.0-Lucid.pet*
|-- cpulimit-1.3.gz*
|-- cursor_themes.pet*
|-- DataRecovery
| |-- foremost_1.5.7-1_i386.deb*
| |-- scalpel_1.60-1build1_i386.deb*
| |-- testdisk-6.11.3.pet*
|-- devscripts_2.11.6ubuntu1_i386.deb*
|-- dosbox-0.72.pet*
|-- dosemu_1.4.0+svn.1999-2_i386.deb*
|-- drec-2.1-i686-dpup.pet (as tar, cp -r -n the usr folder to /, then run in sbin, still messy)
|-- dvdrip-0.52.5.pup (scripted)
|-- Eterm-0.9.4.pet*
|-- Frodo-4.1b-US.pup*
|-- galculator-1.3.4-i486-uj.pet*
|-- gcalctool_lucid52-0.pet (have it)
|-- gcc-4.2.2-1.pet (bad download)
|-- ghex-2.24.0-lucid52.pet* (ghex2)
|-- Gimp-2.6.10-Lucid.pet*
|-- gnucash-2.2.9-5-Lucid.pet*
|-- gnupg-1.4.11-i486.pet (have it)
|-- inkscape-0.4.5-i686-dpup.pet*
|-- LibreOfc_3.3.0_rc4_sfs4.sfs*
|-- lsof-4.77.pet*
|-- Musescore-1.0-lucid525.pet* (mscore)
|-- numlockx_Lucid_1.1-10.pet*
|-- ogle-DVD-Player-0.9.2-1-patched4.2-i386.pet*
|-- p7zip-4.58.pet (unknown)
|-- p7zipxz_lucid52-0.pet (unknown)
|-- pan-0.132-dpup.pet*
|-- partimage-0.6.4-static.tar.bz2*
|-- perl-5.8.8.pet*
|-- pkgtool-0.4.1.tar.gz*
|-- pwidgets-2.4.0.pet*
|-- python_for_CCSM-2.pet (sequence)
|-- qemu-0.91-launchscript-SDL-1.29.pet*
|-- Stellarium-0.10.4-Lucid.pet*
|-- syslinux-common_4.04+dfsg-1ubuntu1_all.deb*
|-- unrar-3.7.8.pet*
|-- unrpm.undeb.pet*
|-- util-linux_2.17.2-9_i386.deb*
|-- Wbar_with_setup-1.3.3-Lucid.pet*
|-- wine-1.1.33-i686-dpup.pet*
|-- xmorph-20090929-i386.pet*
`-- xvkbd-3.0.pet*

30 directories, 214 files <reduced>

Last edited by bobbobbix; 06-04-2012 at 11:00 AM. Reason: fix
 
Old 06-01-2012, 06:00 AM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949
I see a couple of compatibility problems with the script. There are at least a couple of bash/ksh-specific bits in it.

Remember that if you use #!/bin/sh as the shebang, the script is processed in posix-compatible mode. If your sh-parser is actually bash, then bash-only features are still valid, as long as they don't conflict with posix specifications. But if you use a different shell, like dash, then these lines will generate errors.

Specifically, I noticed the substitution parameter substitution here:

Code:
a=${T/\/*\//};
This variation isn't available in posix. You have to run it through tr or sed or something instead.

Second are the comparison tests like this:
Code:
if [ "$1" == "-h" ]
Again, "==" is not valid in the posix-based test. You have to use "=".


Alternately, switch the shebang to #!/bin/bash and make it bash-specific. In which case you should take advantage of all its more advanced features like the extended "[[" test keyword.

See here for what to avoid when aiming for posix compatibility:

http://mywiki.wooledge.org/Bashism


BTW, since functions run in the current environment, there should never be any need to export anything just for that purpose. But of course it's necessary if any of the external processes executed by the function (or the script) need those values in their environments.

Finally, you need to make sure that all of your variable expansions are properly double-quoted. Those unquoted $D and $EXT variables will result in broken commands if any string stored in them happens to include whitespace or globbing characters.

I also recommend adding tests to ensure that the directories and files actually exist (and are readable/writable, etc.) before use in any of the commands that depend on them.
 
Old 06-01-2012, 11:38 AM   #7
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks for that helpful post. Great points. Feel free to adjust the code to your needs. In reply to your points:

1) I will keep that in mind about using #!/bin/sh. A sed alternate would probably be neater. I never thought about that. (Side note: did you notice the variables spell “Tab" - I did that for chuckles.) I am also not experienced with cross-shell compatibility yet. I skimmed though the wiki you posted and it’s a nice reference.

2) I am excited to report that I found out that it is possible to pass variables regularly to functions. The solution just passed under my nose since day one. I only had to change format to take advantage of it.

3) The double quotes sounds reasonable. Good point.

4) I did explore that idea - to a limited extent. File and directory permissions (r/w included) are somewhat different in this version of Puppy, but I don’t know exactly how. However, that shouldn’t dictate the transfer of permissions stored from extracted files. --> more testing should be done.

All ideas will be considered in future updates with these points in mind while still working as default for Puppy Linux 5.2.8.

Last edited by bobbobbix; 06-01-2012 at 08:39 PM. Reason: variables can in fact be passed regularly to functions
 
Old 06-03-2012, 06:27 PM   #8
bobbobbix
LQ Newbie
 
Registered: May 2012
Distribution: Fatdog64 620
Posts: 12

Original Poster
Rep: Reputation: Disabled
Extended version (experimental)

For those who wish to delve into the experimental side, I offer a version that is able to uninstall the same packages it installs.

Very similar to fexti, comes fextiu, which is able to uninstall the more involving packages it installs - those packages that will take more effort than just deleting a folder. (Inspecting the code will show you exactly how.)

I forgot to mention that general uninstalling (especially manually) carries an inherent risk of breaking other installations. (For example, removing a library file for Program B may affect Program A because Program A depends on that library file, which was removed.) This applies to ALL uninstalls regardless of package manager/program.

About 30ish lines of code added, it is untested except for Puppy 5.2.8. It is a little bit more advanced, but I tried to not go too far.

Revision: 1
Code:
#!/bin/sh

# This file is open to the public and may be freely modified, on the 
# conditions of avoiding the need for X and remaining simple

# Experimental version of fexti with uninstaller (*little* more advanced: 1 function)
#  Script creates /FEXTIU_LOGS/ to store logs of installs
#  Pick one, store to /, then run with uninstall
#  (requires fextiu install for generated logfile)
# Usage: # fextiu -u to uninstall

log="" #init

#1 layer of functions is complex enough: that is f(f(x)) in math
logger() { #A FUNCTION FOR FUNCTIONS $1=$1 (from f(x)) and $2=# flag
			#one layer f(f(x)) is OK for me, but 2 or more layers is
			#almost like spaghetti-code material for me
	if [ ! -d "/FEXTIU_LOGS" ]; then mkdir /FEXTIU_LOGS;fi
	b=$(echo "$1" | sed -re 's/^.+\///') #strip path
	if [ "$2" = "" ]; then cd /TEMP/; fi
	if [ "$2" = "1" ]; then cd /TEMP/*;fi
	find * > "/FEXTIU_LOGS/$b.fextiutxt"
	return
	}
#layer 0 functions (directly from main)
uninstaller() { 
	sed -i 's/^/\//' /*.fextiutxt #make small correction
	a=$(echo /*.fextiutxt)
	xargs rm < $a 2>/dev/null #xargs used to uninstall from list
	echo "fextiu'd"
	return
	}
xtar() { # uses the exported D variable for destination path
	echo "...extracting (installing optional) tar $1"
	tar -xf "$1" -C /TEMP 2> /dev/null
	if [ "$D" != "" ]; then
	 cd /TEMP
	 cp -r -n * "$D" # may need to remove -n
	fi
	return	
	}
xzip() {
	echo "...extracting zip $1"
	echo;
	cp "$1" /TEMP
	cd /TEMP
	unzip *.zip > /dev/null
	rm *.zip	
	return
	}
xpup() {
	echo "...extracting pup $1"
	echo;
	cp "$1" /TEMP
	cd /TEMP
	unzip *.pup > /dev/null
	rm *.pup
	mv FILESYSTEM.tbz FILESYSTEM
	T=*.tbz
	tar -xf $T 2> /dev/null
	echo "Check in folder:" 
	du --max-depth 1 /TEMP | grep "/TEMP/"
	return
	}	
xdeb() {
	echo "...installing deb $1"
	dpkg-deb -x "$1" /TEMP 2> /dev/null
	cp -r -n /TEMP/* / #may have to remove the -n option
	logger "$1" "" 
	return
	}
xpet() {
	echo "...installing pet $1"
	tar -xf "$1" -C /TEMP 2> /dev/null
    cp -r -n /TEMP/*/* / #may have to remove the -n option
	logger "$1" "1"
	return
	}
xsfs() {
	echo "...installing sfs $1" #large sfs files can be risky for low RAM	
	cp "$1" /TEMP
	cd /TEMP
	unsquashfs *.sfs
	cp -r -n squashfs-root/* / #may have to remove the -n option
	rm *.sfs
	logger "$1" "1"
    rm -r squashfs-root    
	return
	}

#main 
 if [ "$1" = "" -a "$2" = "" ]; then
  echo ; echo
  echo "-fextiu-"
  echo "Script for faster extraction/installation/uninstallation"
  echo "Caution:  /TEMP is used so if you have /TEMP rename/move it"
  echo "Not compatible with 'scripted' packages"
  echo "Only tested with Puppy Lucid 5.2.8 - source is easy to edit"
  echo "Use -h for help.";echo;
 fi
 if [ "$1" = "-h" ]; then 
  echo "This is a simple shell script to extract (installs most) packages"
  echo "Caution:  /TEMP is used so if you have /TEMP rename/move it"
  echo "Usage '# fextiu [argument] [/filename]";echo;
  echo "Arguments: (at least one required to extract)"
  echo " -h...................help"
  echo " -pet.................extracts and installs pet file"
  echo " -deb.................extracts and installs deb file"
  echo " -tar.................extracts tar file (install optional)"
  echo "                      works for gz, tgz as well (-xf)"
  echo " -sfs.................extracts and installs sfs file"
  echo " -zip.................simply extracts to /TEMP"
  echo " -pup.................simply extracts to /TEMP"
  echo " -u...................uninstall pet, deb, and sfs files"
  echo "Notes:"
  echo "-export D=\"/usr/bin\" gives tar specific destination"
  echo "-For uninstall packages with -u option, move log from"
  echo "  /FEXTIU_LOGS to / - for tar, pup, and zip, remove /TEMP"
 fi
 rm -r /TEMP 2> /dev/null #If /TEMP is used prior rename/move it
 mkdir /TEMP 
 if [ "$1" = "-pet" ]; then xpet "$2";EXT="R";fi
 if [ "$1" = "-sfs" ]; then xsfs "$2";EXT="R"; fi
 if [ "$1" = "-zip" ]; then xzip "$2";fi
 if [ "$1" = "-pup" ]; then xpup "$2";fi
 if [ "$1" = "-deb" ]; then xdeb "$2";EXT="R"; fi
 if [ "$1" = "-tar" ]; then xtar "$2";fi
 #uninstallation
 if [ "$1" = "-u" ]; then uninstaller;fi
 if [ "$EXT" = "R" ]; then rm -r /TEMP;fi
 export D=""
#EOF

Last edited by bobbobbix; 06-04-2012 at 05:53 AM. Reason: fix
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bash script to compare two files swatward Linux - Newbie 17 04-18-2012 06:14 PM
Looking for a bash/sh script to translate a word with Internet (no package to install Xeratul Programming 22 08-10-2011 08:33 PM
Bash script to convert .mpg files to .avi files? Mike_Snyder Linux - Newbie 5 09-19-2009 01:33 PM
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 08:00 AM
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM


All times are GMT -5. The time now is 09:47 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration