-rwxr-xr-x | scripts/mkipkg | 94 |
1 files changed, 53 insertions, 41 deletions
diff --git a/scripts/mkipkg b/scripts/mkipkg index 54651af..7877078 100755 --- a/scripts/mkipkg +++ b/scripts/mkipkg | |||
@@ -142,12 +142,13 @@ 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 -o -type d | 145 | find $1 -type f -o -type b -o -type c -o -type l |
146 | find $1 -type d -a -empty | ||
146 | else | 147 | else |
147 | find . -type f -o -type b -o -type c -o -type l -o -type d | \ | 148 | find . -type f -o -type b -o -type c -o -type l | \ |
148 | sed -e "s,\./\(.*\),\\1,g" | 149 | sed -e "s,\./\(.*\),\\1,g" |
150 | find . -type d -a -empty | ||
149 | fi | 151 | fi |
150 | |||
151 | } | 152 | } |
152 | 153 | ||
153 | _pushd() { oldpwd=`pwd`; cd $1; } | 154 | _pushd() { oldpwd=`pwd`; cd $1; } |
@@ -164,13 +165,9 @@ expandMaskToList() | |||
164 | local _tmpFileList= | 165 | local _tmpFileList= |
165 | for f in $_list; do | 166 | for f in $_list; do |
166 | if [ -d $f ]; then | 167 | if [ -d $f ]; then |
167 | find="`findFile $f`" | 168 | f="`findFile $f`" |
168 | if [ -z "$find" ]; then | ||
169 | find="$f" | ||
170 | fi | ||
171 | f="$f `findFile $f`" | ||
172 | fi | 169 | fi |
173 | _tmpFileList=$f" $_tmpFileList" | 170 | _tmpFileList="`eval echo $f` $_tmpFileList" |
174 | done | 171 | done |
175 | setVar $2 "$_tmpFileList" | 172 | setVar $2 "$_tmpFileList" |
176 | } | 173 | } |
@@ -179,6 +176,9 @@ createFileList() | |||
179 | { | 176 | { |
180 | local excludeMask | 177 | local excludeMask |
181 | local includeMask | 178 | local includeMask |
179 | local includemaskpresent=0 | ||
180 | local excludemaskpresent=0 | ||
181 | |||
182 | if (cat $1|grep -q ^FileExcludeMask); then | 182 | if (cat $1|grep -q ^FileExcludeMask); 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)'"') |
@@ -193,25 +193,26 @@ createFileList() | |||
193 | fi | 193 | fi |
194 | fi | 194 | fi |
195 | 195 | ||
196 | excludeMask="$excludeMask CONTROL/* usr/share/* CVS/* SCCS/*" | 196 | _pushd $destdir |
197 | |||
198 | excludeMask="$excludeMask CONTROL/* usr/share/*" | ||
199 | |||
200 | if [ $includemaskpresent != 1 ]; then | ||
201 | includeMask="." | ||
202 | fi | ||
197 | 203 | ||
198 | if [ $includemaskpresent == 1 ]; then | ||
199 | if [ -z "$includeMask" ]; then | 204 | if [ -z "$includeMask" ]; then |
200 | setVar $2 "" | 205 | setVar $2 "" |
206 | _popd | ||
201 | return 0 | 207 | return 0 |
202 | fi | 208 | fi |
203 | _pushd $destdir | 209 | |
204 | expandMaskToList "$includeMask" _fileList | 210 | expandMaskToList "$includeMask" _fileList |
205 | _popd | ||
206 | else | ||
207 | _fileList=`cd $destdir && findFile` | ||
208 | fi | ||
209 | 211 | ||
210 | _excludeList= | 212 | _excludeList= |
211 | if [ -n "$excludeMask" ]; then | 213 | if [ -n "$excludeMask" ]; then |
212 | _pushd $destdir | ||
213 | expandMaskToList "$excludeMask" _excludeList | 214 | expandMaskToList "$excludeMask" _excludeList |
214 | _popd | 215 | _excludeList="$_excludeList `find -name \*CVS\* -o -name \*SCCS\*`" |
215 | fi | 216 | fi |
216 | 217 | ||
217 | local realFileList= | 218 | local realFileList= |
@@ -224,14 +225,16 @@ createFileList() | |||
224 | fi | 225 | fi |
225 | done | 226 | done |
226 | if [ $containedInList = 0 ]; then | 227 | if [ $containedInList = 0 ]; then |
227 | if [ ! -e $file ]; then | 228 | if ! [ -e $file -o -L $file ]; then |
228 | # echo "$self: $file not found" | 229 | echo "$self: $file not found" |
229 | missing=1 | 230 | missing=1 |
230 | fi | 231 | fi |
231 | realFileList=$file" $realFileList" | 232 | realFileList=$file" $realFileList" |
232 | fi | 233 | fi |
233 | done | 234 | done |
234 | 235 | ||
236 | _popd | ||
237 | |||
235 | if [ $missing = 1 ]; then | 238 | if [ $missing = 1 ]; then |
236 | return 1 | 239 | return 1 |
237 | fi | 240 | fi |
@@ -252,17 +255,20 @@ substFile() | |||
252 | 255 | ||
253 | if [ ! -e $2 ]; then return 1; fi | 256 | if [ ! -e $2 ]; then return 1; fi |
254 | 257 | ||
255 | if [ -e $oldfile ]; then | 258 | if [ -e $oldfile -o -L $oldfile ]; then |
256 | newfile=./`echo $1|sed -f $2|sed -e's,^/,,g'` | 259 | newfile=`echo $oldfile|sed -f $2|sed -e's,^/,,g'` |
257 | olddir=./`dirname $1` | 260 | olddir=`dirname $oldfile` |
261 | base=`basename $oldfile` | ||
258 | newdir=`dirname $newfile` | 262 | newdir=`dirname $newfile` |
259 | 263 | ||
264 | # echo >&2 moving $oldfile to $newfile | ||
265 | |||
260 | if [ "$newdir" = "$olddir" ]; then | 266 | if [ "$newdir" = "$olddir" ]; then |
261 | return 0 | 267 | return 0 |
262 | fi | 268 | fi |
263 | 269 | ||
264 | mkdir -p $newdir | 270 | mkdir -p $newdir |
265 | mv $1 $newfile | 271 | mv $olddir/$base $newfile |
266 | rmdir -p $olddir 2>/dev/null | 272 | rmdir -p $olddir 2>/dev/null |
267 | fi | 273 | fi |
268 | } | 274 | } |
@@ -270,22 +276,22 @@ substFile() | |||
270 | stripFiles() | 276 | stripFiles() |
271 | { | 277 | { |
272 | for f in $1; do | 278 | for f in $1; do |
273 | stripFile $f | 279 | stripFile ./$f |
274 | done | 280 | done |
275 | } | 281 | } |
276 | 282 | ||
277 | substFiles() | 283 | substFiles() |
278 | { | 284 | { |
279 | for f in $1; do | 285 | for f in $1; do |
280 | substFile $f | 286 | substFile ./$f |
281 | done | 287 | done |
282 | } | 288 | } |
283 | 289 | ||
284 | substAndStripFiles() | 290 | substAndStripFiles() |
285 | { | 291 | { |
286 | for f in $1; do | 292 | for f in $1; do |
287 | stripFile $f | 293 | stripFile ./$f |
288 | substFile $f $2 | 294 | substFile ./$f $2 |
289 | done | 295 | done |
290 | } | 296 | } |
291 | 297 | ||
@@ -293,6 +299,8 @@ installScript() | |||
293 | { | 299 | { |
294 | if [ -n "$1" -a -f "$1" ]; then | 300 | if [ -n "$1" -a -f "$1" ]; then |
295 | destfile=`basename $1` | 301 | destfile=`basename $1` |
302 | filetype=`echo $destfile|cut -d. -f2` | ||
303 | if [ -n "$filetype" ]; then destfile=$filetype; fi | ||
296 | if [ -n "$subst" ]; then | 304 | if [ -n "$subst" ]; then |
297 | sed -f $subst < $1 > $ctrldir/$destfile | 305 | sed -f $subst < $1 > $ctrldir/$destfile |
298 | else | 306 | else |
@@ -309,14 +317,28 @@ if [ $? != 0 ]; then | |||
309 | exit 1 | 317 | exit 1 |
310 | fi | 318 | fi |
311 | 319 | ||
312 | cd $destdir; createFileList $control ipkgFileList | 320 | ctrldir=$tempDir/CONTROL |
321 | |||
322 | mkdir -p $ctrldir | ||
323 | |||
324 | if [ ! -e $subst ] || [ -z "$subst" ]; then | ||
325 | cat $control > $ctrldir/control.new | ||
326 | else | ||
327 | sed -f $subst < $control > $ctrldir/control.new | ||
328 | fi | ||
329 | |||
330 | createFileList $ctrldir/control.new ipkgFileList | ||
331 | |||
313 | if [ "$?" != "0" ]; then | 332 | if [ "$?" != "0" ]; then |
314 | echo "$self: ERROR: missing files, not building $control" | 333 | echo "$self: ERROR: missing files, not building $control" |
315 | exit 1 | 334 | exit 1 |
316 | fi | 335 | fi |
317 | 336 | ||
318 | ( cd $destdir && tar cf - $ipkgFileList 2>/dev/null ) | \ | 337 | |
319 | ( cd $tempDir && tar xf - 2>/dev/null ) | 338 | cat $ctrldir/control.new | egrep -v '^(Files|FileExcludeMask|FileIncludeMask):' > $ctrldir/control |
339 | rm -f $ctrldir/control.new | ||
340 | |||
341 | ( cd $destdir && tar -cf - $ipkgFileList 2>/dev/null ) | ( cd $tempDir && tar -xf - 2>/dev/null ) | ||
320 | 342 | ||
321 | if [ -z "$filesubst" ]; then | 343 | if [ -z "$filesubst" ]; then |
322 | ( cd $tempDir && stripFiles "$ipkgFileList" ) | 344 | ( cd $tempDir && stripFiles "$ipkgFileList" ) |
@@ -347,16 +369,6 @@ else | |||
347 | buildsize=`$mkfsjffs2 -r $tempDir | wc -c` | 369 | buildsize=`$mkfsjffs2 -r $tempDir | wc -c` |
348 | fi | 370 | fi |
349 | 371 | ||
350 | ctrldir=$tempDir/CONTROL | ||
351 | |||
352 | mkdir -p $ctrldir | ||
353 | |||
354 | if [ ! -e $subst ] || [ -z "$subst" ]; then | ||
355 | cat $control | egrep -v '^(FileIncludeMask|FileExcludeMask|Files):' > $ctrldir/control | ||
356 | else | ||
357 | sed -f $subst < $control | egrep -v '^(FileIncludeMask|FileExcludeMask|Files):' > $ctrldir/control | ||
358 | fi | ||
359 | |||
360 | if [ "$buildsize" != "0" ]; then | 372 | if [ "$buildsize" != "0" ]; then |
361 | echo "Installed-Size: $buildsize" >> $ctrldir/control | 373 | echo "Installed-Size: $buildsize" >> $ctrldir/control |
362 | fi | 374 | fi |