aboutsummaryrefslogtreecommitdiff
path: root/dist/debian/mkpkg
blob: 830d8b2cd8cefd39da706d80efdc8c4072230bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/local/plan9/bin/rc

nl='
'

fn comma {
	if(! ~ $#* 0 1){
		echo -n $1
		shift
		sep=' '
		len=0
		for(i){
			echo -n $sep$i
			sep=', '
			l=`{echo -n $sep$i|9 wc -c}
			len=`{echo $l+$len | hoc}
			if(test $len -gt 60){
				sep=','^$nl^' '
				len=0
			}
		}
		echo
	}
}

if(~ $#* 1 && ~ $1 all)
	*=`{9 ls -p ../pkg | grep -v CVS}

if(~ $#TREE9 0)
	TREE9=$PLAN9

date=`{u date +%Y%m%d}
march=`{uname -m}
arch=all
switch($march){
case i*86
	march=i386
}

for(i)@{
	if(! test -f ../pkg/$i){
		echo no package ../pkg/$i
		exit 1
	}
	package=plan9port-$i
	grepfor=$i
	. ../pkg/$i
	deb=$package^_$date^_$arch.deb
	rm -rf $i $deb
	mkdir $i $i/DEBIAN
	whatis grepfor
	awk -v'grepfor='$grepfor -v 'pkg='$i -v 'plan9='$TREE9 '
	BEGIN { print "grep for " grepfor >"/dev/stderr" }
	$2==grepfor {
		dir=$1
		sub("/[^/]+$", "/", dir)
		if(dir != lastdir){
			printf("mkdir -p ''%s''\n", pkg "/usr/local/plan9/" dir);
			lastdir = dir
		}
		if($1 !~ /\/$/)
			printf("cp ''%s'' ''%s''\n", plan9 "/" $1, pkg "/usr/local/plan9/" $1)
	}' $TREE9/dist/filelist | rc
	size=`{du -sk $i | awk '{print $1}'}
	{
		echo Package: $package
		echo Version: $date
		echo Architecture: $arch
		comma Depends: $depends
		comma Suggests: $suggests
		comma Conflicts: $conflicts
		echo Source: plan9port-src
		echo Installed-Size: $size
		echo Maintainer: 'Russ Cox <rsc@swtch.com>'
		echo Description: $desc
	} >$i/DEBIAN/control
	if(test -d $i/usr){
		@{
			cd $i
			find usr -type f -print0 | xargs -0 -n 100 u md5sum
		} >$i/DEBIAN/md5sums
	}
	if not
		echo '>>>' $package is a virtual package.
	dpkg -b $i pool/$deb
	rm -rf $i
}