PuppyThis forum is for the discussion of Puppy Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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?
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
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:
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.
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.