X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=misc%2Fhdw-tools%2Fhdw-get;h=0ee4ba78cf521dc3dec5c4d552d55487b616ee82;hb=6836aca6fe863145c4e0da63bfd8689c97d0c161;hp=0aa2a3b10b3c5dba9a396aca187c609f5554b985;hpb=7da8a19a46c67c5daadabc870268f67b45d1eec0;p=hdw-linux%2Fhdw-linux.git diff --git a/misc/hdw-tools/hdw-get b/misc/hdw-tools/hdw-get index 0aa2a3b..0ee4ba7 100644 --- a/misc/hdw-tools/hdw-get +++ b/misc/hdw-tools/hdw-get @@ -11,21 +11,34 @@ usage() { echo "usage:" echo "$0 [install/remove] [root] [package]" echo "$0 [dist-install] [root] [dist file]" + echo "$0 [update]" echo echo "options:" echo "-v tell me whats going on" echo "-a auto resolve deps, do not prompt user" echo "-no-dep do not care for dependencies (used by hdw-get itself)" + echo "-s simulation only, do not install/remove packages" + echo "-b base package, not listed in hdw-get.db" echo } package="" ; inst_root="" +update="" d_install="" ; install="" verbose="" ; no_dep="" auto_resolve_deps="" +simulate="" +base="" + +FL_DIR="var/adm/flists" +DEPS_DIR="var/adm/deps/run" +CONF="/etc/hdw-get.conf" +DBF="/etc/hdw-get.db" while [ "$1" ] ; do case "$1" in + update) update="1" ; package="fake" ; inst_root="fake" + shift 1 ;; install) install="1" inst_root="$2" ; package="$3" ; shift 3 ;; remove) remove="1" @@ -35,6 +48,8 @@ while [ "$1" ] ; do -v) verbose=1 ; shift 1 ;; -a) auto_resolve_deps="1" ; shift 1 ;; -no-dep) no_dep="1" ; shift 1 ;; + -s) simulate="1" ; shift 1 ;; + -b) base="1" ; no_dep="1" ; shift 1;; *) usage ; exit 1 ;; esac done @@ -45,28 +60,54 @@ fi # read hdw-get configs net_addr="" ; bin_dir="" ; distf_dir="" -if [ -f /etc/hdw-get.conf ] ; then - . /etc/hdw-get.conf +if [ -f $CONF ] ; then + . $CONF if [ -z "$hdw_version" -o -z "$hdw_arch" -o -z "$hdw_arch_opt" ] ; then echo "version, arch and arch_opt need to be specified." - echo "adjust /etc/hdw-get.conf file" + echo "adjust $CONF file" exit else [ "$verbose" ] && echo "hdw-get.conf file looks good ..." fi else - echo "/etc/hdw-get.conf file not found, aborting" + echo "$CONF file not found, aborting" exit 1 fi -# create temp directory -mkdir -p /tmp/.hdw-get +if [ "$update" = "1" ] ; then + echo -en "updating hdw-get.db file ..." + wget -q $net_addr/hdw-linux/hdw-linux-$hdw_version/hdw-get/hdw-get.db \ + -O $DBF + echo -en " done. (`cat $DBF | wc -l` packages)\n" +fi # remove if [ "$remove" = "1" ] ; then + # check if packages depend on package to be removed + pkgs="" + ((isdep = 0)) + for fl_file in $inst_root/$DEPS_DIR/*; do + if [ "`grep "^$package$" $fl_file`" != "" ] ; then + pkg=`echo $fl_file | sed "s%$inst_root/$DEPS_DIR/%%"` + if [ "$pkg" != "$package" ] ; then + ((isdep += 1)) + pkgs="$pkg $pkgs" + fi + fi + done + if [ "$isdep" != "0" ] ; then + echo "info:" + echo "run time dependencies were autegenerated by build system." + echo "they may be wrong. edit $inst_root/$DEPS_DIR/* files." + echo "deps:" + echo -en "$pkgs\n" + echo "package $package should not be removed ($isdep deps)" + [ "$no_dep" != "1" ] && exit 1 + fi # looking for flist file - fl_pris="" - for fl_file in $inst_root/var/adm/flists/$package-[x,0-9]*; do + fl_pris="unknown" + for fl_file in $inst_root/$FL_DIR/$package-[x,0-9]*; do + [ -f $fl_file ] && \ fl_pris="`echo $fl_file | awk -F- '{ print $NF }'` $fl_pris" done fl_max="0" @@ -75,30 +116,17 @@ if [ "$remove" = "1" ] ; then fl_max="x" break fi + [ "$pri" = "unknown" ] && break [ "$pri" -gt "$fl_max" ] && fl_max=$pri done - fl_file="$inst_root/var/adm/flists/$package-$fl_max" + fl_file="$inst_root/$FL_DIR/$package-$fl_max" [ "$verbose" ] && echo "expecting flist file $fl_file" if [ ! -f $fl_file ] ; then - echo "package $apckage is not installed (moved the flist file?)" + echo "package $package is not installed (moved the flist file?)" exit 1 fi - # care about info/dir file - rm -f /tmp/.hdw-get/dir* ; modify_info_dir="" - if [ -n "`grep usr/share/info/dir $fl_file`" ] ; then - modify_info_dir="1" - cp $inst_root/usr/share/info/dir /tmp/.hdw-get/ - for info_obj in `grep 'usr/share/info/.*.info' $fl_file | \ - awk -F/ '{ print $4 }'`; do - info_o=`echo $info_obj | sed 's/.info//'` - [ "$verbose" ] && echo "deleting $info_o from info/dir" - grep -v \($info_o\)\. /tmp/.hdw-get/dir | \ - grep -v ^$package\ info\ -\ added\ by\ hdw > \ - /tmp/.hdw-get/dir~ - mv /tmp/.hdw-get/dir~ /tmp/.hdw-get/dir - done - fi + if [ "$simulate" != "1" ] ; then # remove the files/dirs ((supposed = 0)) @@ -120,11 +148,14 @@ if [ "$remove" = "1" ] ; then done echo -en "\ndone.\n" - # reinstall info/dir file - if [ "$modify_info_dir" ] ; then - [ "$verbose" ] && echo "restoring modified info/dir file" - cp /tmp/.hdw-get/dir $inst_root/usr/share/info/dir - rm -f /tmp/.hdw-get/dir* + # care about info/dir file + echo "recreating info dir file ..." + cd $inst_root/usr/share/info + rm -f dir + for f in *; do + install-info $f dir 2>/dev/null + done + fi # install @@ -139,21 +170,65 @@ elif [ "$install" = "1" ] ; then # does package exist? pkg=`basename $package | sed 's/.tar.bz2//'` - if [ -f $inst_root/var/adm/flists/${pkg}-[0-9]* ] ; then + if [ -f $inst_root/$FL_DIR/${pkg}-[0-9]* ] ; then echo "$pkg seems to be installed, candidates:" - for i in $inst_root/var/adm/flists/${pkg}-[0-9]*; do + for i in $inst_root/$FL_DIR/${pkg}-[0-9]*; do echo "-> $i" done exit 1 fi - # store info/dir file - rm -f /tmp/.hdw-get/dir* - if [ -f $inst_root/usr/share/info/dir ] ; then - [ "$verbose" ] && echo "backing up info/dir file" - cp $inst_root/usr/share/info/dir /tmp/.hdw-get/ + # package in database? + if [ -z $base ] ; then + if [ "`grep "^$pkg\ -" $DBF`" = "" ] ; then + echo "sorry, package $package not found ..." + echo "(use 'hdw-get update' to update database)" + exit 1 + fi + fi + + # check for runtime deps + if [ -z $no_dep ] ; then + deps="`grep "^$pkg\ -" $DBF | sed 's/.* -//'`" + udeps="" + tudeps="" + for dep in $deps; do + [ ! -f $inst_root/$FL_DIR/$dep-* ] && \ + udeps="$dep $udeps" + done + while [ "$udeps" != "$tudeps" ] ; do + tudeps="$udeps" + for tdep in $tudeps; do + deps="`grep "^$tdep\ -" $DBF | sed 's/.* -//'`" + for dep in $deps; do + exists=0 + [ -f $inst_root/$FL_DIR/$dep-* ] && \ + break + for i in $udeps; do + [ "$i" = "$dep" ] && exists=1 + done + [ "$exists" = "0" ] && \ + udeps="$udeps $dep" + done + done + done + echo "$pkg depends on the following uninstalled packages:" + echo "$udeps" + echo + echo "continue? [y,n] (default 'n')" + if [ -z $auto_resolve_deps ] ; then + read answer + if [ "$answer" = "y" ] ; then + for i in $udeps; do + [ "$simulate" != "1" ] && \ + $0 -no-dep install $inst_root $i + done + fi + fi fi + if [ "$simulate" != "1" ] ; then + # check/install package if [ -f $package ] ; then echo "extracting `basename $package` to $inst_root ..." @@ -170,6 +245,7 @@ elif [ "$install" = "1" ] ; then retval=$? if [ "$retval" != "0" ] ; then echo "package not found at $net_addr, aborting ..." + exit else echo "extracting $package to $inst_root ..." tar --use-compress-program=bzip2 \ @@ -182,51 +258,16 @@ elif [ "$install" = "1" ] ; then exit 1 fi - # merging info/dir file - if [ "$pkg" != "00-dirtree" ] ; then - fl_file=`ls -A $inst_root/var/adm/flists/$pkg-[0-9]* | tail -1` - if [ -n "`grep usr/share/info/dir $fl_file`" ] ; then - echo "" >> /tmp/.hdw-get/dir - echo "$pkg info - added by hdw `date`" >> /tmp/.hdw-get/dir - for info_obj in `grep 'usr/share/info/.*.info' $fl_file | \ - awk -F/ '{ print $4 }'`; do - info_o=`echo $info_obj | sed 's/.info//'` - if [ -z "`grep \($info_o\)\. /tmp/.hdw-get/dir`" ] - then - [ "$verbose" ] && \ - echo "merging $info_o to info/dir" - grep \($info_o\)\. \ - $inst_root/usr/share/info/dir >> \ - /tmp/.hdw-get/dir - fi - done - fi + # care about info/dir file + echo "recreating info dir file ..." + cd $inst_root/usr/share/info + rm -f dir + for f in *; do + install-info $f dir 2>/dev/null + done + fi - [ -f /tmp/.hdw-get/dir ] && \ - cp /tmp/.hdw-get/dir $inst_root/usr/share/info/dir - rm -f /tmp/.hdw-get/dir - # check for runtime deps - #if [ -z $no_deps ] ; then - # alldeps=`get_all_deps $pkg` - # echo "$pkg depends on the following packages:" - # for i in $alldeps; do - # echo "-> $i" - # done - # echo "continue? [y,n]" - # if [ -z $auto_resolve_deps ] ; then - # read answer - # if [ "$answer" = "y" ] ; then - # for i in $alldeps; do - # $0 -no-dep install $inst_root $pkg - # done - # else - # echo -n "install dependencies on your own," - # echo " things will not work without." - # fi - # fi - #fi - # dist-install elif [ "$d_install" = "1" ] ; then # check dist file @@ -236,11 +277,10 @@ elif [ "$d_install" = "1" ] ; then # install all distribution related packages for package in `cat $dist_file`; do # execute myelf - $0 install $inst_root $package + auto="" + [ "$auto_resolve_deps" = "1" ] && auto="-a" + $0 $auto -b install $inst_root $package done fi fi -# remove temp directory -rm -rf /tmp/.hdw-get -