author | wimpie <wimpie> | 2004-04-02 16:49:47 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-02 16:49:47 (UTC) |
commit | 9e26c10c0dc97a0956d019166caf712955094764 (patch) (unidiff) | |
tree | 9bf4f33bd02185780070e178d25e24bdff4d6cd2 | |
parent | 2f2d702e37cc391dd547eaa7e2432d86285e546d (diff) | |
download | opie-9e26c10c0dc97a0956d019166caf712955094764.zip opie-9e26c10c0dc97a0956d019166caf712955094764.tar.gz opie-9e26c10c0dc97a0956d019166caf712955094764.tar.bz2 |
ipkg-build mkipkg : speedup (avoid grepping over controlfile by loading into array)
SpeciapMTFiles tothreaded : convert control files to -mt.control
-rw-r--r-- | scripts/SpecialMTFiles | 14 | ||||
-rwxr-xr-x | scripts/ipkg-build | 63 | ||||
-rwxr-xr-x | scripts/mkipkg | 22 | ||||
-rwxr-xr-x | scripts/tothreaded | 132 |
4 files changed, 209 insertions, 22 deletions
diff --git a/scripts/SpecialMTFiles b/scripts/SpecialMTFiles new file mode 100644 index 0000000..456550c --- a/dev/null +++ b/scripts/SpecialMTFiles | |||
@@ -0,0 +1,14 @@ | |||
1 | ConvertSpecialFiles() { | ||
2 | local f | ||
3 | for f in "$*" | ||
4 | do | ||
5 | case "$f" in | ||
6 | *libqte*) | ||
7 | echo ${f//qte/qte-mt} | ||
8 | ;; | ||
9 | *) | ||
10 | echo $f | ||
11 | ;; | ||
12 | esac | ||
13 | done | ||
14 | } | ||
diff --git a/scripts/ipkg-build b/scripts/ipkg-build index c6af056..b661bbf 100755 --- a/scripts/ipkg-build +++ b/scripts/ipkg-build | |||
@@ -1,201 +1,242 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
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 |
6 | set -e | 6 | set -e |
7 | 7 | ||
8 | ipkg_extract_value() { | 8 | #declare array for values and fields found in control file |
9 | sed -e "s/^[^:]*:[[:space:]]*//" | 9 | declare -a AllValues AllFields |
10 | |||
11 | collect_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 | ||
12 | required_field() { | 23 | required_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 | |||
24 | pkg_appears_sane() { | 59 | pkg_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 | ||
30 | PKG_ERROR=0 | 65 | PKG_ERROR=0 |
31 | 66 | ||
32 | tilde_files=`find . -name '*~'` | 67 | tilde_files=`find . -name '*~'` |
33 | if [ -n "$tilde_files" ]; then | 68 | if [ -n "$tilde_files" ]; then |
34 | echo "*** Warning: The following files have names ending in '~'. | 69 | echo "*** Warning: The following files have names ending in '~'. |
35 | You probably want to remove them: " >&2 | 70 | You probably want to remove them: " >&2 |
36 | ls -ld $tilde_files | 71 | ls -ld $tilde_files |
37 | echo >&2 | 72 | echo >&2 |
38 | fi | 73 | fi |
39 | 74 | ||
40 | large_uid_files=`find . -uid +99` | 75 | large_uid_files=`find . -uid +99` |
41 | 76 | ||
42 | if [ "$ogargs" = "" ] && [ -n "$large_uid_files" ]; then | 77 | if [ "$ogargs" = "" ] && [ -n "$large_uid_files" ]; then |
43 | echo "*** Warning: The following files have a UID greater than 99. | 78 | echo "*** Warning: The following files have a UID greater than 99. |
44 | You probably want to chown these to a system user: " >&2 | 79 | You probably want to chown these to a system user: " >&2 |
45 | ls -ld $large_uid_files | 80 | ls -ld $large_uid_files |
46 | echo >&2 | 81 | echo >&2 |
47 | fi | 82 | fi |
48 | 83 | ||
49 | 84 | ||
50 | if [ ! -f "$CONTROL/control" ]; then | 85 | if [ ! -f "$CONTROL/control" ]; then |
51 | echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2 | 86 | echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2 |
52 | cd $owd | 87 | cd $owd |
53 | return 1 | 88 | return 1 |
54 | fi | 89 | fi |
55 | 90 | ||
56 | pkg=`required_field Package` | 91 | pkg=`required_field Package` |
57 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 92 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
58 | 93 | ||
59 | version=`required_field Version | sed 's/Version://; s/^.://g;'` | 94 | version=`required_field Version | sed 's/Version://; s/^.://g;'` |
60 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 95 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
61 | 96 | ||
62 | arch=`required_field Architecture` | 97 | arch=`required_field Architecture` |
63 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 98 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
64 | 99 | ||
65 | required_field Maintainer >/dev/null | 100 | required_field Maintainer >/dev/null |
66 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 101 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
67 | 102 | ||
68 | required_field Description >/dev/null | 103 | required_field Description >/dev/null |
69 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 104 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
70 | 105 | ||
71 | section=`required_field Section` | 106 | section=`required_field Section` |
72 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 107 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
73 | if [ -z "$section" ]; then | 108 | if [ -z "$section" ]; then |
74 | echo "The Section field should have one of the following values:" >&2 | 109 | echo "The Section field should have one of the following values:" >&2 |
75 | echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2 | 110 | echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2 |
76 | fi | 111 | fi |
77 | 112 | ||
78 | priority=`required_field Priority` | 113 | priority=`required_field Priority` |
79 | [ "$?" -ne 0 ] && PKG_ERROR=1 | 114 | [ "$?" -ne 0 ] && PKG_ERROR=1 |
80 | if [ -z "$priority" ]; then | 115 | if [ -z "$priority" ]; then |
81 | echo "The Priority field should have one of the following values:" >&2 | 116 | echo "The Priority field should have one of the following values:" >&2 |
82 | echo "required, important, standard, optional, extra." >&2 | 117 | echo "required, important, standard, optional, extra." >&2 |
83 | echo "If you don't know which priority value you should be using, then use \`optional'" >&2 | 118 | echo "If you don't know which priority value you should be using, then use \`optional'" >&2 |
84 | fi | 119 | fi |
85 | 120 | ||
86 | if echo $pkg | grep '[^a-z0-9.+-]'; then | 121 | if echo $pkg | grep '[^a-z0-9.+-]'; then |
87 | echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2 | 122 | echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2 |
88 | PKG_ERROR=1; | 123 | PKG_ERROR=1; |
89 | fi | 124 | fi |
90 | 125 | ||
91 | local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'` | 126 | local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'` |
92 | if [ -n "$bad_fields" ]; then | 127 | if [ -n "$bad_fields" ]; then |
93 | bad_fields=`echo $bad_fields` | 128 | bad_fields=`echo $bad_fields` |
94 | echo "*** Error: The following fields in $CONTROL/control are missing a ':'" >&2 | 129 | echo "*** Error: The following fields in $CONTROL/control are missing a ':'" >&2 |
95 | echo "$bad_fields" >&2 | 130 | echo "$bad_fields" >&2 |
96 | echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2 | 131 | echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2 |
97 | PKG_ERROR=1 | 132 | PKG_ERROR=1 |
98 | fi | 133 | fi |
99 | 134 | ||
100 | for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do | 135 | for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do |
101 | if [ -f $script -a ! -x $script ]; then | 136 | if [ -f $script -a ! -x $script ]; then |
102 | echo "*** Error: package script $script is not executable" >&2 | 137 | echo "*** Error: package script $script is not executable" >&2 |
103 | PKG_ERROR=1 | 138 | PKG_ERROR=1 |
104 | fi | 139 | fi |
105 | done | 140 | done |
106 | 141 | ||
107 | if [ -f $CONTROL/conffiles ]; then | 142 | if [ -f $CONTROL/conffiles ]; then |
108 | for cf in `cat $CONTROL/conffiles`; do | 143 | for cf in `cat $CONTROL/conffiles`; do |
109 | if [ ! -f ./$cf ]; then | 144 | if [ ! -f ./$cf ]; then |
110 | echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" >&2 | 145 | echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" >&2 |
111 | PKG_ERROR=1 | 146 | PKG_ERROR=1 |
112 | fi | 147 | fi |
113 | done | 148 | done |
114 | fi | 149 | fi |
115 | 150 | ||
116 | cd $owd | 151 | cd $owd |
117 | return $PKG_ERROR | 152 | return $PKG_ERROR |
118 | } | 153 | } |
119 | 154 | ||
120 | ### | 155 | ### |
121 | # ipkg-build "main" | 156 | # ipkg-build "main" |
122 | ### | 157 | ### |
123 | ogargs="" | 158 | ogargs="" |
124 | outer=ar | 159 | outer=ar |
125 | usage="Usage: $0 [-c] [-o owner] [-g group] <pkg_directory> [<destination_directory>]" | 160 | usage="Usage: $0 [-c] [-o owner] [-g group] <pkg_directory> [<destination_directory>]" |
126 | while getopts "cg:o:" opt; do | 161 | while getopts "cg:o:" opt; do |
127 | case $opt in | 162 | case $opt in |
128 | o ) owner=$OPTARG | 163 | o ) owner=$OPTARG |
129 | ogargs="--owner=$owner" | 164 | ogargs="--owner=$owner" |
130 | ;; | 165 | ;; |
131 | g ) group=$OPTARG | 166 | g ) group=$OPTARG |
132 | ogargs="$ogargs --group=$group" | 167 | ogargs="$ogargs --group=$group" |
133 | ;; | 168 | ;; |
134 | c ) outer=tar | 169 | c ) outer=tar |
135 | ;; | 170 | ;; |
136 | \? ) echo $usage >&2 | 171 | \? ) echo $usage >&2 |
137 | esac | 172 | esac |
138 | done | 173 | done |
139 | 174 | ||
175 | # maks sure that tar produces headers compatible with busybox format | ||
176 | # debian needs this | ||
177 | ogargs="$ogargs --format=oldgnu" | ||
140 | 178 | ||
141 | shift $(($OPTIND - 1)) | 179 | shift $(($OPTIND - 1)) |
142 | 180 | ||
143 | # continue on to process additional arguments | 181 | # continue on to process additional arguments |
144 | 182 | ||
145 | case $# in | 183 | case $# in |
146 | 1) | 184 | 1) |
147 | dest_dir=. | 185 | dest_dir=. |
148 | ;; | 186 | ;; |
149 | 2) | 187 | 2) |
150 | dest_dir=$2 | 188 | dest_dir=$2 |
151 | ;; | 189 | ;; |
152 | *) | 190 | *) |
153 | echo echo $usage >&2 | 191 | echo echo $usage >&2 |
154 | exit 1 | 192 | exit 1 |
155 | ;; | 193 | ;; |
156 | esac | 194 | esac |
157 | 195 | ||
158 | pkg_dir=$1 | 196 | pkg_dir=$1 |
159 | 197 | ||
160 | if [ ! -d $pkg_dir ]; then | 198 | if [ ! -d $pkg_dir ]; then |
161 | echo "*** Error: Directory $pkg_dir does not exist" >&2 | 199 | echo "*** Error: Directory $pkg_dir does not exist" >&2 |
162 | exit 1 | 200 | exit 1 |
163 | fi | 201 | fi |
164 | 202 | ||
165 | # CONTROL is second so that it takes precedence | 203 | # CONTROL is second so that it takes precedence |
166 | CONTROL= | 204 | CONTROL= |
167 | [ -d $pkg_dir/DEBIAN ] && CONTROL=DEBIAN | 205 | [ -d $pkg_dir/DEBIAN ] && CONTROL=DEBIAN |
168 | [ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL | 206 | [ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL |
169 | if [ -z "$CONTROL" ]; then | 207 | if [ -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 |
172 | fi | 210 | fi |
173 | 211 | ||
212 | # load values | ||
213 | collect_values | ||
214 | |||
174 | if ! pkg_appears_sane $pkg_dir; then | 215 | if ! 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 |
178 | fi | 219 | fi |
179 | 220 | ||
180 | tmp_dir=$dest_dir/IPKG_BUILD.$$ | 221 | tmp_dir=$dest_dir/IPKG_BUILD.$$ |
181 | mkdir $tmp_dir | 222 | mkdir $tmp_dir |
182 | 223 | ||
183 | tar $ogargs -C $pkg_dir -czf $tmp_dir/data.tar.gz . --exclude=$CONTROL | 224 | tar $ogargs -C $pkg_dir -czf $tmp_dir/data.tar.gz . --exclude=$CONTROL |
184 | tar $ogargs -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz . | 225 | tar $ogargs -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz . |
185 | 226 | ||
186 | echo "2.0" > $tmp_dir/debian-binary | 227 | echo "2.0" > $tmp_dir/debian-binary |
187 | 228 | ||
188 | pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk | 229 | pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk |
189 | here_dir=$PWD | 230 | here_dir=$PWD |
190 | ## tar -C $tmp_dir -czf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz | 231 | ## tar -C $tmp_dir -czf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz |
191 | rm -f $pkg_file | 232 | rm -f $pkg_file |
192 | if [ "$outer" = "ar" ] ; then | 233 | if [ "$outer" = "ar" ] ; then |
193 | cd $tmp_dir ; ar crf $here_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz | 234 | cd $tmp_dir ; ar crf $here_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz |
194 | else | 235 | else |
195 | cd $tmp_dir ; tar -zcf $here_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz | 236 | cd $tmp_dir ; tar -zcf $here_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz |
196 | fi | 237 | fi |
197 | cd $here_dir | 238 | cd $here_dir |
198 | rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz | 239 | rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz |
199 | rmdir $tmp_dir | 240 | rmdir $tmp_dir |
200 | 241 | ||
201 | echo "Packaged contents of $pkg_dir into $pkg_file" | 242 | echo "Packaged contents of $pkg_dir into $pkg_file" |
diff --git a/scripts/mkipkg b/scripts/mkipkg index 43bd3a3..a336371 100755 --- a/scripts/mkipkg +++ b/scripts/mkipkg | |||
@@ -118,173 +118,173 @@ fi | |||
118 | if [ -z "$postinst" ]; then | 118 | if [ -z "$postinst" ]; then |
119 | postinst=$destdir/CONTROL/postinst | 119 | postinst=$destdir/CONTROL/postinst |
120 | fi | 120 | fi |
121 | 121 | ||
122 | # remove leading slash from prefix (to fix globbing) | 122 | # remove leading slash from prefix (to fix globbing) |
123 | if [ -n "$prefix" ]; then | 123 | if [ -n "$prefix" ]; then |
124 | prefix=`echo $prefix | sed -e "s,/\(.*\),\\1,"` | 124 | prefix=`echo $prefix | sed -e "s,/\(.*\),\\1,"` |
125 | fi | 125 | fi |
126 | 126 | ||
127 | if [ -z "$destdir" ]; then | 127 | if [ -z "$destdir" ]; then |
128 | usage | 128 | usage |
129 | fi | 129 | fi |
130 | 130 | ||
131 | if [ ! -r $control ]; then | 131 | if [ ! -r $control ]; then |
132 | echo "$self: cannot find $control, exiting..." | 132 | echo "$self: cannot find $control, exiting..." |
133 | exit 1 | 133 | exit 1 |
134 | fi | 134 | fi |
135 | 135 | ||
136 | if [ -z "`which $ipkgbuild 2>/dev/null`" ]; then | 136 | if [ -z "`which $ipkgbuild 2>/dev/null`" ]; then |
137 | echo "$self: cannot find ipkg-build, exiting..." | 137 | echo "$self: cannot find ipkg-build, exiting..." |
138 | exit 1 | 138 | exit 1 |
139 | fi | 139 | fi |
140 | 140 | ||
141 | findFile() | 141 | findFile() |
142 | { | 142 | { |
143 | local path= | 143 | local path= |
144 | if [ $# = 1 ]; then | 144 | if [ $# = 1 ]; then |
145 | find $1 -type f -o -type b -o -type c -o -type l | 145 | find $1 -type f -o -type b -o -type c -o -type l |
146 | find $1 -type d -a -empty | 146 | find $1 -type d -a -empty |
147 | else | 147 | else |
148 | find . -type f -o -type b -o -type c -o -type l | \ | 148 | find . -type f -o -type b -o -type c -o -type l | \ |
149 | sed -e "s,\./\(.*\),\\1,g" | 149 | sed -e "s,\./\(.*\),\\1,g" |
150 | find . -type d -a -empty | 150 | find . -type d -a -empty |
151 | fi | 151 | fi |
152 | } | 152 | } |
153 | 153 | ||
154 | _pushd() { oldpwd=`pwd`; cd $1; } | 154 | _pushd() { oldpwd=`pwd`; cd $1; } |
155 | _popd() { cd $oldpwd; } | 155 | _popd() { cd $oldpwd; } |
156 | 156 | ||
157 | setVar() | 157 | setVar() |
158 | { | 158 | { |
159 | eval "$1='$2'" | 159 | eval "$1='$2'" |
160 | } | 160 | } |
161 | 161 | ||
162 | expandMaskToList() | 162 | expandMaskToList() |
163 | { | 163 | { |
164 | local _list=`echo $1` | 164 | local _list=`echo $1` |
165 | local _tmpFileList= | 165 | local _tmpFileList= |
166 | for f in $_list; do | 166 | for f in $_list; do |
167 | if [ -d $f ]; then | 167 | if [ -d $f ]; then |
168 | f="`findFile $f`" | 168 | f="`findFile $f`" |
169 | fi | 169 | fi |
170 | _tmpFileList="`eval echo $f` $_tmpFileList" | 170 | _tmpFileList="`eval echo $f` $_tmpFileList" |
171 | done | 171 | done |
172 | setVar $2 "$_tmpFileList" | 172 | setVar $2 "$_tmpFileList" |
173 | } | 173 | } |
174 | 174 | ||
175 | createFileList() | 175 | createFileList() |
176 | { | 176 | { |
177 | local excludeMask | 177 | local excludeMask |
178 | local includeMask | 178 | local includeMask |
179 | local includemaskpresent=0 | 179 | local includemaskpresent=0 |
180 | local excludemaskpresent=0 | 180 | local excludemaskpresent=0 |
181 | 181 | ||
182 | if (cat $1|grep -q ^FileExcludeMask); then | 182 | if (grep -q ^FileExcludeMask $1); then |
183 | excludemaskpresent=1 | 183 | excludemaskpresent=1 |
184 | excludeMask=$(eval echo '"'$(sed -n -e "s,^FileExcludeMask: *,,p" $1)'"') | 184 | excludeMask=$(eval echo '"'$(sed -n -e "s,^FileExcludeMask: *,,p" $1)'"') |
185 | fi | 185 | fi |
186 | if (cat $1|grep -q ^FileIncludeMask); then | 186 | if (grep -q ^FileIncludeMask $1); then |
187 | includemaskpresent=1 | 187 | includemaskpresent=1 |
188 | includeMask=$(eval echo '"'$(sed -n -e "s,^FileIncludeMask: *,,p" $1)'"') | 188 | includeMask=$(eval echo '"'$(sed -n -e "s,^FileIncludeMask: *,,p" $1)'"') |
189 | else | 189 | else |
190 | if (cat $1|grep -q ^Files:); then | 190 | if (grep -q ^Files: $1); then |
191 | includemaskpresent=1 | 191 | includemaskpresent=1 |
192 | includeMask=$(eval echo '"'$(sed -n -e "s,^Files: *,,p" $1)'"') | 192 | includeMask=$(eval echo '"'$(sed -n -e "s,^Files: *,,p" $1)'"') |
193 | fi | 193 | fi |
194 | fi | 194 | fi |
195 | 195 | ||
196 | _pushd $destdir | 196 | _pushd $destdir |
197 | 197 | ||
198 | excludeMask="$excludeMask CONTROL/* usr/share/*" | 198 | declare -a excludeMaskArray |
199 | excludeMaskArray=( $excludeMask ) | ||
200 | excludeMaskArray=( "${excludeMaskArray[@]}" "CONTROL/*" "usr/share/*" ) | ||
199 | 201 | ||
200 | if [ $includemaskpresent != 1 ]; then | 202 | if [ $includemaskpresent != 1 ]; then |
201 | includeMask="." | 203 | includeMask="." |
202 | fi | 204 | fi |
203 | 205 | ||
204 | if [ -z "$includeMask" ]; then | 206 | if [ -z "$includeMask" ]; then |
205 | setVar $2 "" | 207 | setVar $2 "" |
206 | _popd | 208 | _popd |
207 | return 0 | 209 | return 0 |
208 | fi | 210 | fi |
209 | 211 | ||
210 | expandMaskToList "$includeMask" _fileList | 212 | expandMaskToList "$includeMask" _fileList |
211 | 213 | ||
212 | _excludeList= | 214 | excludeMaskArray=( "${excludeMaskArray[@]}" "*/CVS*" "*/SCCS*" ) |
213 | if [ -n "$excludeMask" ]; then | ||
214 | expandMaskToList "$excludeMask" _excludeList | ||
215 | _excludeList="$_excludeList `find -name \*CVS\* -o -name \*SCCS\*`" | ||
216 | fi | ||
217 | 215 | ||
218 | local realFileList= | 216 | local realFileList= |
219 | local missing=0 | 217 | local missing=0 |
220 | for file in $_fileList; do | 218 | for file in $_fileList; do |
221 | local containedInList=0 | 219 | local containedInList=0 |
222 | for i in $_excludeList; do | 220 | for i in "${excludeMaskArray[@]}"; do |
223 | if [ $file = $i ]; then | 221 | if [[ $file == $i ]]; then |
224 | containedInList=1 | 222 | containedInList=1 |
223 | break; | ||
225 | fi | 224 | fi |
226 | done | 225 | done |
226 | |||
227 | if [ $containedInList = 0 ]; then | 227 | if [ $containedInList = 0 ]; then |
228 | if ! [ -e $file -o -L $file ]; then | 228 | if ! [ -e $file -o -L $file ]; then |
229 | echo "$self: $file not found" | 229 | echo "$self: $file not found" |
230 | missing=1 | 230 | missing=1 |
231 | fi | 231 | fi |
232 | realFileList=$file" $realFileList" | 232 | realFileList=$file" $realFileList" |
233 | fi | 233 | fi |
234 | done | 234 | done |
235 | 235 | ||
236 | _popd | 236 | _popd |
237 | 237 | ||
238 | if [ $missing = 1 ]; then | 238 | if [ $missing = 1 ]; then |
239 | return 1 | 239 | return 1 |
240 | fi | 240 | fi |
241 | 241 | ||
242 | setVar $2 "$realFileList" | 242 | setVar $2 "$realFileList" |
243 | } | 243 | } |
244 | 244 | ||
245 | stripFile() | 245 | stripFile() |
246 | { | 246 | { |
247 | if [ -f $1 -a -x $1 ]; then | 247 | if [ -f $1 -a -x $1 ]; then |
248 | $strip --strip-all $1 | 248 | $strip --strip-all $1 |
249 | fi | 249 | fi |
250 | } | 250 | } |
251 | 251 | ||
252 | substFile() | 252 | substFile() |
253 | { | 253 | { |
254 | local oldfile=$1 | 254 | local oldfile=$1 |
255 | 255 | ||
256 | if [ ! -e $2 ]; then return 1; fi | 256 | if [ ! -e $2 ]; then return 1; fi |
257 | 257 | ||
258 | if [ -e $oldfile -o -L $oldfile ]; then | 258 | if [ -e $oldfile -o -L $oldfile ]; then |
259 | newfile=`echo $oldfile|sed -f $2|sed -e's,^/,,g'` | 259 | newfile=`echo $oldfile|sed -f $2|sed -e's,^/,,g'` |
260 | olddir=`dirname $oldfile` | 260 | olddir=`dirname $oldfile` |
261 | base=`basename $oldfile` | 261 | base=`basename $oldfile` |
262 | newdir=`dirname $newfile` | 262 | newdir=`dirname $newfile` |
263 | 263 | ||
264 | # echo >&2 moving $oldfile to $newfile | 264 | # echo >&2 moving $oldfile to $newfile |
265 | 265 | ||
266 | if [ "$newdir" = "$olddir" ]; then | 266 | if [ "$newdir" = "$olddir" ]; then |
267 | return 0 | 267 | return 0 |
268 | fi | 268 | fi |
269 | 269 | ||
270 | mkdir -p $newdir | 270 | mkdir -p $newdir |
271 | mv $olddir/$base $newfile | 271 | mv $olddir/$base $newfile |
272 | rmdir -p $olddir 2>/dev/null | 272 | rmdir -p $olddir 2>/dev/null |
273 | fi | 273 | fi |
274 | } | 274 | } |
275 | 275 | ||
276 | stripFiles() | 276 | stripFiles() |
277 | { | 277 | { |
278 | for f in $1; do | 278 | for f in $1; do |
279 | stripFile ./$f | 279 | stripFile ./$f |
280 | done | 280 | done |
281 | } | 281 | } |
282 | 282 | ||
283 | substFiles() | 283 | substFiles() |
284 | { | 284 | { |
285 | for f in $1; do | 285 | for f in $1; do |
286 | substFile ./$f | 286 | substFile ./$f |
287 | done | 287 | done |
288 | } | 288 | } |
289 | 289 | ||
290 | substAndStripFiles() | 290 | substAndStripFiles() |
diff --git a/scripts/tothreaded b/scripts/tothreaded new file mode 100755 index 0000000..d9f8488 --- a/dev/null +++ b/scripts/tothreaded | |||
@@ -0,0 +1,132 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # PURPOSE : | ||
4 | # | ||
5 | # this script converts a non-threaded control file to a threaded one | ||
6 | # by extending appropriate names with -mt as extension | ||
7 | # | ||
8 | # eg abc.control becoms abc-mt.control | ||
9 | # | ||
10 | |||
11 | # | ||
12 | # make sure that the depends expression has enough spaces | ||
13 | # expression can contian : , ( ) || && | ||
14 | # | ||
15 | tokenize() { | ||
16 | sed "s/,/ & /g" | sed "s/)/ & /g" | sed "s/(/ & /g" | sed "s/|/ & /g" | sed "s/&/ & /g" | ||
17 | } | ||
18 | |||
19 | # | ||
20 | # function converts package name to threaded equivalend IF the | ||
21 | # package file HAS a threaded version | ||
22 | # | ||
23 | findthreadedequiv() { | ||
24 | local isin i | ||
25 | for i in $* | ||
26 | do | ||
27 | isin=`grep "^$i\$" "$ALLTHREADEDPKGSFILE"` | ||
28 | if [ -z "$isin" ] | ||
29 | then | ||
30 | # no threaded package | ||
31 | echo -n "$i " | ||
32 | else | ||
33 | # threaded package | ||
34 | echo -n "${isin}-mt " | ||
35 | fi | ||
36 | done | ||
37 | echo | ||
38 | } | ||
39 | |||
40 | # | ||
41 | # signature of binary files | ||
42 | # currently obsolete | ||
43 | # | ||
44 | # ISBINARY="*ELF*LSB*" | ||
45 | |||
46 | usage() { | ||
47 | echo "Usage : tothreaded <controlfile> <ALLPackages file>" | ||
48 | exit 2 | ||
49 | } | ||
50 | |||
51 | . scripts/SpecialMTFiles | ||
52 | |||
53 | # | ||
54 | # get the name of the controlfile to check for threading | ||
55 | # | ||
56 | if [ -z "$1" ] | ||
57 | then | ||
58 | usage | ||
59 | fi | ||
60 | controlfile=$1 | ||
61 | shift | ||
62 | |||
63 | case $controlfile in | ||
64 | *-mt.control) | ||
65 | #already threaded | ||
66 | echo $controlfile | ||
67 | exit 0; | ||
68 | ;; | ||
69 | esac | ||
70 | |||
71 | # | ||
72 | # file containing list of all known threaded packages | ||
73 | # | ||
74 | if [ -z "$1" ] | ||
75 | then | ||
76 | usage | ||
77 | fi | ||
78 | ALLTHREADEDPKGSFILE=$1 | ||
79 | shift | ||
80 | |||
81 | # | ||
82 | # strip out the name of the package | ||
83 | # | ||
84 | packagename=${controlfile##*/} # path | ||
85 | packagename=${packagename%.control} # extension | ||
86 | |||
87 | # | ||
88 | # generate new control file | ||
89 | # | ||
90 | newcontrolfile=${controlfile/\.control/-mt\.control} | ||
91 | |||
92 | # | ||
93 | # read all lines in original control file | ||
94 | # | ||
95 | while read line | ||
96 | do | ||
97 | case $line in | ||
98 | # convert some files to threaded equivalent | ||
99 | "Files:"*) | ||
100 | files=${line#Files:} | ||
101 | # thread-converted files | ||
102 | T_files=`ConvertSpecialFiles "$files"` | ||
103 | echo "Files: $T_files" | ||
104 | ;; | ||
105 | "Package: "*) | ||
106 | T_package=`findthreadedequiv ${line#Package: }` | ||
107 | echo "Package: ${T_package}" | ||
108 | ;; | ||
109 | "Depends: "*) | ||
110 | depends=`echo "${line#Depends: }" | tokenize` | ||
111 | T_depends=`findthreadedequiv ${depends}` | ||
112 | echo "Depends: $T_depends" | ||
113 | ;; | ||
114 | "Provides: "*) | ||
115 | T_provides=`findthreadedequiv ${line#Provides: }` | ||
116 | echo "Provides: $T_provides" | ||
117 | ;; | ||
118 | "Conflicts: "*) | ||
119 | conflicts=`echo "${line#Conflicts: }" | tokenize` | ||
120 | T_conflicts=`findthreadedequiv ${conflicts}` | ||
121 | echo "Conflicts: $T_conflicts" | ||
122 | ;; | ||
123 | *":"*) | ||
124 | echo "$line" | ||
125 | ;; | ||
126 | *) # al other lines | ||
127 | echo " $line" | ||
128 | ;; | ||
129 | esac | ||
130 | done < $controlfile > $newcontrolfile | ||
131 | |||
132 | echo $newcontrolfile | ||