diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-09-11 20:22:06 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-29 12:35:28 +0200 |
commit | 012eebe233371bebac63438dd8083f8a8fe468be (patch) | |
tree | 322e4f69e56b284370ec66edaab97babfba3212e | |
parent | 9b5bdbca998c78ae31301eb216b265d4c163ba34 (diff) |
Support for git-push after successful build of package update
-rw-r--r-- | example.rc | 12 | ||||
-rwxr-xr-x | nix-script-update-package-def.sh | 44 |
2 files changed, 51 insertions, 5 deletions
@@ -59,3 +59,15 @@ RC_UPD_NIX_BUILD_J=2 # RC_UPD_NIX_BUILD_CORES=2 +# +# when updating a package definition, do git-push afterwards +# 0 = no, 1 = yes +# +RC_UPD_PUSH=0 + +# +# when updating a package definition, push to this remote. Several can be +# specified. +# +RC_UPD_PUSH_REMOTE="github" + diff --git a/nix-script-update-package-def.sh b/nix-script-update-package-def.sh index bf6b448..50c0b4a 100755 --- a/nix-script-update-package-def.sh +++ b/nix-script-update-package-def.sh @@ -12,7 +12,7 @@ source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh usage() { cat <<EOS - $(help_synopsis "${BASH_SOURCE[0]}" "[-y] [-b] [-c] [-g <nixpkgs path>] [-j <n>] [-C <n>] -u <url>") + $(help_synopsis "${BASH_SOURCE[0]}" "[-y] [-b] [-c] [-g <nixpkgs path>] [-j <n>] [-C <n>] [-p <yes|no>] -u <url>") -y Don't ask before executing things (optional) (not implemented yet) -b Also test-build the package (optional) @@ -22,6 +22,7 @@ usage() { -d Don't checkout base branch after successfull run. -j <n> Pass "-j <n>" to nix-build -C <n> Pass "--cores <n>" to nix-build + -p <yes|no> Do a git-push after successful run. (remote specified in config file) -h Show this help and exit Helper for developers of Nix packages. @@ -49,9 +50,11 @@ usage() { # Verbosity is on. nix-script -v update-package-def -b -u http://monitor.nixos.org/patch?p=ffmpeg-full&v=2.7.1&m=Matthias+Beyer -$(help_rcvars \ - "RC_UPD_NIX_BUILD_J - Default number to pass to 'nix-build -j'" - "RC_UPD_NIX_BUILD_CORES - Default number to pass to 'nix-build --cores'" +$(help_rcvars \ + "RC_UPD_NIX_BUILD_J - Default number to pass to 'nix-build -j'" \ + "RC_UPD_NIX_BUILD_CORES - Default number to pass to 'nix-build --cores'" \ + "RC_UPD_PUSH - Set to 1 to enable git-push after applying the patch (and building it)"\ + "RC_UPD_PUSH_REMOTE - git remote(s) to push to" ) $(help_end "${BASH_SOURCE[0]}") @@ -66,8 +69,9 @@ CHECKOUT=1 DONT_CHECKOUT_BASE= J="$RC_UPD_NIX_BUILD_J" CORES="$RC_UPD_NIX_BUILD_CORES" +DO_PUSH= -while getopts "ybu:g:cdj:C:h" OPTION +while getopts "ybu:g:cdj:C:p:h" OPTION do case $OPTION in y) @@ -110,6 +114,12 @@ do stderr "CORES = $CORES" ;; + p) + [[ "$OPTARG" == "yes" ]] && DO_PUSH=1 + [[ "$OPTARG" == "no" ]] && DO_PUSH=0 + stdout "DO_PUSH = $DO_PUSH" + ;; + h) usage exit 0 @@ -189,6 +199,30 @@ then fi # +# If the config says yes and is not overridden +# OR +# If the config is overridden with yes +# +if [[ ($RC_UPD_PUSH -eq 1 && -z "$DO_PUSH") || ! -z "$DO_PUSH" && $DO_PUSH -eq 1 ]] +then + dbg "RC_UPD_PUSH enabled or overridden" + dbg "Starting performing git-push" + + if [[ ! -z "$RC_UPD_PUSH_REMOTE" ]] + then + __git "$NIXPKGS" push $RC_UPD_PUSH_REMOTE + stdout "git-push done" + else + stderr "Cannot git-push: No remote set in configuration" + stderr "Aborting git-push." + continue_question "Continue execution?" || exit 1 + fi + +else + dbg "git-push won't be performed" +fi + +# # If we checked out a new branch, we go back, too. # if [[ $CHECKOUT == 1 && -z "$DONT_CHECKOUT_BASE" ]] |