summaryrefslogtreecommitdiff
path: root/scripts/ipkg-build
Unidiff
Diffstat (limited to 'scripts/ipkg-build') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/ipkg-build63
1 files changed, 52 insertions, 11 deletions
diff --git a/scripts/ipkg-build b/scripts/ipkg-build
index c6af056..b661bbf 100755
--- a/scripts/ipkg-build
+++ b/scripts/ipkg-build
@@ -2,28 +2,63 @@
2 2
3# ipkg-build -- construct a .ipk from a directory 3# ipkg-build -- construct a .ipk from a directory
4# Carl Worth <cworth@east.isi.edu> 4# Carl Worth <cworth@east.isi.edu>
5# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001 5# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001
6set -e 6set -e
7 7
8ipkg_extract_value() { 8#declare array for values and fields found in control file
9 sed -e "s/^[^:]*:[[:space:]]*//" 9declare -a AllValues AllFields
10
11collect_values() {
12 local i line
13
14 i=0
15 while read line
16 do
17 AllFields[$i]=${line%%:*}
18 AllValues[$i]=`echo ${line#*:}` # echo to remove spaces
19 let i=i+1
20 done < ${pkg_dir}/${CONTROL}/control
10} 21}
11 22
12required_field() { 23required_field() {
13 field=$1 24 local field i
14 25 field=$1
15 value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value` 26
16 if [ -z "$value" ]; then 27 i=0
17 echo "*** Error: $CONTROL/control is missing field $field" >&2 28 for af in "${AllFields[@]}"
18 return 1 29 do
19 fi 30 if [ "$field" = "$af" ]
20 echo $value 31 then
21 return 0 32 # return value
33 echo "${AllValues[$i]}"
34 return 0;
35 fi
36 let i=i+1
37 done
38 # not found
39 echo "*** Error: $CONTROL/control is missing field $field" >&2
40 return 1
22} 41}
23 42
43#ipkg_extract_value() {
44 #sed -e "s/^[^:]*:[[:space:]]*//"
45#}
46#
47#required_field() {
48 #field=$1
49#
50 #value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value`
51 #if [ -z "$value" ]; then
52 # echo "*** Error: $CONTROL/control is missing field $field" >&2
53 # return 1
54 #fi
55 #echo $value
56 #return 0
57#}
58
24pkg_appears_sane() { 59pkg_appears_sane() {
25 local pkg_dir=$1 60 local pkg_dir=$1
26 61
27 local owd=`pwd` 62 local owd=`pwd`
28 cd $pkg_dir 63 cd $pkg_dir
29 64
@@ -134,12 +169,15 @@ while getopts "cg:o:" opt; do
134 c ) outer=tar 169 c ) outer=tar
135 ;; 170 ;;
136 \? ) echo $usage >&2 171 \? ) echo $usage >&2
137 esac 172 esac
138done 173done
139 174
175# maks sure that tar produces headers compatible with busybox format
176# debian needs this
177ogargs="$ogargs --format=oldgnu"
140 178
141shift $(($OPTIND - 1)) 179shift $(($OPTIND - 1))
142 180
143# continue on to process additional arguments 181# continue on to process additional arguments
144 182
145case $# in 183case $# in
@@ -168,12 +206,15 @@ CONTROL=
168[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL 206[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL
169if [ -z "$CONTROL" ]; then 207if [ -z "$CONTROL" ]; then
170 echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2 208 echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2
171 exit 1 209 exit 1
172fi 210fi
173 211
212# load values
213collect_values
214
174if ! pkg_appears_sane $pkg_dir; then 215if ! pkg_appears_sane $pkg_dir; then
175 echo >&2 216 echo >&2
176 echo "ipkg-build: Please fix the above errors and try again." >&2 217 echo "ipkg-build: Please fix the above errors and try again." >&2
177 exit 1 218 exit 1
178fi 219fi
179 220