3 # author: hackbard@hackdaworld.dyndns.org
6 # this is hdw-get script, used to install/remove/(update) binary packages
11 echo "usage: $0 [install/remove] [directory] [package]"
14 package="" ; inst_root=""
20 inst_root="$2" ; package="$3" ; shift 3 ;;
22 inst_root="$2" ; package="$3" ; shift 3 ;;
23 -v) verbose=1 ; shift 1 ;;
28 if [ -z "inst_root" -o -z "$package" ] ; then
32 # read hdw-get configs
33 net_addr="" ; bin_dir=""
34 if [ -f /etc/hdw-get.conf ] ; then
36 if [ -z "$hdw_version" -o -z "$hdw_arch" -o -z "$hdw_arch_opt" ] ; then
37 echo "version, arch and arch_opt need to be specified."
38 echo "adjust /etc/hdw-get.conf file"
41 echo "hdw-get.conf file looks good ..."
44 echo "/etc/hdw-get.conf file not found, aborting"
49 if [ "$remove" = "1" ] ; then
50 # looking for flist file
52 for fl_file in $inst_root/var/adm/flists/$package-*; do
53 fl_pris="`echo $fl_file | awk -F- '{ print $NF }'` $fl_pris"
56 for pri in $fl_pris; do
57 if [ "$pri" = "x" ] ; then
61 [ "$pri" -gt "$fl_max" ] && fl_max=$pri
63 fl_file="$inst_root/var/adm/flists/$package-$fl_max"
64 [ "$verbose" ] && echo "expecting flist file $fl_file"
65 if [ ! -f $fl_file ] ; then
66 echo "package $apckage is not installed (moved the flist file?)"
71 cat $fl_file | while read pkg file; do
73 if [ -e $inst_root/$file ] ; then
74 if [ "$file" != "tmp" ] ; then
75 if [ -d $inst_root/$file ] ; then
76 rmdir -p $inst_root/$file > /dev/null 2>&1
78 rm -f $inst_root/$file > /dev/null 2>&1
79 rmdir -p `dirname $file` > /dev/null 2>&1
84 echo -en "\rremoved $counter from $supposed supposed files"
89 elif [ "$install" = "1" ] ; then
90 # does inst_root exist
91 if [ ! -d $inst_root ] ; then
93 echo "the install directory doesnt exist, create it first"
97 # does the package exist
98 if [ -f $package ] ; then
99 echo "extracting `basename $package` to $inst_root ..."
100 tar --use-compress-program=bzip2 -xf $package \
103 elif [ ! -z "$bin_dir" -a -f $bin_dir/$package/$package.tar.bz2 ] ; then
104 echo "extracting $package to $inst_root ..."
105 tar --use-compress-program=bzip2 \
106 -xf $bin_dir/$package/$package.tar.bz2 -C $inst_root
107 elif [ ! -z "$net_addr" ] ; then
108 #echo "trying to get package $package via net ..."
109 wget $net_addr/hdw-linux/hdw-linux-$hdw_version/binaries/${hdw_arch}-${hdw_arch_opt}/$package/${package}.tar.bz2 &&
110 tar --use-compress-program=bzip2 \
111 -xf ${package}.tar.bz2 -C $inst_root
112 rm ${package}.tar.bz2
115 echo "sorry, package $package not found"