X-Git-Url: https://hackdaworld.org/gitweb/?p=hdw-linux%2Fhdw-linux.git;a=blobdiff_plain;f=misc%2Fhdw-tools%2Fhdw-get;h=10be612b2887ae695b430b4eafb4948305e5f3c1;hp=5cb2e40b0b08b6c269bbaf6d369bca28e52083a8;hb=279a8b0643080f522eb4b0eb515229f21159ea2f;hpb=2b6dfb448cf086bb899f505626c9e114e4971bd2 diff --git a/misc/hdw-tools/hdw-get b/misc/hdw-tools/hdw-get index 5cb2e40..10be612 100644 --- a/misc/hdw-tools/hdw-get +++ b/misc/hdw-tools/hdw-get @@ -12,10 +12,17 @@ usage() { echo "$0 [install/remove] [root] [package]" echo "$0 [dist-install] [root] [dist file]" 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 } + package="" ; inst_root="" d_install="" ; install="" -verbose="" +verbose="" ; no_dep="" +auto_resolve_deps="" while [ "$1" ] ; do case "$1" in @@ -23,9 +30,11 @@ while [ "$1" ] ; do inst_root="$2" ; package="$3" ; shift 3 ;; remove) remove="1" inst_root="$2" ; package="$3" ; shift 3 ;; - dist-install) d_install="1" + dist-install) d_install="1" ; package="fake" inst_root="$2" ; dist_file="$3" ; shift 3 ;; -v) verbose=1 ; shift 1 ;; + -a) auto_resolve_deps="1" ; shift 1 ;; + -no-dep) no_dep="1" ; shift 1 ;; *) usage ; exit 1 ;; esac done @@ -43,7 +52,7 @@ if [ -f /etc/hdw-get.conf ] ; then echo "adjust /etc/hdw-get.conf file" exit else - echo "hdw-get.conf file looks good ..." + [ "$verbose" ] && echo "hdw-get.conf file looks good ..." fi else echo "/etc/hdw-get.conf file not found, aborting" @@ -57,7 +66,7 @@ mkdir -p /tmp/.hdw-get if [ "$remove" = "1" ] ; then # looking for flist file fl_pris="" - for fl_file in $inst_root/var/adm/flists/$package-[0-9]*; do + for fl_file in $inst_root/var/adm/flists/$package-[x,0-9]*; do fl_pris="`echo $fl_file | awk -F- '{ print $NF }'` $fl_pris" done fl_max="0" @@ -84,7 +93,9 @@ if [ "$remove" = "1" ] ; then 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 > /tmp/.hdw-get/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 @@ -126,6 +137,16 @@ elif [ "$install" = "1" ] ; then exit 1 fi + # does package exist? + pkg=`basename $package | sed 's/.tar.bz2//'` + if [ -f $inst_root/var/adm/flists/${pkg}-[0-9]* ] ; then + echo "$pkg seems to be installed, candidates:" + for i in $inst_root/var/adm/flists/${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 @@ -144,12 +165,14 @@ elif [ "$install" = "1" ] ; then tar --use-compress-program=bzip2 \ -xf $bin_dir/$package/$package.tar.bz2 -C $inst_root elif [ ! -z "$net_addr" ] ; then - #echo "trying to get package $package via net ..." + echo "getting package $package via net ..." wget $net_addr/hdw-linux/hdw-linux-$hdw_version/binaries/${hdw_arch}-${hdw_arch_opt}/$package/${package}.tar.bz2 > /dev/null 2>&1 - if [ "$?" ] ; 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 \ -xf ${package}.tar.bz2 -C $inst_root rm ${package}.tar.bz2 @@ -157,13 +180,15 @@ elif [ "$install" = "1" ] ; then fi else echo "sorry, package $package not found" + exit 1 fi # merging info/dir file - fl_file=`ls -A $inst_root/var/adm/flists/$package-[0-9]* | tail -1` + 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 "$package info - added by hdw `date`" >> /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//'` @@ -177,11 +202,34 @@ elif [ "$install" = "1" ] ; then fi done fi - cp /tmp/.hdw-get/dir $inst_root/usr/share/info/dir + 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 [ "$dist_install" = "1" ] ; then +elif [ "$d_install" = "1" ] ; then # check dist file if [ ! -f $dist_file ] ; then echo "$dist_file not found, aborting"