#!/bin/sh . $(dirname $0)/conf.sh help="Options: setup add ..." createrepo_check() { cd $repos/rpm/ || { echo "Repository not found. Have you set it up?" >&2 exit 1 } test -x `which createrepo` || { echo "Must install createrepo to manage rpm packages" >&2 exit 1 } test -x `which rpmsign` || { echo "Must install rpmsign to sign rpm packages" >&2 exit 1 } } case $1 in setup) echo "Making rpm package repository folders" for arch in any x86_64 i386; do mkdir -p $repos/rpm/$arch || exit 1 done echo "Making ReadMe file" echo "\ $setup_cmd_instruction ( echo '[$label]' echo 'name=$origin' echo 'baseurl=http://$uri_root/rpm/\$basearch' echo 'enabled=1' echo 'gpgcheck=1' echo 'gpgkey=http://$uri_root/gpg.key' ) > /etc/yum.repos.d/greenstone.repo yum makecache $install_cmd_instruction sudo yum install greenstone " > $repos/rpm/ReadMe.txt ;; add) keyid=$(get_gpg) createrepo_check shift for pkg in $@; do # Default to all architectures unless an architecture is specified arch="any" echo $pkg | grep 'x86_64\.rpm' >/dev/null 2>/dev/null && { arch="x86_64" } echo $pkg | grep 'i686\.rpm' >/dev/null 2>/dev/null && { arch="i386" } name="$(basename $pkg)" echo "$name: $arch" cp $pkg $arch/ # Unfortunately RPM is (as usual) sub-standard, and will not use # gpg-agent. As such, you will probably be forced to enter a pass # phrase for every single package that gets signed, regardless of # whether your GPG key even has a pass-phrase (just hit enter in # that case) echo "Signing $name..." rpmsign --key-id=$keyid --addsign $arch/$name # If arch is any, symlink package into all architectures if test "$arch" = "any"; then for link in x86_64 i386; do echo "$name: $link (linked)" cd $link ln -sf ../any/$name $name cd .. done fi done for arch in x86_64 i386; do cd $arch createrepo --update . rm -f repodata/repomd.xml.asc gpg --detach-sign --armor --use-agent --default-key $keyid repodata/repomd.xml cd .. done ;; -h|--help|help) echo "$help" ;; *) if test -z "$*"; then echo "$help" else createrepo_check createrepo $@ fi ;; esac