plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

mkpkg (1610B)


      1 #!/usr/local/plan9/bin/rc
      2 
      3 nl='
      4 '
      5 
      6 fn comma {
      7 	if(! ~ $#* 0 1){
      8 		echo -n $1
      9 		shift
     10 		sep=' '
     11 		len=0
     12 		for(i){
     13 			echo -n $sep$i
     14 			sep=', '
     15 			l=`{echo -n $sep$i|9 wc -c}
     16 			len=`{echo $l+$len | hoc}
     17 			if(test $len -gt 60){
     18 				sep=','^$nl^' '
     19 				len=0
     20 			}
     21 		}
     22 		echo
     23 	}
     24 }
     25 
     26 if(~ $#* 1 && ~ $1 all)
     27 	*=`{9 ls -p ../pkg | grep -v CVS}
     28 
     29 if(~ $#TREE9 0)
     30 	TREE9=$PLAN9
     31 
     32 date=`{u date +%Y%m%d}
     33 march=`{uname -m}
     34 arch=all
     35 switch($march){
     36 case i*86
     37 	march=i386
     38 }
     39 
     40 for(i)@{
     41 	if(! test -f ../pkg/$i){
     42 		echo no package ../pkg/$i
     43 		exit 1
     44 	}
     45 	package=plan9port-$i
     46 	grepfor=$i
     47 	. ../pkg/$i
     48 	deb=$package^_$date^_$arch.deb
     49 	rm -rf $i $deb
     50 	mkdir $i $i/DEBIAN
     51 	whatis grepfor
     52 	awk -v'grepfor='$grepfor -v 'pkg='$i -v 'plan9='$TREE9 '
     53 	BEGIN { print "grep for " grepfor >"/dev/stderr" }
     54 	$2==grepfor {
     55 		dir=$1
     56 		sub("/[^/]+$", "/", dir)
     57 		if(dir != lastdir){
     58 			printf("mkdir -p ''%s''\n", pkg "/usr/local/plan9/" dir);
     59 			lastdir = dir
     60 		}
     61 		if($1 !~ /\/$/)
     62 			printf("cp ''%s'' ''%s''\n", plan9 "/" $1, pkg "/usr/local/plan9/" $1)
     63 	}' $TREE9/dist/filelist | rc
     64 	size=`{du -sk $i | awk '{print $1}'}
     65 	{
     66 		echo Package: $package
     67 		echo Version: $date
     68 		echo Architecture: $arch
     69 		comma Depends: $depends
     70 		comma Suggests: $suggests
     71 		comma Conflicts: $conflicts
     72 		echo Source: plan9port-src
     73 		echo Installed-Size: $size
     74 		echo Maintainer: 'Russ Cox <rsc@swtch.com>'
     75 		echo Description: $desc
     76 	} >$i/DEBIAN/control
     77 	if(test -d $i/usr){
     78 		@{
     79 			cd $i
     80 			find usr -type f -print0 | xargs -0 -n 100 u md5sum
     81 		} >$i/DEBIAN/md5sums
     82 	}
     83 	if not
     84 		echo '>>>' $package is a virtual package.
     85 	dpkg -b $i pool/$deb
     86 	rm -rf $i
     87 }
     88