LINUX.ORG.RU

Ответ на: комментарий от Severus_Zley

а что, много народу знает про эту утилитку?
популязирую, так сказать
тебе жалко?

ldconfig
() автор топика
Ответ на: комментарий от AnnaKonda

нет конечно, это просто дополнение
например удобно посмотрет размер пакета (spm -qi)
или список файлов в установленном пакете (spm -ql)

не нравится - не пользуй, я не заставляю

ldconfig
() автор топика
Ответ на: комментарий от ldconfig

Ну да, вообще-то и действительно полезная штука.
Для интереса переписала этот скрипт с перла на шелл.
Гляньте, кому не лень, может какие ошибки найдете или что...
Хотя вообще-то на debian'е эта хреновина не сильно нужна :)
Ну, слаководы, вперед!

#!/bin/sh

# Slackware Package Manager
# ver 1.1.1
# Copyright (C) 2000  Edoardo Di Sante <striker@interfree.it> - perl version
# Copyright (C) 2004  Anna Krinitzina  <anna_konda@inbox.ru> - shell version
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

PACKAGE_PATH="/var/adm/packages"

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=[ let's begin ]=-=-=-=-=-=-=-=-=-=-=-=-=- #

OPTION=$1
FILE=$2
DIR=$3

# -=-=-=-=-=-=-=-=-=-=-=-=-=[ functions ]=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #

usage()
{
        echo -e "\nSPM - Slackware Package Manager"
        echo -e "ver. 1.1.1\n"
        echo -e "Usage: spm [-options] [filename]\n"
        echo -e "-i   --install   install a new rpm package"
        echo -e "-t   --tgzinst   install a new tgz package"
        echo -e "-c   --convert   convert a rpm to tgz"
        echo -e "-q   --query     list packages currently installed"
        echo -e "-qi  --qinfo     display package information"
        echo -e "-ql  --qlist     list files in package"
        echo -e "-e   --erase     uninstall a package"
        echo -e "-u   --upgrade   upgrade a package currently installed"
        echo -e "-c   --make      make a tgz package"
        echo -e "-w   --view      view files in package without installing\n"
}

checkroot()
{
        if [ `id -u` != 0 ]; then
                echo '*** Error: you are not root.'
                exit 1
        fi
}

install()
{
	checkroot

	if [ x$FILE = "x" ]; then
		echo usage: spm -i \[package name\]
		exit 1
	fi

	test -r $FILE

	if [ $? = 1 ]; then
		echo "*** Error: cannot open file $FILE"
		exit 1
	fi
	
	if [ x`echo $FILE | grep -r \\.tgz$` != "x" ]; then
		echo "*** Error: file `basename $FILE` seems to be a tgz package."
		echo "*** Install it using \"spm -t $FILE\""
		exit 1
	fi

	if [ x`echo $FILE | grep -r \\.rpm$` = "x" ]; then
		echo "*** Error: filename `basename $FILE` is invalid - it must be an rpm package"
		exit 1
	fi

	echo Converting rpm package to tgz...

	if [ `rpm2tgz $FILE` ]; then
		echo "*** Error: rpm2tgz failed"
		exit 1
	fi

	FILE=`echo $FILE | sed s/rpm$/tgz/`

	echo Installing package...
	if [ `installpkg $FILE >/dev/null 2>/dev/null` ]; then
		echo Package installation failed
		exit 1
	fi

	rm -f $FILE
	echo Done.
}

query_info()
{
	head -n5 $PACKAGE_PATH/`basename $FILE` 
	TMP=`echo \`basename $FILE\` | awk -F- '{ print $1 }'`
	grep -r $TMP\*\: $PACKAGE_PATH/`basename $FILE` | sed -e s/$TMP\*\:// -e s/^\ //
}

query_list()
{
	if [ -e $PACKAGE_PATH/`basename $FILE` ]; then :; else
		echo "*** Error: package `basename $FILE` is not installed"
		exit 1
	fi
	cat $PACKAGE_PATH/`basename $FILE` | grep -x 'FILE LIST:' -A999999999 #how else can i print to the EOF?
	
}

tgzinstall()
{
	checkroot

	if [ x$FILE = "x" ]; then
		echo usage: spm -t \[package name\]
		exit 1
	fi

	test -r $FILE

	if [ $? = 1 ]; then
		echo "*** Error: cannot open file $FILE"
		exit 1
	fi
	
	if [ x`echo $FILE | grep -r \\.tgz$` = "x" ]; then
		echo "*** Error: filename `basename $FILE` is invalid - it must be a tgz package"
		exit 1
	fi

	if [ x`echo $FILE | grep -r \\.rpm$` != "x" ]; then
		echo "*** Error: file `basename $FILE` seems to be an rpm package."
		echo "Install it using \"spm -i $FILE\""
		exit 1
	fi

	echo Installing package...
	installpkg $FILE >/dev/null
	echo Done.
	
}

query_all()
{
	if [ x$FILE = "x" ]; then
		ls $PACKAGE_PATH
	else
		ls $PACKAGE_PATH | grep $FILE
	fi
}

convert()
{
	# do we need to check if we are root?
	# i thnk we needn't
	# the original perl version of spm did the check
	# uncomment the following line to enable "uid = 0" check
	#
	# checkroot

	if [ x$FILE = "x" ]; then
		echo usage: spm -c \[package name\]
		exit 1
	fi
	
        if [ x`echo $FILE | grep -r \\.rpm$` = "x" ]; then
		echo "*** Error: filename `basename $FILE` is invalid - it must be an rpm package"
		exit 
	fi
	
	test -r $FILE
	if [ $? = 1 ]; then
		echo "*** Error: cannot open file $FILE"
		exit 1
	fi
	
	echo Converting rpm package to tgz...
	rpm2tgz $FILE >/dev/null
	echo Done. Package `echo $FILE | sed s/rpm$/tgz/` is ready

}

erase()
{
	checkroot
	
	if [ x$FILE = "x" ]; then
		echo usage: spm -e \[package name\]
		exit 1
	fi

	test -e $PACKAGE_PATH/`basename $FILE`
	if [ $? = 1 ]; then
		echo "*** Error: package `basename $FILE` is not installed"
		exit 1
	fi

	echo Removing package...
	removepkg $FILE >/dev/null
	echo Done.
}

upgrade()
{
	checkroot
	
	if [ x$FILE = "x" ]; then
		echo usage: spm -u \[package name\]
		exit 1
	fi

	test -e $FILE
	if [ $? = 1 ]; then
		echo "*** Error: file $FILE not found"
		exit 1
	fi

	if [ x`echo $FILE | grep -r rpm$` = "x"]; then :; else
		echo Converting rpm package to tgz...
		rpm2tgz $FILE >/dev/null
		echo Done.
		FILE=`echo $FILE | sed s/rpm$/tgz/`
	fi
	
	echo Upgrading package...
	upgradepkg $FILE
	echo Done.
}

make()
{
	if [ x$FILE = "x" -o x$DIR = "x" ]; then
		echo "usage: spm -m [package name] [directory] (don't use extension in \"package name\")"
	fi

	test -d $DIR
	if [ $? = 1 ]; then
		echo "*** Error: $DIR is not a directory"
		exit 1
	fi

	if [ x`echo $FILE | grep -r \\.tgz$` = "x" ]; then :; else
		FILE=`echo $FILE | sed s/\.tgz$//`
		echo $FILE
	fi

	echo Creating and gzipping $FILE.tgz...
	tar czf $FILE.tgz $DIR
	echo Done. Package $FILE.tgz is ready.
}

view()
{
	if [ x$FILE = "x" ]; then
		echo usage: spm -w \[file name\]
		exit 1
	fi

	if [ "x`file $FILE | grep gzip`" = "x" ]; then
		echo "*** Error: file seems to be not a gzipped archive"
		exit 1
	fi

	tar tzf $FILE
}

# -=-=-=-=-=-=-=-=-=-=-=-=[ parse command line ]=-=-=-=-=-=-=-=-=-=-=-=- #

case "$OPTION" in

	-i|--install) install ;;
	-qi|--qinfo) query_info ;;
	-ql|--qlist) query_list ;;
	-t|--tgzinst) tgzinstall ;;
	-q|--query) query_all ;;
	-c|--convert) convert ;;
	-e|--erase) erase ;;
	-u|--upgrade) upgrade ;;
	-m|--make) make ;;
	-w|--view) view ;;

	*) usage ;;
esac

AnnaKonda
()
Ответ на: комментарий от AnnaKonda

thanks! считайте что spm updated до 1.1.1 оффициально %)

ldconfig
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.