|  | @@ -10,11 +10,12 @@ die() {
 | 
	
		
			
			| 10 | 10 |  }
 | 
	
		
			
			| 11 | 11 |  
 | 
	
		
			
			| 12 | 12 |  usage() {
 | 
	
		
			
			| 13 |  | -    warn "usage: $0 [options] COPR_PROJECT"
 | 
	
		
			
			|  | 13 | +    warn "usage: $0 [options] MODE"
 | 
	
		
			
			| 14 | 14 |      warn ""
 | 
	
		
			
			| 15 | 15 |      warn "Options:"
 | 
	
		
			
			| 16 | 16 |      warn ""
 | 
	
		
			
			| 17 | 17 |      warn "  -b BRN  build from branch BRN (default: last tag)"
 | 
	
		
			
			|  | 18 | +    warn "  -c COPR_PROJECT  COPR project name"
 | 
	
		
			
			| 18 | 19 |      warn "  -n      dry mode, don't do anything (just show"
 | 
	
		
			
			| 19 | 20 |      warn "          what would be done)"
 | 
	
		
			
			| 20 | 21 |      warn "  -r REL  use REL as Release number in SPEC file"
 | 
	
	
		
			
			|  | @@ -29,6 +30,9 @@ usage() {
 | 
	
		
			
			| 29 | 30 |      warn "If -b is used, the project repo is temporarily clonded, and"
 | 
	
		
			
			| 30 | 31 |      warn "both Version and Release are found by consulting git-describe"
 | 
	
		
			
			| 31 | 32 |      warn "on the specified branch."
 | 
	
		
			
			|  | 33 | +    warn ""
 | 
	
		
			
			|  | 34 | +    warn "If MODE is 'scratch' (default), Release is pre-fixed by string"
 | 
	
		
			
			|  | 35 | +    warn "'0.scratch.' and build is triggered in scratch COPR project."
 | 
	
		
			
			| 32 | 36 |      exit 2
 | 
	
		
			
			| 33 | 37 |  }
 | 
	
		
			
			| 34 | 38 |  
 | 
	
	
		
			
			|  | @@ -82,6 +86,24 @@ git_guess() {
 | 
	
		
			
			| 82 | 86 |      esac
 | 
	
		
			
			| 83 | 87 |  }
 | 
	
		
			
			| 84 | 88 |  
 | 
	
		
			
			|  | 89 | +choose_copr() {
 | 
	
		
			
			|  | 90 | +    #
 | 
	
		
			
			|  | 91 | +    # Choose COPR project based on $Mode
 | 
	
		
			
			|  | 92 | +    #
 | 
	
		
			
			|  | 93 | +    case $Mode in
 | 
	
		
			
			|  | 94 | +        scratch) echo amahdal/slop-scratch ;;
 | 
	
		
			
			|  | 95 | +        main)    echo amahdal/slop         ;;
 | 
	
		
			
			|  | 96 | +    esac
 | 
	
		
			
			|  | 97 | +}
 | 
	
		
			
			|  | 98 | +
 | 
	
		
			
			|  | 99 | +choose_relpfx() {
 | 
	
		
			
			|  | 100 | +    #
 | 
	
		
			
			|  | 101 | +    # Choose COPR project based on $Mode
 | 
	
		
			
			|  | 102 | +    #
 | 
	
		
			
			|  | 103 | +    test "$Mode" == scratch && echo 0.scratch.
 | 
	
		
			
			|  | 104 | +    return 0
 | 
	
		
			
			|  | 105 | +}
 | 
	
		
			
			|  | 106 | +
 | 
	
		
			
			| 85 | 107 |  main() {
 | 
	
		
			
			| 86 | 108 |      local Version       # Version in SPEC file
 | 
	
		
			
			| 87 | 109 |      local Release       # Release in SPEC file
 | 
	
	
		
			
			|  | @@ -90,12 +112,14 @@ main() {
 | 
	
		
			
			| 90 | 112 |      local Tmp           # our temp
 | 
	
		
			
			| 91 | 113 |      local Branch        # branch to use, if empty, tags are considered
 | 
	
		
			
			| 92 | 114 |      local DryRun=false  # do not do anything
 | 
	
		
			
			|  | 115 | +    local Mode=scratch  # implies COPR project and release prefix
 | 
	
		
			
			| 93 | 116 |      which copr >/dev/null \
 | 
	
		
			
			| 94 | 117 |       || die "copr not found, try 'sudo install copr-cli'"
 | 
	
		
			
			| 95 | 118 |      UrlBase=https://github.com/AloisMahdal/slop
 | 
	
		
			
			| 96 | 119 |      Tmp=$(mktemp -d)
 | 
	
		
			
			| 97 | 120 |      while true; do case $1 in
 | 
	
		
			
			| 98 | 121 |          -b) Branch=$2;      shift 2 || usage ;;
 | 
	
		
			
			|  | 122 | +        -c) CoprProject=$2; shift 2 || usage ;;
 | 
	
		
			
			| 99 | 123 |          -u) UrlBase=$2;     shift 2 || usage ;;
 | 
	
		
			
			| 100 | 124 |          -r) Release=$2;     shift 2 || usage ;;
 | 
	
		
			
			| 101 | 125 |          -v) Version=${2#v}; shift 2 || usage ;;
 | 
	
	
		
			
			|  | @@ -103,8 +127,12 @@ main() {
 | 
	
		
			
			| 103 | 127 |          -*) usage ;;
 | 
	
		
			
			| 104 | 128 |          *)  break ;;
 | 
	
		
			
			| 105 | 129 |      esac done
 | 
	
		
			
			| 106 |  | -    CoprProject=$1
 | 
	
		
			
			| 107 |  | -    test -n "$CoprProject" || usage
 | 
	
		
			
			|  | 130 | +    Mode=${1:-$Mode}
 | 
	
		
			
			|  | 131 | +    case $Mode in
 | 
	
		
			
			|  | 132 | +        main|scratch) : ;;
 | 
	
		
			
			|  | 133 | +        *)            usage ;;
 | 
	
		
			
			|  | 134 | +    esac
 | 
	
		
			
			|  | 135 | +    test -n "$CoprProject" || CoprProject=$(choose_copr)
 | 
	
		
			
			| 108 | 136 |      if test -n "$Branch"; then
 | 
	
		
			
			| 109 | 137 |          die "not implemented"
 | 
	
		
			
			| 110 | 138 |          test -n "$Version" || Version=$(git_guess ver)
 | 
	
	
		
			
			|  | @@ -113,6 +141,7 @@ main() {
 | 
	
		
			
			| 113 | 141 |          test -n "$Version" || Version=$(last_version)
 | 
	
		
			
			| 114 | 142 |          test -n "$Release" || Release=1
 | 
	
		
			
			| 115 | 143 |      fi
 | 
	
		
			
			|  | 144 | +    Release=$(choose_relpfx)$Release
 | 
	
		
			
			| 116 | 145 |      mkspec >"$Tmp/slop.spec"
 | 
	
		
			
			| 117 | 146 |      $DryRun && {
 | 
	
		
			
			| 118 | 147 |          warn "dry mode active, we would build:"
 |