#!/bin/bash # Used to compile a package and copy it to the correct repository location. # all arguments are passed to makepkg # # . /etc/makepkg.conf . PKGBUILD PKGHOME=/data/pkg_repo/packages SRCPKGHOME=/data/pkg_repo/src_packages mydir=`pwd` repolist="core extra" cmdline=$@ if [ x`basename $0` = xmpr ] then PFIX="" else PFIX="-testing" fi function bump { echo x$cmdline | grep -q \\-b if [ $? = 0 ] then cmdline=`echo $cmdline|sed -e "s/-b//g"` i="PKGBUILD" #getting pkgrel number after = package_pkgrel=`cat $i | grep pkgrel= | cut -d'=' -f 2` #extract number before dot in pkgrel beforedot=`echo $package_pkgrel | cut -n -d'.' -f 1` #add 1 to pkgrel new_pkgrel=$[$beforedot+1] #write it back to PKGBUILD sed -i "s:pkgrel=${package_pkgrel}:pkgrel=${new_pkgrel}:g" $i echo "bumped $pkgname release from $package_pkgrel to $new_pkgrel" . PKGBUILD fi TOTALPKG="$pkgname"-"$pkgver"-"$pkgrel"-"$CARCH".pkg.tar.gz SRCPKG="$pkgname"-"$pkgver"-"$pkgrel".src.tar.gz } function find_repo { dirname=`dirname $mydir` echo $dirname|grep -q "extra" if [ $? = 0 ] then REPO=extra${PFIX} else REPO=core${PFIX} fi echo $dirname|grep -q "chroot-devel" if [ $? = 0 ] then REPO=chroot-devel fi echo $dirname|grep -q "mv-core" if [ $? = 0 ] then REPO=mv-core fi if [ x`basename $0` = xmpl ] then REPO="local" fi DOCROOT=/data/pkg_repo/$CARCH/$REPO if [ ! -e $DOCROOT ] then mkdir -p $DOCROOT fi } function update-repo { cd $DOCROOT echo echo "DOCROOT=$DOCROOT" echo #remove old package from local copy DELPKG="$pkgname"-"$pkgver"-*-"$CARCH".pkg.tar.gz #echo $DOCROOT #echo $DELPKG echo "Removing old packages from $CARCH/$REPO:" rm -fvI $DELPKG #copy in new package echo echo "Updating $CARCH/$REPO with $TOTALPKG" cp -f $PKGDEST/$TOTALPKG . repo-add $DOCROOT/$REPO.db.tar.gz $DOCROOT/$TOTALPKG cd - } function update-src-pkg { DELPKG="$pkgname"-"$pkgver"-*.src.tar.gz echo "Removing old src pkg" if [ ! -d $PKGHOME/$REPO/$SRCPKG ] then echo "Creating src_pkg directory" mkdir -p $SRCPKGHOME/$REPO fi rm -vf $SRCPKGHOME/$REPO/$DELPKG echo "copying src_pkg to $SRCPKGHOME/$REPO" cp -f $PKGHOME/$SRCPKG $SRCPKGHOME/$REPO } function dup_check { if [ $REPO = "local" -o $REPO = "mv-core" ] then return fi for i in $repolist do if [ ! $i$PFIX = $REPO ] then out=`pacman -Sl $i$PFIX|cut -d" " -f2 |grep ^pkgname$` if [ $? = 0 ] then echo "#######################################" echo "$pkgname already exists in $i$PFIX" echo " "$out echo echo x$cmdline|grep -q \\-f if [ $? = 0 ] then echo "Force detected, making pkg anyhow" echo "#######################################" return else echo "#######################################" exit 2 fi fi fi done } #MAIN PROGRAM find_repo dup_check bump echo "---------------" makepkg --asroot $cmdline || exit 1 echo "---------updating database ----------" update-repo #&& pacman -Sy echo "----------creating source package---------" makepkg -f --holdver --asroot --source --skipinteg && update-src-pkg