Skip to content
seblu-repo-add 1.19 KiB
Newer Older
#!/bin/bash
# vim:set ts=2 sw=2 ft=sh et:

. /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 $*"