Re: [suse-autoinstall] applying patches
Hello, I have written a script to generate a new common.pkd after an upgrade of the rpms in the installation directory. I hope someone find it usefull. On my server the script takes a long time: # time gen_common_pkd real 8m32.052s user 6m50.890s sys 3m5.250s (Perhaps someone find a solution to make the script faster.) I include the script in the mail body to avoid an attachment. script begin: ----- snip/snap --------------------------------------- #!/bin/bash --noprofile # # gen_common_pkd - makes common.pkd # generiert das Descriptionfile suse/setup/descr/common.pkd # das ist notwendig, wenn ein Paket durch ein neueres ersetzt # wurde: # # cd /net/lin_suse8.0/suse/yast1 # # mv yast2-module-autoinst-2.5.22-0.noarch.rpm # .yast2-module-autoinst-2.5.22-0.noarch.rpm # # cp /tmp/yast2-module-autoinst-2.5.27-0.noarch.rpm . # # cd /net/lin_suse8.0/suse # # /net/lin_internal/bin/gen_common_pkd # # CS - 29.08.2002 # Anmerkung: # Originalskript von Anas Nashif: # http://www.suse.de/~nashif/makeCommon.sh NAME=`basename $0` BASE=/net/lin_suse8.0/suse ORIGINAL_COMMON_PKD=/net/lin_suse8.0/suse/setup/descr/common.pkd.orig GEN_COMMON_PKD=/net/lin_suse8.0/suse/setup/descr/common.pkd TMP_COMMON_PKD=/net/lin_suse8.0/suse/setup/descr/common.pkd.tmp function gen_entries () { file_name=$(basename $1) pkg_name=$(rpm -qp --queryformat '%-8{NAME}' $1) series=$(dirname $1 | tr -d [:digit:]) dir=$(dirname $1) instpath="01 /$dir/" dusize=$(du -b $1 | cut -f1) rpmsize=$(rpm -qp --queryformat '%-8{SIZE}' $1) buildtime=$(rpm -qp --queryformat '%-8{BUILDTIME}' $1) search_string="RpmName:.*[ \t]$pkg_name.Series:.*InstPath:.*\/$dir\/.*" flag_line=`cat $ORIGINAL_COMMON_PKD | awk 'BEGIN { RS="##----- "; }'" /$search_string/ {print }" | grep 'Flag:'` anz_flag_lines=`echo "$flag_line" | wc -l | sed 's/ //g'` if [ "$anz_flag_lines" != "1" ]; then echo "error anz_flag_lines=$anz_flag_lines" echo "file_name=$$file_name" echo "pkg_name=$pkg_name" echo "dir=$dir" fi unset search_string anz_flag_lines builtfrom=$(rpm -qp --queryformat '%-8{SOURCERPM}' $1) rpmgroup=$(rpm -qp --queryformat '%-8{GROUP}' $1) copyright=$(rpm -qp --queryformat '%-8{COPYRIGHT}' $1) author=$(rpm -qp --queryformat '%-8{PACKAGER}' $1) version=$(rpm -qp --queryformat '%-8{VERSION}' $1) release=$(rpm -qp --queryformat '%-8{RELEASE}' $1) requires=$(rpm -qp --requires $1 | tr '\n' ' ' | sed -e 's/ */ /g' -e 's/ *$//') provides=$(rpm -qp --provides $1 | tr '\n' ' ' | sed -e 's/ */ /g' -e 's/ *$//') ( echo "##----- $pkg_name -----" printf "Filename:\t$file_name\n" printf "RpmName:\t$pkg_name\n" printf "Series:\t\t$series\n" printf "InstPath:\t$instpath\n" printf "Size:\t\t$rpmsize $dusize\n" printf "Buildtime:\t$buildtime\n" printf "BuiltFrom:\t$builtfrom\n" # don't know how to retrieve this value, eventually get it from original # common.pkd if [ "$flag_line" != "" ]; then echo "$flag_line" # from original suse common.pkd else printf "Flag:\t\tELF\n" # for new package fi printf "RpmGroup:\t$rpmgroup\n" printf "Copyright:\t$copyright\n" # available in internal SuSE DB, take packager instead.. # eventually take it from original common.pkd printf "AuthorName:\t$author\n" printf "Version:\t$version-$release\n" if [ -n "$requires" ]; then printf "Requires:\t$requires\n" fi if [ -n "$provides" ]; then printf "Provides:\t$provides\n" fi ) >> $TMP_COMMON_PKD } # +------+ # | main | # +------+ cd $BASE echo "$NAME: running in `pwd`..." rm -f $TMP_COMMON_PKD # Header erzeugen DATE=`date '+%d.%m.%Y'` TIME=`date '+%H:%M'` ( echo "###------------------------------------------------------------" echo "###" echo "### SuSE - Sprachunabhängiger Teil der Paketbeschreibungen" echo "###" echo "### Generiert von: $NAME ($DATE $TIME)" echo "###" echo "PkdVersion: 1.1" echo "Encoding: ISO-8859-1" echo "###------------------------------------------------------------" ) > $TMP_COMMON_PKD echo "$NAME: getting package list..." declare -a package_list package_list=( $( \ for ser in $(ls -1) do if [ -d "$ser" ]; then for pkg in $(find $ser -name "*.rpm" | grep -v 'src.rpm$') do echo $pkg done fi done ) ) no_of_pkgs=${#package_list[*]} echo "$NAME: generating common.pkd for $no_of_pkgs packages..." let i=0 for pkg in `echo ${package_list[*]} | sort`; do ((reminder=i++%100)) # alle 100 Pakete einen Status schreiben [ $reminder = 0 ] && echo " package $i/$no_of_pkgs" gen_entries $pkg done echo "$NAME: todo" echo " cd /net/lin_suse8.0/suse/setup/descr" echo " diff common.pkd common.pkd.tmp" echo " cp common.pkd common.pkd.$DATE" echo " cp common.pkd.tmp common.pkd" exit 0 script end: ----- snip/snap --------------------------------------- Regards CS -- Christian Stoltze Computer Science, University of Constance (Lake Constance/SW-Germany) Email: Christian.Stoltze@uni-konstanz.de Voice: +49 (0)7531 88-4448 Fax: +49 (0)7531 88-3577
participants (1)
-
Christian Stoltze