#!/bin/bash # # netsrpm-install.sh - Build srpms that download sources from network # # Copyright (C) 2003-2008 by Silvan Calarco # Copyright (C) 2005 by Massimo Pintore # Copyright (C) 2005-2007 by Davide Madrisan me="${0##*/}" if [ -z "$1" -o -z "$2" ]; then echo "Usage:" echo "$me " exit 1 fi pckname="$1" pckarch="$2" function check_if_already_installed() { rpm -q $1 &>/dev/null if [ $? -eq 0 ]; then kdialog \ --caption "$pckname" \ --msgbox "$pckname: "$"already installed." else kdialog \ --caption "$pckname" \ --sorry $"There was an error installing $pckname!" fi } tmpfile=`mktemp -q -t $me.XXXXXXXX` || { echo "$me: "$"error: "$"cannot create temporary files." >&2 { (exit 1); exit 1; }; } tmpdir=`mktemp -d -q -t $me.XXXXXXXX` || { echo "$me: "$"error: "$"cannot create temporary files." >&2 { (exit 1); exit 1; }; } DISTRO_SRPMS_DIR=@distrosrpmsdir@ rpmdir=$(rpm --eval=%{_rpmdir} 2>/dev/null) [ "$rpmdir" ] || { echo "$m3: "$"error: "$"cannot set \`rpmdir'."" "$"Aborting..." >&2 { (exit 1); exit 1; }; } SYSTEM_RPMS_DIR=$rpmdir/$pckarch SRPM_NAME=`\ find $DISTRO_SRPMS_DIR \ -regex ".*/${pckname//+/\\+}-[^-]*-[^-]*" -printf "%f " 2>/dev/null` SRPM_VERSION=`\ echo $SRPM_NAME | \ sed "s|${pckname//+/\\+}-\([^-]*-[^-]*\).src.rpm|\1|" 2>/dev/null` if [ -z "$SRPM_NAME" -o -z "$SRPM_VERSION" ]; then echo "$me: "$"cannot set \`SRPM_PATH' and/or \`SRPM_VERSION'."" "$"Aborting..." >&2 exit 1 fi SRPM_PATH=${DISTRO_SRPMS_DIR}/${SRPM_NAME} RPM_PATH=${SYSTEM_RPMS_DIR}/${pckname}-${SRPM_VERSION}.${pckarch}.rpm if [ ! -f $SRPM_PATH ]; then echo "$me: "$"missing SRPM \`$SRPM_PATH'."" "$"Aborting..." >&2 exit 1 fi # get license agreement ( rpm2cpio $SRPM_PATH > $tmpfile && cd $tmpdir && cpio --quiet --extract --make-directories < $tmpfile ) 2>/dev/null if [ -f $tmpdir/LICENSE ]; then kdialog \ --caption "LICENSE" \ --textbox $tmpdir/LICENSE 600 400 [ $? -ne 0 ] && exit 1 fi kdialog \ --title "$pckname" \ --passivepopup \ $"$1 installation in progress..." # build rpm echo "$me: "$"rebuilding package \`$SRPM_PATH'..." rpmbuild --rebuild $SRPM_PATH if [ $? -gt 0 ]; then echo "$me: "$"error rebuilding \`$SRPM_PATH'."" "$"Aborting..." >&2 check_if_already_installed $1 exit 1 fi # install rpm sudo rpm -hUv --force $RPM_PATH if [ $? -gt 0 ]; then echo "$me: "$"error installing \`$SRPM_PATH'."" "$"Aborting..." >&2 check_if_already_installed $1 exit 1 fi # erase rpm rm -f $RPM_PATH rpm -q $1 2>/dev/null if [ $? -eq 0 ]; then kdialog \ --title "$pckname" \ --passivepopup \ $"Installation of $1 successfully completed." else kdialog \ --caption "$pckname" \ --sorry $"There was an error installing $1!" fi