initial checkin of hdw-linux devel cvs repository
[hdw-linux/hdw-linux.git] / scripts / Create-Binary
diff --git a/scripts/Create-Binary b/scripts/Create-Binary
new file mode 100755 (executable)
index 0000000..14f9d45
--- /dev/null
@@ -0,0 +1,92 @@
+#/bin/sh
+#
+# hdw - linux ./scripts/Create-Binary
+#
+# this script is used to create the binary packages
+#
+
+package=""
+tar_name=""
+my_root=""
+
+while [ "$1" ] ; do
+       case "$1" in
+               all)            package=all     ; shift 1 ;;
+               -package)       package=$2      ; shift 2 ;;
+               -tar-name)      tar_name=$2     ; shift 2 ;;
+               -root)          my_root=$2      ; shift 2 ;;
+               *)      
+       echo "usage: $0 -package <package> -tar-name <tarname> -root <root>"
+       exit 1 ;;
+       esac
+done
+
+# do we run?
+if [ -z "$package" ] ; then
+       echo "no package specified"
+       exit 1
+fi
+
+# how to call the packaged tar file (no .tar.bz2 ending!)
+[ -z "$tar_name" ] && tar_name="$package"
+
+# get Config & set hdw_home_dir
+. ./Config && hdw_home_dir=`pwd`
+
+# which root to use?
+[ ! -z "$my_root" ] && hdw_build_dir="$my_root" 
+
+# create binary directory
+if [ ! -z "$hdw_arch_opt" ]; then
+       bin_dir=${hdw_arch}-${hdw_arch_opt}
+else
+       bin_dir=${hdw_arch}-generic
+fi
+mkdir -p binaries/$bin_dir
+
+# single package
+if [  "$package" != "all" ] ; then
+if [ -d ./binaries/$bin_dir/${package} ] ; then
+       echo "$package binary already exists, skipped"
+       echo "(remove ./binaries/$bin_dir/$package to recreate it)"
+       exit 0
+else
+       # does it exist?
+       if [ ! -f $hdw_build_dir/var/adm/flists/$package ] ; then
+               echo "package not build (moved flist file?)"
+               exit 0
+       else
+               echo "creating binary tarball of $package"
+               mkdir -p $hdw_home_dir/binaries/$bin_dir/$package &&
+               cd $hdw_build_dir &&
+               # which files do we need? - are we packaging linux?
+               if [ "$package" = "linux" ] ; then
+                       fl_file="var/adm/flists/$package*"
+               else
+                       fl_file="var/adm/flists/$package"
+               fi
+               cat $fl_file | awk '{ print $2 }' | \
+               tar --no-recursion --use-compress-program=bzip2 \
+               -cf $hdw_home_dir/binaries/$bin_dir/$package/$tar_name.tar.bz2 \
+               -T -
+               cp $hdw_build_dir/var/adm/flists/$package \
+                       $hdw_home_dir/binaries/$bin_dir/$package
+               cd $hdw_home_dir
+               echo "done"
+       fi
+fi
+
+elif [ "$package" = "all" ] ; then
+
+((counter=1))
+for pkg in `ls -A $hdw_build_dir/var/adm/flists | grep -v '.stage1'`; do
+       ./scripts/Create-Binary -package $pkg -root $hdw_build_dir
+       ((counter+=1))
+done
+
+# add 00-dirtree, build in stage1
+./scripts/Create-Binary -package 00-dirtree.stage1 -tar-name 00-dirtree
+((counter+=1))
+
+echo "created $counter binaries, done"
+fi