Browse Source

Use modal CLI in trigger_copr

Hard-code COPR project names and switch them as well as prefix Release
tag based on mode.  This prevents from confusing builds.
Alois Mahdal 6 years ago
parent
commit
590b8250ad
1 changed files with 32 additions and 3 deletions
  1. 32
    3
      trigger_copr

+ 32
- 3
trigger_copr View File

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