jw-pkg/scripts/jannet

206 lines
3.6 KiB
Bash

#!/bin/sh
myname=`basename $0`
longname=$0
opts="v"
channel_present()
{
if smart channel --show $1 2>&1 | grep -q baseurl >/dev/null; then
return 0
fi
return 1
}
usage()
{
cat << EOT
$myname command [arguments]
command is one of
help: show this help screen
init: initialize
uninit: undo initialization
install: install packages in [arguments]
update: update all jannet software on the system
restore: restore a previous jannet software version state
info: query information about installed software
checklog: update the installation log file if necessary
rpmnew: remove superfluous rpmnew files and show conflicts
for others
EOT
if [ "$1" ]; then
exit $1
fi
}
get_opts()
{
set -- `getopt $opts $*`
while [ "$1" != -- ] ; do
case "$1" in
-v)
opt_verbose=true
;;
*)
eusage
;;
esac
shift
done
shift
}
create_ldconfig_state()
{
echo "=== automatically created by $myname update script"
echo "--- files"
ls /etc/ld.so.conf.d
echo "--- directories"
find /etc/ld.so.conf.d -type f | xargs cat | sort -u
}
check_ldconfig()
{
local state=/var/log/ytools-ldconf.state
[ -f $state ] && create_ldconfig_state | diff $state - >/dev/null 2>&1 && return
echo -n "running ldconfig ... "
/sbin/ldconfig
create_ldconfig_state > $state
echo "done."
}
list_all_packages()
{
rpm -qa --queryformat '%{NAME}: %{VENDOR}\n' | \
grep -i '^[^ ]\+:.*\(jannet\|c-mexx\)' | \
sed 's/\(^[^ ]\+\) *:.*/\1/' |\
sort -u
}
cmd_rpmnew()
{
local file
list_all_packages |
xargs rpm -ql |
while read file; do
if [ -e "$file.rpmnew" ]; then
if diff -q $file $file.rpmnew; then
if [ -L "$file" ]; then
echo ========== skipping link $file
diff $file.rpmnew $file
continue
fi
echo mv $file.rpmnew $file
sudo mv $file.rpmnew $file
else
echo =========== $file
diff $file.rpmnew $file
fi
fi
done
}
cmd_diff()
{
local file
list_all_packages |
xargs rpm -qV |
sed '/^....L\|^..5/ !d; s%[^/]*/%/%' |
while read file; do
if diff -q $file $file.rpmnew; then
if [ -L "$file" ]; then
echo ========== skipping link $file
diff $file.rpmnew $file
continue
fi
echo mv $file.rpmnew $file
sudo mv $file.rpmnew $file
else
echo =========== $file
diff $file.rpmnew $file
fi
done
}
cmd="$1"
shift
get_opts $*
case $cmd in
init)
if ! channel_present ftp.jannet.de; then
echo -n "adding installation source ... "
sudo smart channel -y --add ftp.jannet.de \
type=yast2 \
baseurl=ftp://dspadm:dspasswd@ftp.jannet.de/pub/packages/linux/suse/10.1/inst-source \
>/dev/null 2>&1
if channel_present; then echo done; else echo failed; fi
fi
;;
uninit)
if channel_present ftp.jannet.de; then
echo -n "removing installation source ... "
sudo smart channel -y --remove ftp.jannet.de >/dev/null 2>&1
echo done
fi
;;
update)
sudo smart update ftp.jannet.de
sudo smart upgrade -y
check_ldconfig
;;
install)
sudo smart update ftp.jannet.de
if [ -f $1 ]; then
sudo smart install -y `cat $1`
else
sudo smart install -y $*
fi
check_ldconfig
;;
restore)
echo "not yet implemented, sorry" >&2
;;
checklog)
line=`jannet info | tr -s " "`
echo $line
;;
info)
if [ "$opt_verbose" = true ]; then
list_all_packages | xargs rpm -qi
else
list_all_packages | xargs rpm -q
fi
;;
cpp-glib)
sudo rpm -U --replacefiles --replacepkgs --oldpackage \
ftp://dspadm@ftp.jannet.de/pub/packages/linux/suse/10.1/inst-source/rpm/i586/glib2-2.8.5-19.i586.rpm
check_ldconfig
;;
rpmnew)
cmd_rpmnew $@
;;
diff)
cmd_diff $@
;;
help)
usage 0
;;
*)
usage 1
;;
esac