to install a package:
petget2 fox-1.2.pet
to list all user installed packages:
petget2
to list all user installed packages that start with fox:
petget2 fox
to list all files installed in the package(s) that start with fox:
petget2 fox list
to uninstall all packages that start with fox:
petget2 fox remove
Code: Select all
#!/bin/bash
jwm=`ps aux | grep jwm | grep -v grep`
installed=`ls /var/packages/*.files | uniq -u | cut -f 4 -d '/' | sed 's/\.files//'`
#list all installed packages
if ! [ "$1" ]; then
echo "$installed"
exit
fi
if [ -f "$1" ]; then
install=yes
noext="`echo ${1%.*}`"
ext=${1##*.}
extlow=`echo "$ext" | tr -s [A-Z] [a-z]`
mv "$1" "$noext"."$extlow" 2>/dev/null
file="$noext"."$extlow"
noext2=`basename "$noext"`
fi
if [ "`echo $file | grep '.deb'`" != "" ]; then
echo installing "$file"
mkdir "$noext" 2>/dev/null
if [ `ar t "$file" | grep data.tar` = data.tar.xz ]; then
ar p "$file" data.tar.xz | tar xJ -C "$noext"
rm -f data.tar.xz 2>/dev/null
elif [ `ar t "$file" | grep data.tar` = data.tar.gz ]; then
ar p "$file" data.tar.gz | tar zx -C "$noext"
rm -f data.tar.gz 2>/dev/null
fi
rm -f control.tar.gz 2>/dev/null
rm -f debian-binary 2>/dev/null
fi
if [ "`echo $file | grep '.pet'`" != "" ]; then
echo installing "$file"
cp "$file" "$file".bak
pet2tgz "$file"
if [ -f "$noext".tar.xz ]; then
tar -xf "$noext".tar.xz
rm -f "$noext".tar.xz 2>/dev/null
elif [ -f "$noext".tar.gz ]; then
tar -zxvf "$noext".tar.gz
rm -f "$noext".tar.gz 2>/dev/null
fi
mv "$file".bak "$file"
fi
if [ "$install" = yes ]; then
if [ -d "$noext2" ]; then
cd "$noext2"
if [ -f pinstall.sh ]; then
./pinstall.sh
rm pinstall.sh
fi
if [ -f pet.specs ]; then
info=`cat pet.specs`
echo -e "$info" >> /var/packages/user-installed-packages
rm pet.specs
else
echo -e "$noext2" >> /var/packages/user-installed-packages
fi
#cp -af * /
rsync -a * /
find -L ./ -type f | sed 's/.//' | sort -u > /var/packages/"$noext2".files
desktop=`cat /var/packages/"$noext2".files | grep '.desktop'`
cd ../
rm -rf "$noext2"
if [ "$desktop" != "" ]; then
fixmenus
if [ "$jwm" != "" ]; then
jwm -restart
fi
fi
else
echo no "$noext2" directory found
fi
exit
fi
#find installed packages with given name
packages=`echo "$installed" | grep ^"$1"`
if [ "$packages" != "" ]; then
num=`echo "$packages" | wc -l`
echo
echo $num package\(s\) found
echo
echo "$packages"
echo
if [ "$2" = remove ]; then
echo "$packages" | while read pkg; do
echo removing "$pkg" now
cat /var/packages/"$pkg".files | while read file; do
#if [ -f "$file" ]; then #doesn't always work with symlinks
if ! [ -d "$file" ]; then
echo removing "$file"
rm "$file" 2>/dev/null
fi
done
dir2=""
cat /var/packages/"$pkg".files | sort -r | while read file; do
if ! [ -d "$file" ]; then
dir=`dirname "$file"`
if [ -d "$dir" ]; then
if [ "`echo $dir`" != / ]; then
if [ "$dir" != "$dir2" ]; then
echo searching for empty directories to remove in "$dir"
find "$dir" -type d -empty -delete 2>/dev/null
fi
fi
fi
else
if [ "`echo $file`" != / ]; then
echo searching for empty directories to remove in "$file"
find "$file" -type d -empty -delete 2>/dev/null
fi
fi
dir2="$dir"
done
desktop=`cat /var/packages/"$pkg".files | grep '.desktop'`
rm /var/packages/"$pkg".files
cat /var/packages/user-installed-packages | grep -v ^"$pkg" > /var/packages/user-installed-packages.new
mv /var/packages/user-installed-packages.new /var/packages/user-installed-packages
if [ "$desktop" != "" ]; then
fixmenus
if [ "$jwm" != "" ]; then
jwm -restart
fi
fi
done
fi
if [ "$2" = list ]; then
echo "$packages" | while read pkg; do
cat /var/packages/"$pkg".files | sort -u
done
fi
fi