#!/bin/sh # ROOT Linux Package Manager v1.0.0pre1 # Released under the GNU GPL v2 # John Eriksson # TODO : # # - Handle dots in filenames better # Set version VERSION="1.0.0pre1" # Where to store tempfiles TMP="/tmp" # Usage function usage() { echo "ROOT Linux Package Manager $VERSION" echo echo "Usage: pkgtool [--install,-i] [--uninstall,-u]" echo " pkgtool [--showpkgs,-s] [--showpackage,-p]" echo " pkgtool [--version,-v]" } # Version information if [ "$1" = "--version" -o "$1" = "-v" ]; then echo "ROOT Linux Package Manager $VERSION" echo "Copyright (C) 2001 John Eriksson." echo "Part of ROOT Linux v1.3 (Noodle)." echo "Released under the GNU GPL v2." exit fi # Print usage if [ "$1" = "-h" -o "$1" = "--help" ]; then usage exit fi # Show a package if [ "$1" = "--showpackage" -o "$1" = "-p" ]; then if [ "$2" = "" ]; then echo "pkgtool: no package to show" exit 1 fi if ! [ -f /var/log/packages/$2 ]; then echo "pkgtool: package '$2' does not exist." exit 1 fi echo "File database for '$2' is /var/log/packages/$2" >/tmp/pkgcontents echo "Exit with 'q'. Contents in package '$2':" >>/tmp/pkgcontents echo >>/tmp/pkgcontents cat /var/log/packages/$2 >>/tmp/pkgcontents less /tmp/pkgcontents exit fi # Show installed packages if [ "$1" = "--showpkgs" -o "$1" = "-s" ]; then if ( cd /var/log/packages 2>/dev/null >/dev/null ); then cd /var/log/packages ls | less exit else echo "pkgtool: error: /var/log/packages missing." exit 1 fi fi if [ "$1" = "--uninstall" -o "$1" = "-u" ]; then if [ "$2" = "" ]; then echo "pkgtool: error: don't know what to uninstall." exit 1 fi if [ "$2" = "*" ]; then echo "damn, if i hadn't fixed this you'd have" echo "deleted the whole shit!" echo echo "please send me (at least) \$20 for rescuing you." exit 1 fi if ! [ -f /var/log/packages/$2 ]; then echo "pkgtool: $2: package does not exists." exit 1 fi echo -n "pkgtool: uninstalling $2..." cd / cat var/log/packages/$2 | xargs rm 2>/dev/null >/dev/null rm -f var/log/packages/$2 2>/dev/null >/dev/null echo " done." exit fi if [ "$1" = "--install" -o "$1" = "-i" ]; then if [ "$2" = "" ]; then echo "pkgtool: don't know what to install." exit 1 fi if ( echo $2 | grep .rpm >/dev/null 2>/dev/null ); then echo "pkgtool: rpm files not supported (convert with 'rpm2tgz')." exit 1 fi if ! ( echo $@ | grep "/" 2>/dev/null >/dev/null); then if ! [ -f "$PWD/$2" ]; then echo "pkgtool: error: could not find '$2'" exit 1 fi echo -n "pkgtool: Installing $2..." pack=$(echo $2 | cut -f1 -d.) OLDPWD=`pwd` cd / tar -zxvf $OLDPWD/$2 2>/dev/null >/var/log/packages/$pack if [ -f install/doinst.sh ]; then . install/doinst.sh rm -f install/doinst.sh 2>/dev/null >/dev/null rmdir install/ 2>/dev/null >/dev/null fi echo " done." exit else string=$(echo "$2") for x in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25; do tmp=$(echo $string | cut -d/ -f $x) echo $tmp > /tmp/pkgtmp if ( grep ".tgz" /tmp/pkgtmp 2>/dev/null >/dev/null ); then small=$(cat /tmp/pkgtmp | cut -f1 -d.) fi done cd / if [ "$small" = "" ]; then echo "pkgtool: unexpected error; exiting." exit 1 fi echo -n "pkgtool: Installing $small.tgz..." tar -zxvf $2 2>/dev/null >/var/log/packages/$small if [ -f install/doinst.sh ]; then . install/doinst.sh rm -f install/doinst.sh 2>/dev/null >/dev/null rmdir install/ 2>/dev/null >/dev/null fi echo " done." exit fi fi usage exit #EOF