]> www.hackdaworld.org Git - hdw-linux/hdw-linux.git/blob - scripts/Create-Binary
-> cvs
[hdw-linux/hdw-linux.git] / scripts / Create-Binary
1 #/bin/sh
2 #
3 # hdw - linux ./scripts/Create-Binary
4 #
5 # this script is used to create the binary packages
6 #
7
8 package=""
9 tar_name=""
10 my_root=""
11
12 while [ "$1" ] ; do
13         case "$1" in
14                 all)            package=all     ; shift 1 ;;
15                 -package)       package=$2      ; shift 2 ;;
16                 -tar-name)      tar_name=$2     ; shift 2 ;;
17                 -root)          my_root=$2      ; shift 2 ;;
18                 *)      
19         echo "usage: $0 -package <package> -tar-name <tarname> -root <root>"
20         exit 1 ;;
21         esac
22 done
23
24 # do we run?
25 if [ -z "$package" ] ; then
26         echo "no package specified"
27         exit 1
28 fi
29
30 # how to call the packaged tar file (no .tar.bz2 ending!)
31 [ -z "$tar_name" ] && tar_name="$package"
32
33 # get Config & set hdw_home_dir
34 . ./Config && hdw_home_dir=`pwd`
35
36 # which root to use?
37 [ ! -z "$my_root" ] && hdw_build_dir="$my_root" 
38
39 # create binary directory
40 if [ ! -z "$hdw_arch_opt" ]; then
41         bin_dir=${hdw_arch}-${hdw_arch_opt}
42 else
43         bin_dir=${hdw_arch}-generic
44 fi
45 pkg_dir=`echo $package | sed 's%-[0-9].%%'`
46 pkg_dir=`echo $pkg_dir | sed 's%-[0-9]%%'`
47 pkg_dir=`echo $pkg_dir | sed s"%\(.*\)\.\(.*\)%\1%"`
48 mkdir -p binaries/$bin_dir
49
50 # single package
51 if [  "$package" != "all" ] ; then
52 if [ -d ./binaries/$bin_dir/${pkg_dir} ] ; then
53         echo "$package binary already exists, skipped"
54         echo "(remove ./binaries/$bin_dir/${pkg_dir} to recreate it)"
55         exit 0
56 else
57         # does it exist?
58         if [ ! -f $hdw_build_dir/var/adm/flists/$package ] ; then
59                 echo "package not build (moved flist file?)"
60                 exit 0
61         else
62                 echo "creating binary tarball of $package"
63                 mkdir -p $hdw_home_dir/binaries/$bin_dir/${pkg_dir} &&
64                 cd $hdw_build_dir &&
65                 # which files do we need?
66                 fl_file="var/adm/flists/$package"
67                 cat $fl_file | awk '{ print $2 }' | \
68                 tar --no-recursion --use-compress-program=bzip2 \
69                 -cf $hdw_home_dir/binaries/$bin_dir/${pkg_dir}/$tar_name.tar.bz2 \
70                 -T -
71                 cp $hdw_build_dir/var/adm/flists/$package \
72                         $hdw_home_dir/binaries/$bin_dir/${pkg_dir}
73                 cd $hdw_home_dir
74                 echo "done"
75         fi
76 fi
77
78 elif [ "$package" = "all" ] ; then
79
80 ((counter=0))
81 for pkg in `ls -A $hdw_build_dir/var/adm/flists | grep -v '.stage'`; do
82         tar_name=`echo $pkg | awk -F- '{ print $1 }'`
83         ./scripts/Create-Binary -package $pkg -root $hdw_build_dir \
84                                 -tar_name $tar_name
85         ((counter+=1))
86 done
87
88 # add 00-dirtree, build in stage1
89 ./scripts/Create-Binary -package 00-dirtree.stage0-0 -tar-name 00-dirtree
90 ((counter+=1))
91
92 echo "created $counter binaries, done"
93 fi