Created
September 22, 2012 20:30
-
-
Save lbt/3767738 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quickbuild script | |
# | |
# Issues: | |
# * Remove [target] if we can determine what last build-target was (maybe cache it?) | |
usage() { | |
cat <<EOF | |
usage: $0 [ -h | --help ] [target] | |
This script makes it easy to quickly reuse "osc build" to regenerate | |
rpms based on a local source tree. | |
It makes the following assumptions: | |
* the current directory name is the same as the package name | |
(Usually the directory created when doing osc co <project> <package>) | |
* the directory contains an subdirectory with the unpacked source | |
whose name is the same as the rpmbuild directory | |
* | |
EOF | |
} | |
# gitpkg | |
# if .git/ and .osc/ are present then assume gitpkg | |
# if branch is pkg-* then copy over the packaging (and assume src unchanged?) | |
# else copy over the src (and assume spec unchanged?) | |
# rpm/ present | |
# if there is an rpm/ dir then copy the contents as packaging | |
while [[ $# -gt 0 ]] ; do | |
case $1 in | |
-h | --help ) | |
usage; exit 1;; | |
* ) target=$1 ; shift ;; | |
esac | |
done | |
package=${PWD##*/} # basenane of CWD | |
if ! [[ -d .osc ]]; then | |
echo "This is not an OSC directory." | |
exit 1 | |
fi | |
srcdir=$(find * -maxdepth 0 -type d -name ${package}\*) | |
numsrc=$(wc -l <<< $srcdir) | |
if [[ $numsrc -eq 0 ]]; then | |
echo "There is no src directory called ${package}<something>" | |
exit 1 | |
fi | |
if [[ $numsrc -gt 1 ]]; then | |
echo "There are multiple src directories called ${package}<something> - this script requires there to be just one." | |
exit 1 | |
fi | |
if ! osc -o chroot pwd >/dev/null 2>&1 ; then | |
echo "No existing chroot - doing a normal build" | |
osc build $target | |
else | |
osc build -o --rebuild --rsync-src=$srcdir --rsync-dest=/home/abuild/rpmbuild/BUILD/$srcdir $target | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment