summaryrefslogtreecommitdiffstats
path: root/makepkg
diff options
context:
space:
mode:
Diffstat (limited to 'makepkg')
-rwxr-xr-xmakepkg88
1 files changed, 88 insertions, 0 deletions
diff --git a/makepkg b/makepkg
new file mode 100755
index 00000000..b9ad4bcb
--- /dev/null
+++ b/makepkg
@@ -0,0 +1,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";