blob: 17965d922e3684bc0cac2c81dd1d13852b04c44d (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/bash
me=`basename $0`
myver='1.21'
startdir=`pwd`
[ -f /etc/makepkg.conf ] && . /etc/makepkg.conf
strip_url() {
echo $1 | sed 's|^.*://.*/||g'
}
if [ ! -f $startdir/PKGBUILD ]; then
echo "error: $startdir/PKGBUILD does not exist!" >&2
exit 1
fi
. $startdir/PKGBUILD
echo
d=`date`
echo "==> Building package $pkgname ($d)" >&2
# extract source
echo "==> Acquiring/Extracting Sources..." >&2
mkdir -p src pkg
cd $startdir/src
for netfile in ${source[@]}; do
file=`strip_url $netfile`
if [ -f ../$file ]; then
echo "==> Found $file in build dir" >&2
cp ../$file .
elif [ -f /var/cache/pacman/src/$file ]; then
echo "==> Using local copy of $file" >&2
cp /var/cache/pacman/src/$file .
else
echo "==> Downloading $file" >&2
wget --passive-ftp --no-directories --tries=3 --waitretry=3 $netfile 2>&1
if [ ! -f $file ]; then
echo "==> ERROR: Failed to download $file" >&2
echo "==> Aborting..." >&2
exit 1
fi
mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
fi
case $file in
*.tar.gz|*.tar.Z|*.tgz)
cmd="tar --use-compress-program=gzip -xf $file" ;;
*.tar.bz2)
cmd="tar --use-compress-program=bzip2 -xf $file" ;;
*.zip)
cmd="unzip -qq $file" ;;
*)
cmd="cp ../$file ." ;;
esac
echo "==> $cmd" >&2
$cmd
done
# build
echo "==> Building Package..." >&2
build 2>&1
if [ $? -gt 0 ]; then
echo "==> Build Failed. Aborting..." >&2
exit 2
fi
# write the .PKGINFO file
echo "==> Generating .PKGINFO file..." >&2
cd $startdir/pkg
echo "# Generated by makepkg $myver" >.PKGINFO
echo -n "# " >>.PKGINFO
date >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
for bakfile in "${backup[@]}"; do
echo "backup = $bakfile" >>.PKGINFO
done
if [ "$install" != "" ]; then
cat $startdir/$install | egrep '^[^$]' | sed 's/^/install = /g' >>.PKGINFO
fi
if [ "$remove" != "" ]; then
cat $startdir/$remove | egrep '^[^$]' | sed 's/^/remove = /g' >>.PKGINFO
fi
# remove info/doc files
cd $startdir
rm -rf pkg/usr/info pkg/usr/share/info
rm -rf pkg/usr/doc pkg/usr/share/doc
# strip binaries
cd $startdir
echo "==> Stripping debugging symbols from libraries..." >&2
find pkg/{,usr,usr/local}/lib -type f \
-exec /usr/bin/strip --strip-debug '{}' ';' 2>&1
echo "==> Stripping symbols from binaries..." >&2
find pkg/{,usr,usr/local}/{bin,sbin} -type f \
-exec /usr/bin/strip '{}' ';' 2>&1
# tar it up
echo "==> Compressing package..." >&2
cd $startdir/pkg
tar czvf $startdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO * >../filelist
cd $startdir
d=`date`
echo "==> Finished ($d)" >&2
exit 0
|