summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/mkipkg3
1 files changed, 3 insertions, 0 deletions
diff --git a/scripts/mkipkg b/scripts/mkipkg
index 9c5e184..43bd3a3 100755
--- a/scripts/mkipkg
+++ b/scripts/mkipkg
@@ -98,288 +98,291 @@ do
98 usage 98 usage
99 ;; 99 ;;
100 *) 100 *)
101 destdir=$option 101 destdir=$option
102 ;; 102 ;;
103 esac 103 esac
104done 104done
105 105
106if [ -z "$control" ]; then 106if [ -z "$control" ]; then
107 control=$destdir/CONTROL/control 107 control=$destdir/CONTROL/control
108fi 108fi
109if [ -z "$prerm" ]; then 109if [ -z "$prerm" ]; then
110 prerm=$destdir/CONTROL/prerm 110 prerm=$destdir/CONTROL/prerm
111fi 111fi
112if [ -z "$postrm" ]; then 112if [ -z "$postrm" ]; then
113 postrm=$destdir/CONTROL/postrm 113 postrm=$destdir/CONTROL/postrm
114fi 114fi
115if [ -z "$preinst" ]; then 115if [ -z "$preinst" ]; then
116 preinst=$destdir/CONTROL/preinst 116 preinst=$destdir/CONTROL/preinst
117fi 117fi
118if [ -z "$postinst" ]; then 118if [ -z "$postinst" ]; then
119 postinst=$destdir/CONTROL/postinst 119 postinst=$destdir/CONTROL/postinst
120fi 120fi
121 121
122# remove leading slash from prefix (to fix globbing) 122# remove leading slash from prefix (to fix globbing)
123if [ -n "$prefix" ]; then 123if [ -n "$prefix" ]; then
124 prefix=`echo $prefix | sed -e "s,/\(.*\),\\1,"` 124 prefix=`echo $prefix | sed -e "s,/\(.*\),\\1,"`
125fi 125fi
126 126
127if [ -z "$destdir" ]; then 127if [ -z "$destdir" ]; then
128 usage 128 usage
129fi 129fi
130 130
131if [ ! -r $control ]; then 131if [ ! -r $control ]; then
132 echo "$self: cannot find $control, exiting..." 132 echo "$self: cannot find $control, exiting..."
133 exit 1 133 exit 1
134fi 134fi
135 135
136if [ -z "`which $ipkgbuild 2>/dev/null`" ]; then 136if [ -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
139fi 139fi
140 140
141findFile() 141findFile()
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
157setVar() 157setVar()
158{ 158{
159 eval "$1='$2'" 159 eval "$1='$2'"
160} 160}
161 161
162expandMaskToList() 162expandMaskToList()
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
175createFileList() 175createFileList()
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 (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)'"')
185 fi 185 fi
186 if (cat $1|grep -q ^FileIncludeMask); then 186 if (cat $1|grep -q ^FileIncludeMask); 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 (cat $1|grep -q ^Files:); 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 excludeMask="$excludeMask CONTROL/* usr/share/*"
199 199
200 if [ $includemaskpresent != 1 ]; then 200 if [ $includemaskpresent != 1 ]; then
201 includeMask="." 201 includeMask="."
202 fi 202 fi
203 203
204 if [ -z "$includeMask" ]; then 204 if [ -z "$includeMask" ]; then
205 setVar $2 "" 205 setVar $2 ""
206 _popd 206 _popd
207 return 0 207 return 0
208 fi 208 fi
209 209
210 expandMaskToList "$includeMask" _fileList 210 expandMaskToList "$includeMask" _fileList
211 211
212 _excludeList= 212 _excludeList=
213 if [ -n "$excludeMask" ]; then 213 if [ -n "$excludeMask" ]; then
214 expandMaskToList "$excludeMask" _excludeList 214 expandMaskToList "$excludeMask" _excludeList
215 _excludeList="$_excludeList `find -name \*CVS\* -o -name \*SCCS\*`" 215 _excludeList="$_excludeList `find -name \*CVS\* -o -name \*SCCS\*`"
216 fi 216 fi
217 217
218 local realFileList= 218 local realFileList=
219 local missing=0 219 local missing=0
220 for file in $_fileList; do 220 for file in $_fileList; do
221 local containedInList=0 221 local containedInList=0
222 for i in $_excludeList; do 222 for i in $_excludeList; do
223 if [ $file = $i ]; then 223 if [ $file = $i ]; then
224 containedInList=1 224 containedInList=1
225 fi 225 fi
226 done 226 done
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
245stripFile() 245stripFile()
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
252substFile() 252substFile()
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
276stripFiles() 276stripFiles()
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
283substFiles() 283substFiles()
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
290substAndStripFiles() 290substAndStripFiles()
291{ 291{
292 for f in $1; do 292 for f in $1; do
293 stripFile ./$f 293 stripFile ./$f
294 substFile ./$f $2 294 substFile ./$f $2
295 done 295 done
296} 296}
297 297
298installScript() 298installScript()
299{ 299{
300 if [ -n "$1" -a -f "$1" ]; then 300 if [ -n "$1" -a -f "$1" ]; then
301 destfile=`basename $1` 301 destfile=`basename $1`
302 filetype=`echo $destfile|cut -d. -f2` 302 filetype=`echo $destfile|cut -d. -f2`
303 if [ -n "$filetype" ]; then destfile=$filetype; fi 303 if [ -n "$filetype" ]; then destfile=$filetype; fi
304 if [ -n "$subst" ]; then 304 if [ -n "$subst" ]; then
305 sed -f $subst < $1 > $ctrldir/$destfile 305 sed -f $subst < $1 > $ctrldir/$destfile
306 else 306 else
307 cat $1 > $ctrldir/$destfile 307 cat $1 > $ctrldir/$destfile
308 fi 308 fi
309 chmod +x $ctrldir/$destfile 309 chmod +x $ctrldir/$destfile
310 fi 310 fi
311} 311}
312 312
313tempDir=/tmp/`basename $self`.$$ 313tempDir=/tmp/`basename $self`.$$
314mkdir -p $tempDir 314mkdir -p $tempDir
315if [ $? != 0 ]; then 315if [ $? != 0 ]; then
316 echo "$self: cannot create $tempDir, exiting..." 316 echo "$self: cannot create $tempDir, exiting..."
317 rm -rf $tempDir 317 rm -rf $tempDir
318 exit 1 318 exit 1
319fi 319fi
320 320
321ctrldir=$tempDir/CONTROL 321ctrldir=$tempDir/CONTROL
322 322
323mkdir -p $ctrldir 323mkdir -p $ctrldir
324 324
325if [ ! -e $subst ] || [ -z "$subst" ]; then 325if [ ! -e $subst ] || [ -z "$subst" ]; then
326 cat $control > $ctrldir/control.new 326 cat $control > $ctrldir/control.new
327else 327else
328 sed -f $subst < $control > $ctrldir/control.new 328 sed -f $subst < $control > $ctrldir/control.new
329fi 329fi
330 330
331createFileList $ctrldir/control.new ipkgFileList 331createFileList $ctrldir/control.new ipkgFileList
332 332
333if [ "$?" != "0" ]; then 333if [ "$?" != "0" ]; then
334 echo "$self: ERROR: missing files, not building $control" 334 echo "$self: ERROR: missing files, not building $control"
335 rm -rf $tempDir 335 rm -rf $tempDir
336 exit 1 336 exit 1
337fi 337fi
338 338
339 339
340cat $ctrldir/control.new | egrep -v '^(Files|FileExcludeMask|FileIncludeMask):' > $ctrldir/control 340cat $ctrldir/control.new | egrep -v '^(Files|FileExcludeMask|FileIncludeMask):' > $ctrldir/control
341rm -f $ctrldir/control.new 341rm -f $ctrldir/control.new
342 342
343( cd $destdir && tar -cf - $ipkgFileList 2>/dev/null ) | ( cd $tempDir && tar -xf - 2>/dev/null ) 343( cd $destdir && tar -cf - $ipkgFileList 2>/dev/null ) | ( cd $tempDir && tar -xf - 2>/dev/null )
344 344
345if [ -z "$filesubst" ]; then 345if [ -z "$filesubst" ]; then
346 ( cd $tempDir && stripFiles "$ipkgFileList" ) 346 ( cd $tempDir && stripFiles "$ipkgFileList" )
347else 347else
348 if ! (echo $filesubst|grep -q '^/'); then 348 if ! (echo $filesubst|grep -q '^/'); then
349 filesubst="$oldpwd/$filesubst" 349 filesubst="$oldpwd/$filesubst"
350 fi 350 fi
351 ( cd $tempDir && substAndStripFiles "$ipkgFileList" $filesubst ) 351 ( cd $tempDir && substAndStripFiles "$ipkgFileList" $filesubst )
352fi 352fi
353 353
354# removing CVS directories
355find $tempDir -name CVS -a -type d -print0 | xargs -0 rm -rf
356
354path="`echo "$PATH" | sed -e "s/\:/ /g"`" 357path="`echo "$PATH" | sed -e "s/\:/ /g"`"
355if [ -z "$mkfsjffs2" ]; then 358if [ -z "$mkfsjffs2" ]; then
356 for i in $path; do 359 for i in $path; do
357 if [ -x "$i/mkfs.jffs2" ]; then 360 if [ -x "$i/mkfs.jffs2" ]; then
358 mkfsjffs2="$i/mkfs.jffs2" 361 mkfsjffs2="$i/mkfs.jffs2"
359 break 362 break
360 fi 363 fi
361 done 364 done
362fi 365fi
363 366
364if [ -z "$mkfsjffs2" ]; then 367if [ -z "$mkfsjffs2" ]; then
365 echo "$self: WARNING: no mkjfs.jffs2 found in path. Falling back to using du" 368 echo "$self: WARNING: no mkjfs.jffs2 found in path. Falling back to using du"
366 echo "for size calculation. mkfs.jffs2 is recommended for size calculation" 369 echo "for size calculation. mkfs.jffs2 is recommended for size calculation"
367 echo "as it calculates the real package size on the compressed file system," 370 echo "as it calculates the real package size on the compressed file system,"
368 echo "in contrast to du calculating the uncompressed size!" 371 echo "in contrast to du calculating the uncompressed size!"
369 buildsize=`du -h -s $tempDir | awk '{print $1}'` 372 buildsize=`du -h -s $tempDir | awk '{print $1}'`
370else 373else
371 buildsize=`$mkfsjffs2 -r $tempDir | wc -c` 374 buildsize=`$mkfsjffs2 -r $tempDir | wc -c`
372fi 375fi
373 376
374if [ "$buildsize" != "0" ]; then 377if [ "$buildsize" != "0" ]; then
375 echo "Installed-Size: $buildsize" >> $ctrldir/control 378 echo "Installed-Size: $buildsize" >> $ctrldir/control
376fi 379fi
377 380
378installScript $preinst 381installScript $preinst
379installScript $postinst 382installScript $postinst
380installScript $prerm 383installScript $prerm
381installScript $posrm 384installScript $posrm
382 385
383$ipkgbuild $classic -o $user -g $group $tempDir 386$ipkgbuild $classic -o $user -g $group $tempDir
384 387
385rm -rf $tempDir 388rm -rf $tempDir