Index: /main/trunk/package-kits/linux/repos/ReadMe
===================================================================
--- /main/trunk/package-kits/linux/repos/ReadMe	(revision 29691)
+++ /main/trunk/package-kits/linux/repos/ReadMe	(revision 29692)
@@ -45,4 +45,12 @@
     signing them, and adding them to the relevant package database(s) using
     repo-add.
+
+./rpm
+    Generates a rpm package repository under ./repos/
+    createrepo is used to manage the repositories.
+    rpmsign is used to sign the packages.
+    This script automates copying packages to their correct architecture folder,
+    signing them with rpmsign, and adding them to the relevant package
+    database(s) using createrepo --update.
     
 ================================================================================
Index: /main/trunk/package-kits/linux/repos/rpm
===================================================================
--- /main/trunk/package-kits/linux/repos/rpm	(revision 29692)
+++ /main/trunk/package-kits/linux/repos/rpm	(revision 29692)
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+. $(dirname $0)/conf.sh
+
+help="Options:
+  setup
+  add </path/to/1.rpm> ..."
+
+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 repo file"
+        echo "\
+[$label]
+name=$origin
+baseurl=http://$domain/repos/rpm/\$basearch
+enabled=1
+gpgcheck=1
+gpgkey=http://$domain/repos/gpg.key" > "$repos/rpm/${label}.repo"
+        ;;
+    add)
+        if test -f $base/gpg.key.id; then
+            keyid=$(cat $base/gpg.key.id)
+        else
+            gpg --list-keys
+            echo "Enter the keyid of the GPG key to use:"
+            while test -z $keyid; do
+                echo -n "> "
+                read keyid
+            done
+            echo $keyid > $base/gpg.key.id
+            echo
+        fi
+        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
