Convenient wrapper around mock
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 11 Sep 2008 11:12:45 +0000 (07:12 -0400)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 11 Sep 2008 11:12:45 +0000 (07:12 -0400)
smock/README [new file with mode: 0644]
smock/smock.httpd.conf [new file with mode: 0644]
smock/smock.mock.cfg [new file with mode: 0644]
smock/smock.sh [new file with mode: 0755]

diff --git a/smock/README b/smock/README
new file mode 100644 (file)
index 0000000..b670973
--- /dev/null
@@ -0,0 +1,25 @@
+ SMOCK - Simpler Mock
+ ====================
+
+Smock is a thin wrapper around mock to let you build up a whole
+set of dependant RPMs against an external distro.
+
+ - Copy smock.httpd.conf to /etc/httpd/conf.d/smock.conf, changing the
+   /home/[USERNAME]/ to your user
+ - Start httpd
+ - Add  smock.mock.conf to all your repos in /etc/mock/ changing the
+   arch and distro name to match
+ - Create  $HOME/smock
+
+ - Edit smock.sh to set which arch(es) you want to build on
+
+Now you can run
+
+    ./smock.sh fedora-9 /path/to/srpm
+
+And it'll build  the RPM against the fedora-9-XXX distro for each 'XXX' 
+arch you listed.
+
+The resulting src RPMs, binary RPMs and build logs wil be put into
+$HOME/smock, and a YUM repo created. Further RPMs you build using
+smock will resolve the BuildRequires against this local repo
diff --git a/smock/smock.httpd.conf b/smock/smock.httpd.conf
new file mode 100644 (file)
index 0000000..e14f71e
--- /dev/null
@@ -0,0 +1,8 @@
+
+
+Alias /smock /home/USERNAME/smock
+
+<Directory /home/USERNAME/smock>
+   Allow from all
+  Options +Indexes
+</Directory>
diff --git a/smock/smock.mock.cfg b/smock/smock.mock.cfg
new file mode 100644 (file)
index 0000000..0fa4316
--- /dev/null
@@ -0,0 +1,5 @@
+[smock]
+name=smock
+baseurl=http://127.0.0.1/smock/yum/fedora-9/i386
+enabled=1
+
diff --git a/smock/smock.sh b/smock/smock.sh
new file mode 100755 (executable)
index 0000000..41b7888
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+
+LOCALREPO=$HOME/smock/yum
+#ARCHES="i386 x86_64"
+ARCHES=i386
+
+help() {
+    echo "syntax: $0 DIST SRPM"
+}
+
+if [ -z "$1" ]; then
+    help
+    exit
+fi
+
+
+if [ -z "$2" ]; then
+    help
+    exit
+fi
+
+DIST=$1
+SRPM=$2
+
+createrepos() {
+
+  (
+    mkdir -p $LOCALREPO/$DIST/src/SRPMS
+    cd $LOCALREPO/$DIST/src
+    rm -rf repodata
+    createrepo .
+  )
+
+  for ARCH in $ARCHES
+  do
+    (
+      mkdir -p $LOCALREPO/$DIST/$ARCH/RPMS
+      mkdir -p $LOCALREPO/$DIST/$ARCH/logs
+      cd $LOCALREPO/$DIST/$ARCH
+      rm -rf repodata
+      createrepo --exclude "logs/*rpm" .
+    )
+  done
+}
+
+createrepos
+
+mkdir -p $LOCALREPO/scratch
+rm -f $LOCALREPO/scratch/*
+
+for ARCH in $ARCHES
+do
+    mkdir -p $LOCALREPO/$DIST/$ARCH/logs/$SRPM
+
+    mock -r $DIST-$ARCH --resultdir $LOCALREPO/scratch $SRPM
+
+    mv $LOCALREPO/scratch/*.src.rpm $LOCALREPO/$DIST/src/SRPMS
+    mv $LOCALREPO/scratch/*.rpm $LOCALREPO/$DIST/$ARCH/RPMS
+    mv $LOCALREPO/scratch/*.log $LOCALREPO/$DIST/$ARCH/logs/$SRPM/
+done
+
+createrepos