summaryrefslogtreecommitdiffstats
path: root/makepkg
blob: b9ad4bcba5024c7748a6b0f839cefd8e50c8a660 (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
#!/bin/bash

me=`basename $0`
myver='1.0'
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!"
  exit
fi

. $startdir/PKGBUILD

# extract source
echo "==> Acquiring/Extracting Sources..."
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"
    cp ../$file .
  elif [ -f /var/cache/pkg/$file ]; then
    echo "==> Using local copy of $file"
    cp /var/cache/pkg/$file .
  else
    echo "==> Downloading $file"
    wget --passive-ftp --no-directories --tries=3 --waitretry=3 $netfile
    if [ ! -f $file ]; then
      echo "==> ERROR: Failed to download $file"
      echo "==> Aborting..."
      exit 1
    fi
    mkdir -p /var/cache/pkg && cp $file /var/cache/pkg
  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"
	$cmd
done

# build
echo "==> Building Package..."
build

# write the .PKGINFO file
echo "==> Generating .PKGINFO file..."
cd $startdir/pkg
echo "# Generated by makepkg $myver" >.PKGINFO
echo -n "# " >>.PKGINFO
date >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO

# remove info files
cd $startdir
rm -rf pkg/usr/info pkg/usr/share/info

# strip binaries
cd $startdir
echo "==> Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local}/lib -type f \
   -exec /usr/bin/strip --strip-debug '{}' ';'
echo "==> Stripping symbols from binaries..."
find pkg/{,usr,usr/local}/{bin,sbin} -type f \
   -exec /usr/bin/strip '{}' ';'

# tar it up
echo "==> Compressing package..."
cd $startdir/pkg
tar czvf $startdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO * >../filelist

cd $startdir
echo "==> Finished";