#!/bin/bash # vim:set ts=2 sw=2 ft=sh et: # Copyright © Sébastien Luttringer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. . /etc/makepkg.conf repo_path='/home/seblu/scm/archrepo/x86_64' repo_db='seblu.db.tar.gz' commit=0 #no commit by default delete=1 #delete old pkg usage() { echo "${0##*/} [options] *$PKGEXT" echo echo "options:" echo " -h: display this help" echo " -c: svn commit" echo " -p: preserve old packages in repository" } # check args count (( $# < 1 )) && usage && exit 1 # parse optios while getopts "hcp" opts; do case $opts in c) commit=1;; d) delete=0;; h) usage; exit 0;; *) usage; exit 1;; esac done # skip optional args (( OPTIND > 0 )) && shift $((OPTIND - 1)) for pkg; do [[ ! -r "$pkg" ]] && echo "No readable package $pkg, skipped." && continue [[ ! "$pkg" =~ .*$PKGEXT ]] && echo "Invalid package $pkg, skipped." && continue mv -i "$pkg" "$repo_path" && ( cd "$repo_path" svn add "$pkg" repo-add "$repo_db" "$pkg" # remove old verions (( delete )) || continue pkgname=${pkg%-*} pkgname=${pkgname%-*} pkgname=${pkgname%-*} for j in $pkgname-*$PKGEXT; do [[ "$pkg" == "$j" ]] && continue svn rm "$j" done ) done (( commit )) && cd "$repo_path" && svn commit -m "add $*"