3 # author: hackbard@hackdaworld.dyndns.org
5 # this script defines functions used by the other scripts
9 echo -e "\e[01;31m${1}\e[0m" # Red
13 echo -e "\e[01;32m${1}\e[0m" # Green
17 echo -e "\e[01;33m${1}\e[0m" # Yellow
21 echo -e "\e[01;36m${1}\e[0m" # Cyan
25 echo -e "\e[01;37m${1}\e[0m" # White
29 echo -en "\e[01;36m${1}\e[0m"
42 abort_when_package_build_failed() {
45 if [ "$return" != "0" -a "$hdw_abort" = "1" ]; then
46 echo "failed building package $package!"
47 echo "failed executing $last"
56 echo "creating init ..."
58 run="`basename $1 | awk -F. '{ print $1 }'`"
59 bin=$package ; params="" ; depends="" ; exec=""
60 path=$prefix/sbin ; sec_append="exit 0"
61 sync_respawn="" ; use_pfh=0
66 ((s2_value = 100 - s_value))
67 if [ ! -d $root/etc/minit ] ; then
69 echo "assuming sysvinit as init system!"
70 cat > $root/etc/init.d/$run << EOF
73 # hdw - linux $root/etc/init.d/$run
76 # remove this for automatic startup
79 [ ! -f $path/$bin ] && exit 0
83 echo "starting $run ..."
86 echo "stopping $run ..."
87 killall -15 $path/$bin ;;
89 echo "restarting $run ..."
90 killall -1 $path/$bin ;;
92 echo "usage: \$0 [start|stop|restart]"
97 # permissions and links
98 chmod 750 $root/etc/init.d/$run
99 ln -sf ../$run $root/etc/init.d/rc2.d/S${s_value}${run}
100 ln -sf ../$run $root/etc/init.d/rc2.d/K${s2_value}${run}
102 echo "assuming minit as init system!"
103 mkdir -p $root/etc/minit/$run
104 if [ "$use_pfh" = "1" ] ; then
105 ln -sf $root/sbin/pidfilehack $root/etc/minit/$run/run
106 elif [ ! -z "$exec" ] ; then
107 rm -f $root/etc/minit/$run/run
108 echo "exec $exec" > $root/etc/minit/$run/run
110 ln -sf $path/$bin $root/etc/minit/$run/run
112 [ ! -z "$sync_respawn" ] && \
113 touch $root/etc/minit/$run/$snc_respawn
114 if [ ! -z "$params" ]; then
115 rm -f $root/etc/minit/$run/params
117 echo "$i" >> $root/etc/minit/$run/params
120 if [ ! -z "$depends" ]; then
121 rm -f $root/etc/minit/$run/depends
122 for i in $depends; do
123 echo "$i" >> $root/etc/minit/$run/depends
129 detect_file_ending() {
131 if [ "`echo $file | awk -F'tar\\\.' '{ print $2 }'`" = "bz2" ] ; then
133 elif [ ! -z "`echo $file | grep '.tbz2'`" ] ; then
136 if [ "`echo $file | awk -F'tar\\\.' '{ print $2 }'`" = "gz" ] ; then
138 elif [ ! -z "`echo $file | grep '.tgz'`" ] ; then
140 elif [ ! -z "`echo $file | grep 'tar.Z'`" ] ; then
145 create_setup_scripts() {
146 destfile="`echo $1 | awk -F/ '{ print $NF }' | sed 's/\.setup//'`.sh"
147 cat > $root/etc/setup.d/$destfile << EOF
150 # hdw - linux $root/etc/setup.d/$destfile
154 if [ -z "`grep setup_block $1`" ] ; then
155 cat >> $root/etc/setup.d/$destfile << EOF
157 echo "setup not supported"
161 if [ -z "`grep uninstall_block $1`" ] ; then
162 cat >> $root/etc/setup.d/$destfile << EOF
164 echo "uninstall not supported"
168 cat $1 >> $root/etc/setup.d/$destfile
169 cat >> $root/etc/setup.d/$destfile << EOF
171 echo "usage: \$0 [setup|uninstall]"
175 [ -z "\$1" ] && usage
179 setup) setup_block ; shift ;;
180 uninstall) uninstall_block ; shift ;;
185 chmod 750 $root/etc/setup.d/$destfile
197 dir="`echo $package | awk -F/ '{ print $3 }'`"
198 for match in `grep '^# \[S\]' $package | \
199 awk '{ for(i=3;i<=NF;i++) print $i }'`; do
200 if [ "$stage-$priority" = "$match" ] ; then
201 echo -en "$stage \t $priority \t\t $dir "
202 echo -e "`basename $package`"
207 create_buildorder() {
213 categories=`grep '^# \[C\]' ./targets/$hdw_target/include | \
215 categories="$categories $hdw_arch"
216 # add single packages to categories
217 singlepackages=`grep '^# \[P\]' ./targets/$hdw_target/include | \
219 [ ! -z "$singlepackages" ] && categories="$categories $singlepackages"
221 delpackages=`grep '^# \[R\]' ./targets/$hdw_target/include | \
224 if [ "$hdw_use_dietlibc" = "1" ] ; then
225 [ -z "`echo $categories | grep diet`"] && \
226 singlepackages="$singlepackages diet/dietlibc"
227 delpackages="$delpackages base/glibc"
230 echo -e "#stage \t #priority \t #category package"
231 for stage in $stages; do
233 while (( counter <= max_priority )); do
236 for dir in $categories; do
237 for package in ./packages/$dir/[!C]*; do
239 pkg=`basename $package`
240 if [ -d $package -a -f $package/$pkg ] ; then
242 [ -z "`echo $delpackages | grep $dir/$pkg`" ] && \
243 output_if_valid $package/`basename $package` \
248 [ -f ./packages/$dir/$foo ] && \
249 output_if_valid ./packages/$dir/$foo \