Index: /main/trunk/package-kits/linux/repos/ReadMe
===================================================================
--- /main/trunk/package-kits/linux/repos/ReadMe	(revision 29690)
+++ /main/trunk/package-kits/linux/repos/ReadMe	(revision 29691)
@@ -1,2 +1,11 @@
+================================================================================
+Web Server Setup:
+================================================================================
+Any web server that can serve files should work fine.
+No special security settings should be required, as the sync script will only
+copy the necessary package files.
+Symlinks must be enabled for the Pacman repository, because they are used to
+keep the size down (noarch packages are symlinked into both x86_64 and i686)
+
 ================================================================================
  General:
@@ -29,4 +38,11 @@
     reprepro is used to manage the repository, so this script just generates the
     reprepro config, and wraps reprepro to automate some things.
+
+./pacman
+    Generates a pacman package repository under ./repos/
+    repo-add is used to manage the repositories.
+    This script automates copying packages to their correct architecture folder,
+    signing them, and adding them to the relevant package database(s) using
+    repo-add.
     
 ================================================================================
Index: /main/trunk/package-kits/linux/repos/apt
===================================================================
--- /main/trunk/package-kits/linux/repos/apt	(revision 29690)
+++ /main/trunk/package-kits/linux/repos/apt	(revision 29691)
@@ -35,4 +35,5 @@
                 read keyid
             done
+            echo $keyid > $base/gpg.key.id
             echo
         fi
Index: /main/trunk/package-kits/linux/repos/pacman
===================================================================
--- /main/trunk/package-kits/linux/repos/pacman	(revision 29691)
+++ /main/trunk/package-kits/linux/repos/pacman	(revision 29691)
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+. $(dirname $0)/conf.sh
+
+help="Options:
+  setup
+  add </path/to/1.pkg.tar.xz> ..."
+
+repo_add_check() {
+    cd $repos/arch/ || {
+        echo "Repository not found. Have you set it up?" >&2
+        exit 1
+    }
+    test -x `which repo-add` || {
+        echo "Must install repo-add to manage pacman packages" >&2
+        exit 1
+    }
+}
+
+case $1 in
+    setup)
+        echo "Making arch package repository folders"
+        for arch in any x86_64 i686; do
+            mkdir -p $repos/arch/$arch || exit 1
+        done
+        echo "Making readme file"
+        echo "\
+To use this repository:
+
+1. Add the following section to your pacman.conf:
+
+  [$label]
+  Server = http://$domain/repos/arch/\$arch
+
+2. Import the $label GPG public key:
+
+  wget http://$domain/repos/gpg.key -O ${label}.key
+  sudo pacman-key -a ${label}.key
+  sudo pacman-key -f <keyid>
+  sudo pacman-key --lsign-key <keyid>
+
+To find the <keyid>, you can run
+
+  sudo pacman-key -l
+
+And find the key with uid '$origin'.
+It should be at the bottom, as it was just added
+
+2.1. If you don't want to import the $label GPG key, you can just prepend the
+following to your pacman.conf:
+
+  [SigLevel = Optional]
+
+This will disable signature checking, allowing you to install packages
+without ensuring they originated with the Greenstone Team." > $repos/arch/readme
+        ;;
+    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
+        repo_add_check
+        shift
+        for pkg in $@; do
+            # Default to all architectures unless an architecture is specified
+            arch="any"
+            echo $pkg | grep 'x86_64\.pkg' >/dev/null 2>/dev/null && {
+                arch="x86_64"
+            }
+            echo $pkg | grep 'i686\.pkg' >/dev/null 2>/dev/null && {
+                arch="i686"
+            }
+            name="$(basename $pkg)"
+            echo "$name: $arch"
+            cp $pkg $arch/
+            rm -f "$arch/${name}.sig"
+            gpg --detach-sign --use-agent --default-key $keyid "$arch/$name"
+            # If arch is any, symlink package into all architectures
+            if test "$arch" = "any"; then
+                for link in x86_64 i686; do
+                    echo "$name: $link (linked)"
+                    cd $link
+                    ln -sf ../any/$name $name
+                    ln -sf ../any/${name}.sig ${name}.sig
+                    cd ..
+                done
+                arch="any x86_64 i686"
+            fi
+
+            for pkgarch in $arch; do
+                cd $pkgarch
+                repo-add -s -k $keyid -v -d ${label}.db.tar.xz $name
+                cd ..
+            done
+        done
+        ;;
+    -h|--help|help)
+        echo "$help"
+        ;;
+    *)
+        if test -z "$*"; then
+            echo "$help"
+        else
+            repo_add_check
+            repo-add $@
+        fi
+        ;;
+esac
