From bdce13e6a3a27b91d8693e1e5b257e298c463e73 Mon Sep 17 00:00:00 2001 From: Viktor Hercinger Date: Thu, 21 Feb 2013 09:23:07 +0100 Subject: initial commit --- build-spec | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ make-repo | 72 ++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100755 build-spec create mode 100755 make-repo diff --git a/build-spec b/build-spec new file mode 100755 index 0000000..c6d1818 --- /dev/null +++ b/build-spec @@ -0,0 +1,158 @@ +#!/bin/sh + +DESTDIR=.build +CLEAN=0 +DIST=fedora-18-local-x86_64 +PACKAGE_PATH_BASE=$HOME/devel/specs + +MOCKDIR=/var/lib/mock +MOCKCONF=/etc/mock +PACKAGES= + +function die +{ + echo $@ >&2 + exit 1 +} + +function get_mock_path +{ + FILE="$MOCKCONF/$1.cfg" + NAME=$(sed -n "s,^config_opts\['root'\]\s*=\s*'\(.*\)'.*$,\1,p" $FILE) + + echo $MOCKDIR/$NAME +} + +while [ $# -gt 0 ] +do + OPTION=$1 + shift + + case $OPTION in + -b|--build) + DESTDIR=$1 + shift + ;; + + -c|--clean) + CLEAN=1 + ;; + + -d|--dist) + DIST=$1 + shift + ;; + + --list-pkgs) + for path in $(find $PACKAGE_PATH_BASE -maxdepth 2 -name '*.spec') + do + echo $(basename $(dirname $path)) + done + exit 0 + ;; + + --list-dists) + for profile in $(find $MOCKCONF -name '*.cfg' -printf '%f\n') + do + echo ${profile:0: -4} + done + exit 0 + ;; + + -h|--help) + echo "Create a local repository from the RPMs found in the scan-path. + +usage: $0 [ options ] < package name > + +options: + -b --build Specify output for source/built RPMs (default: $DESTDIR) + -c --clean Clean build directory before building + -d --dist Specify distribution (mock profile name) (default: $DIST) + --list-pkgs List packages that can be built + --list-dists List available distributions + + -h --help Show this help file" + exit 1 + ;; + + --) + PACKAGES="$PACKAGES $@" + break + ;; + + -*) + echo "Unkown option $OPTION" >&2 + exit 1 + ;; + + *) + PACKAGES="$PACKAGES $OPTION" + ;; + esac +done + +[ "x$PACKAGES" = "x" ] && die Missing package name + +#set -x + +if [ $CLEAN -eq 1 ] +then + rm -rf $DESTDIR/* +fi + +if [ ! -d $DESTDIR ] +then + mkdir -p $REPODIR +elif [ ! -w $REPODIR ] +then + die "You don't have access to $REPODIR" +fi + +mkdir -p $DESTDIR/srpm +mkdir -p $DESTDIR/rpm + +BASE_DIR=$(pwd) + +cd $DESTDIR +DESTDIR=$(pwd) +cd $BASE_DIR + +for PACKAGE in $PACKAGES +do + PACKAGE_PATH=$PACKAGE_PATH_BASE/$PACKAGE + + if [ ! -d $PACKAGE_PATH ] + then + echo "$PACKAGE_PATH not found" + continue + fi + + SPECFILE=$(find $PACKAGE_PATH -name '*.spec' | head -1) + if [ "x$SPECFILE" = "x" ] + then + echo "$PACKAGE_PATH contains no spec file" + continue + fi + + mock --buildsrpm --spec $SPECFILE --sources $PACKAGE_PATH -r $DIST + if [ $? -ne 0 ] + then + echo "Mock failed to create srpm from $SPECFILE" + continue + fi + + DISTPATH=$(get_mock_path $DIST)/result + SRPM=$(find $DISTPATH -name '*.src.rpm' -printf '%f\n' | head -1) + cp $DISTPATH/$SRPM $DESTDIR/srpm + + mock -r $DIST --rebuild $DESTDIR/srpm/$SRPM + if [ $? -ne 0 ] + then + echo "Mock failed to build $SRPM" + continue + fi + + find $DISTPATH \( -name '*.rpm' -a ! -name '*.src.rpm' \) -exec cp {} $DESTDIR/rpm \; + + cd $BASE_DIR +done diff --git a/make-repo b/make-repo new file mode 100755 index 0000000..b9e15ca --- /dev/null +++ b/make-repo @@ -0,0 +1,72 @@ +#!/usr/bin/sh + +REPODIR=/var/www/lighttpd/repos/local +SCANPATH=.build +CLEAN=0 + +while [ $# -gt 0 ] +do + OPTION=$1 + shift + + case $OPTION in + -r|--repo-dir) + REPODIR=$1 + shift + ;; + + -c|--clean) + CLEAN=1 + ;; + + -p|--path) + SCANPATH=$1 + shift + ;; + + -h|--help) + echo "Create a local repository from the RPMs found in the scan-path. + +usage: $0 [ options ] + +options: + -r --repo-dir Specify output directory of created repository (default: $REPODIR) + -c --clean Clean repository before scanning path for files + -p --path Scan specified path for RPMs (default: $SCANPATH) + + -h --help Show this help file" + exit 1 + ;; + esac +done + +if [ ! -d $REPODIR ] +then + mkdir -p $REPODIR +fi + +if [ ! -w $REPODIR ] +then + echo "You don't have access to $REPODIR" >&2 + exit 1 +fi + +if [ $CLEAN -eq 1 ] +then + rm -rf $REPODIR/* +fi + +find $SCANPATH \( -name '*.rpm' -a ! -path '*/.repo/*' \) -exec cp {} $REPODIR \; +createrepo -o $REPODIR $REPODIR + +ls -lahR $REPODIR > $REPODIR/files.txt + +IPADDR=$(ifconfig em1 | grep 'inet ' | sed -e 's,^\s\+inet \([0-9.]\+\).*$,\1,') + +cat >$REPODIR/local.repo <