From: Martin Vidner Date: Wed, 25 Nov 2015 14:04:43 +0000 (+0100) Subject: Moved the script to a dedicated repo. X-Git-Tag: v0.3.3~21^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=284275eeeb025c9fa1e749b63a6b9af5923bee67;p=thirdparty%2Fsnapper.git Moved the script to a dedicated repo. --- diff --git a/Makefile.ci b/Makefile.ci index 019d9286..3b30ca05 100644 --- a/Makefile.ci +++ b/Makefile.ci @@ -8,13 +8,19 @@ # Usage in Jenkins: # make -f Makefile.ci osc_build -.PHONY: package osc_build - -package: - ./obs-package-from-git \ +.PHONY: package +package: obs-package-from-git + ./$^ \ -P YaST:Head -p snapper \ -o .obsdir \ -c 'make -f Makefile.repo && make package' +.PHONY: osc_build osc_build: package cd .obsdir; osc build + +# A script that is shared with other projects and should be always refreshed +URL=https://raw.githubusercontent.com/openSUSE/obs-package-from-git/master/obs-package-from-git +.PHONY: always_out_of_date +obs-package-from-git: always_out_of_date + wget -O $@ $(URL) && chmod +x $@ diff --git a/obs-package-from-git b/obs-package-from-git deleted file mode 100755 index b83d695d..00000000 --- a/obs-package-from-git +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -set -eu - -# Given a Git repo of a package in the Open Build Service, -# make a source package from that repo, -# using `osc` to bring the dependencies to a chroot. - -# Minimal dependencies: -# - git-core (not used here; our caller, typically Jenkins, will have used it) -# - osc -# - build - -main() { - local USAGE_TEXT=' -Usage: main - -Options: --P --p --o (will be removed first) --c Shell command to make a package -' - local COMMAND OBSDIR PROJECT PACKAGE - local USAGE=false RC=0 - while getopts c:ho:P:p: FLAG; do - case $FLAG in - c) COMMAND="$OPTARG";; - h) USAGE=true;; - o) OBSDIR="$OPTARG";; - P) PROJECT="$OPTARG";; - p) PACKAGE="$OPTARG";; - - *) USAGE=true; RC=1;; - esac - done - shift $((OPTIND-1)) - - if $USAGE; then - echo "$USAGE_TEXT" - return $RC - fi - - local GITDIR=`pwd` - rm -rf $OBSDIR - osc checkout --output-dir=$OBSDIR $PROJECT $PACKAGE - cd $OBSDIR - - export OSC_BUILD_ROOT=/var/tmp/build-root-git-to-obs - init_build_root - - copy_git_to_chroot $GITDIR - - make_package "$COMMAND" - - fetch_package - - # CLEANUP - cleanup_git_in_chroot -} - -# short circuit the first build -# in: -# cwd: obs -# $OSC_BUILD_ROOT -# out: -# chroot at $OSC_BUILD_ROOT is initialized -init_build_root() { - local SUCCESS_FILE=/tmp/build-root-ready - - rm -f $OSC_BUILD_ROOT/$SUCCESS_FILE - sed -i -e "/^%build/atouch $SUCCESS_FILE; : intentional fail; exit 1" *.spec - osc build --build-uid=caller || : - rm $OSC_BUILD_ROOT/$SUCCESS_FILE # fails if not present -} - -TMPGIT=/tmp/gitdir - -# in: -# $1 git dir -# $OSC_BUILD_ROOT -copy_git_to_chroot() { - cleanup_git_in_chroot - mkdir -p $OSC_BUILD_ROOT/$TMPGIT - rmdir $OSC_BUILD_ROOT/$TMPGIT - cp -a $1 $OSC_BUILD_ROOT/$TMPGIT -} - -# in: -# $OSC_BUILD_ROOT -cleanup_git_in_chroot() { - rm -rf $OSC_BUILD_ROOT/$TMPGIT -} - -# in: -# $1 command to make package -# out: -# package in $OSC_BUILD_ROOT/$TMPGIT/package -make_package() { - sudo chroot --userspec=$USER $OSC_BUILD_ROOT \ - sh -c "cd ${TMPGIT#$OSC_BUILD_ROOT}; $1" -} - -# in: -# pwd: obs dir -fetch_package() { - rm -v *.tar.* - cp -av $OSC_BUILD_ROOT/$TMPGIT/package/* . -} - -main "$@"