-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathcfg.py
490 lines (422 loc) · 20.4 KB
/
cfg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
header = '''# GENERATED FILE - DO NOT EDIT
set -e
'''
clear_lst = '''for f in __envsub/{files_,Media}*.lst; do
[ ! -f "$f" ] || : > "$f"
done
[ ! -f __envdir/../rsync.secret ] || rsync_pwd_option=--password-file=__envdir/../rsync.secret
'''
read_files_curl = '''curl -s PRODUCTPATH/ | grep -o 'ISOMASK' | head -n 1 >> __envsub/files_iso.lst'''
read_files_hdd = '''rsync -4 --list-only $rsync_pwd_option PRODUCTPATH/FOLDER/ | grep -o 'ISOMASK' | awk '{ $1=$2=$3=$4=""; print substr($0,5); }' | grep -E 'ARCHORS' >> __envsub/files_iso.lst
'''
read_files_iso = '''rsync -4 --list-only $rsync_pwd_option PRODUCTISOPATH/FOLDER/*SRCISO* | grep -P 'Media1?.iso$' | awk '{ $1=$2=$3=$4=""; print substr($0,5); }' >> __envsub/files_iso.lst
'''
read_files_isos = '''rsync -4 --list-only $rsync_pwd_option PRODUCTISOPATH/ | grep -P 'Media1?.iso$' | grep -E 'ARCHORS' | awk '{ $1=$2=$3=$4=""; print substr($0,5); }' >> __envsub/files_iso.lst
'''
read_files_repo = '''rsync -4 --list-only $rsync_pwd_option PRODUCTREPOPATH/ | grep -P 'Media[1-3](.license)?$' | awk '{ $1=$2=$3=$4=""; print substr($0,5); } ' | grep -v IGNOREPATTERN | grep -E 'REPOORS' | grep -E 'ARCHORS' >> __envsub/files_repo.lst
'''
read_files_repo_media = '''rsync -4 $rsync_pwd_option PRODUCTREPOPATH/*Media1/media.1/media __envsub/Media1.lst'''
read_files_repo_media_convert = ''' && echo "Snapshot$(grep -oP '[\d]{8}' __envsub/products)" >> __envsub/destlst'''
read_files_repo_link = '''cp __envdir/REPOLINK/files_repo*.lst __envsub/
'''
read_files_repo_link2 = '''cp __envdir/REPOLINK/files_iso_buildid.lst __envsub/
'''
read_files_repo_link3 = '''cp __envdir/REPOLINK/files_iso*.lst __envsub/
'''
def rsync_fix_dest(distri, version, staging, use_staging_patterns):
if not staging: return ''
if use_staging_patterns: return '''
staging_pattern=$flavor
[ -z "${flavor_staging[$staging_pattern]}" ] || staging_pattern="${flavor_staging[$staging_pattern]}"
dest=${dest//$staging_pattern/Staging:__STAGING-$staging_pattern}'''
if version != 'Factory' and len(staging) == 1: return '''dest=${dest//$flavor/Staging:__STAGING-Staging-$flavor}'''
return '''dest=${dest//$flavor/Staging:__STAGING-$flavor}'''
def rsync_iso_fix_src(archs):
if 'armv7hl' in archs and not 'armv7l' in archs:
return '[ -n "$src" ] || [ "$arch" != armv7hl ] || src=$(grep "$filter" __envsub/files_iso.lst | grep armv7l | head -n 1)'
return ''
def rsync_commands(checksum):
res = '''echo "rsync --timeout=3600 -tlp4 --specials PRODUCTISOPATH/${iso_folder[$flavor]}*$src /var/lib/openqa/factory/$asset_folder/$dest"'''
if checksum:
res = res + '''
echo "rsync --timeout=3600 -tlp4 --specials PRODUCTISOPATH/${iso_folder[$flavor]}*$src.sha256 /var/lib/openqa/factory/other/$dest.sha256"'''
return res
rsync_iso = lambda distri, version, archs, staging, checksum, repo0folder, use_staging_patterns: '''
archs=(ARCHITECTURS)
for flavor in {FLAVORLIST,}; do
for arch in "${archs[@]}"; do
filter=$flavor
[ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
[[ ${norsync_filter[$filter]} != 1 ]] || continue
src=$(grep "$filter" __envsub/files_iso.lst | grep $arch | head -n 1)
''' + rsync_iso_fix_src(archs) + '''
[ ! -z "$src" ] || continue
dest=$src
''' + rsync_fix_dest(distri, version, staging, use_staging_patterns) + '''
asset_folder=other
[[ ! $dest =~ \.iso$ ]] || asset_folder=iso
[[ ! $dest =~ \.spdx\.json$ ]] || asset_folder=iso
[[ ! $dest =~ \.tar$ ]] || asset_folder=iso
[[ ! $dest =~ \.(qcow2|raw|vhd|vmdk|vhdx|xz)$ ]] || asset_folder=hdd
''' + rsync_commands(checksum) + '''
repo0folder=${dest%.iso}
repo0folder=${repo0folder%.tar}
''' + (repo0folder if repo0folder else "") + '''
[ -z "FLAVORASREPOORS" ] || [ $( echo "$flavor" | grep -E -c "^(FLAVORASREPOORS)$" ) -eq 0 ] || echo "[ -d /var/lib/openqa/factory/repo/$repo0folder ] || {
mkdir /var/lib/openqa/factory/repo/$repo0folder
bsdtar xf /var/lib/openqa/factory/iso/$dest -C /var/lib/openqa/factory/repo/$repo0folder
}"
[ -z "FLAVORTOREPOORS" ] || [ $( echo "$flavor" | grep -E -c "^(FLAVORTOREPOORS)$" ) -eq 0 ] || echo "cp -l /var/lib/openqa/factory/iso/$dest /var/lib/openqa/factory/repo/"
done
done'''
rsync_hdds = '''
archs=(ARCHITECTURS)
for flavor in {FLAVORLIST,}; do
for arch in "${archs[@]}"; do
while read src; do
folder=""
for i in "${!hdd_folder[@]}"; do
if [[ $src =~ $i ]]; then
folder="${hdd_folder[$i]}"
break
fi
done
[[ $src =~ .iso$ ]] && asset="iso" || asset="hdd"
echo "rsync --timeout=3600 -tlp4 --specials PRODUCTISOPATH/$folder/$src /var/lib/openqa/factory/$asset/"
echo "rsync --timeout=3600 -tlp4 --specials PRODUCTISOPATH/$folder/$src.sha256 /var/lib/openqa/factory/other/"
echo ""
done < <(grep ${arch} __envsub/files_iso.lst | sort)
done
done'''
def pre_rsync_repo(repos):
return ''
rsync_repo1 = '''
echo '# REPOOWNLIST'
[ ! -f __envsub/files_iso.lst ] || buildid=$(cat __envsub/files_iso.lst | grep -E 'FLAVORORS' | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
[ ! -f __envsub/files_iso.lst ] || test -n "$buildid" || buildid=$(cat __envsub/files_iso.lst | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
[ -z "__STAGING" ] || buildid=${buildid//Build/Build__STAGING.}
[ ! -f __envsub/files_repo.lst ] || ! grep -q -- "-POOL-" __envsub/files_repo.lst || additional_repo_suffix=-POOL
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+(.[0-9]+)?' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
buildid=${buildid/.iso}
for repo in {REPOOWNLIST,}; do
while read src; do
[ ! -z "$src" ] || continue
dest=$src
destPrefix=${dest%-Media*}
destSuffix=${dest#$destPrefix}
dest=$destPrefix
'''
rsync_repo2 = '''
destPrefix=$dest
repoDest=$destPrefix-$buildid$destSuffix
repoCur=$destPrefix-CURRENT$destSuffix
[ -z "__STAGING" ] || repoCur=$destPrefix-__STAGING-CURRENT$destSuffix
echo "rsync --timeout=3600 -rtlp4 --delete --specials PRODUCTREPOPATH/$src/ /var/lib/openqa/factory/repo/$repoCur"
echo "rsync --timeout=3600 -rtlp4 --delete --specials --link-dest /var/lib/openqa/factory/repo/$repoCur/ /var/lib/openqa/factory/repo/$repoCur/ /var/lib/openqa/factory/repo/$repoDest/"
done < <(grep $repo$additional_repo_suffix __envsub/files_repo.lst)
done
'''
rsync_repodir1 = '''
archs=(ARCHITECTURREPO)
for arch in "${archs[@]}"; do
[ ! -f __envsub/files_iso.lst ] || buildid=$(cat __envsub/files_iso.lst | grep $arch | grep -E 'FLAVORORS' | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+(.[0-9]+)?' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
if [[ ! -n $build ]] && [[ ! $buildid =~ (Build|Snapshot)[0-9]*[0-9]$ ]]; then
buildid=${buildid%%\.[[:alpha:]]*}
fi
while read src; do
[ ! -z "$src" ] || continue
dest=$src
dest=${dest%-Build*}
destPrefix=${dest%$arch*}
destSuffix=${dest#$destPrefix}
mid=''
dest=$destPrefix$mid$destSuffix
[[ ! $src =~ .*\.license ]] || [[ $dest == *license* ]] || dest=$dest.license'''
def rsync_repodir2():
return '''
dest=${dest//-Media2/}
Mdia=Media2
[[ ! $src =~ .*\.license ]] || Mdia=Media2.license
echo rsync --timeout=3600 -rtlp4 --delete --specials RSYNCFILTER PRODUCTREPOPATH/*$Mdia/ /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/
echo rsync --timeout=3600 -rtlp4 --delete --specials --link-dest /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/ /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/ /var/lib/openqa/factory/repo/$dest-$buildid-debuginfo
done < <(grep ${arch//i686/i586} __envsub/files_repo.lst | grep Media2 )
done
'''
rsync_repodir1_dest = lambda dest: '''
archs=(ARCHITECTURREPO)
buildid=$(cat __envsub/files_iso.lst | grep -E 'FLAVORORS' | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
for arch in "${archs[@]}"; do
while read src; do
[ ! -z "$src" ] || continue
[[ ''' + dest + ''' =~ $arch ]] || [[ ''' + dest + ''' =~ ${arch//i686/i586} ]] || [[ "ARCHITECTURREPO" == . ]] || break
dest=''' + dest + '''
[[ ! $src =~ .*\.license ]] || dest=$dest.license'''
def openqa_call_fix_destiso(distri, version, staging):
if not staging:
return ''
if (version == 'Factory' or len(staging)>1):
return '''destiso=${iso//$flavor/Staging:__STAGING-$flavor}
flavor=Staging-$flavor'''
return '''version=${version}:S:__STAGING
destiso=${iso//$flavor/Staging:__STAGING-Staging-$flavor}
flavor=Staging-$flavor'''
def openqa_call_start_fix_iso(archs):
if 'armv7hl' in archs and not 'armv7l' in archs:
return '[ -n "$iso" ] || [ "$arch" != armv7hl ] || iso=$(grep "$filter" __envsub/files_iso.lst | grep armv7l | head -n 1)'
return ''
def openqa_call_news(news, news_archs):
if not news:
return ''
news_str = '''[[ ! "$flavor" =~ ''' + news + ''' ]]'''
if news_archs:
news_str += ''' || [ "$arch" != ''' + news_archs + ''' ]'''
return news_str + ''' || news["$flavor"]="$destiso"'''
def openqa_call_start_distri(flavor_distri):
if flavor_distri:
return '''distri=DISTRIVALUE
[ -z "${flavor_distri[$flavor]}" ] || distri=${flavor_distri[$flavor]}'''
return 'distri=DISTRIVALUE'
def openqa_call_start_meta_variables(meta_variables):
if not meta_variables:
return 'VERSION=$version\"'
return '''VERSION=$version \\\\
''' + meta_variables + '\"'
def pre_openqa_call_start(repos):
return ''
openqa_call_start = lambda distri, version, archs, staging, news, news_archs, flavor_distri, meta_variables, assets_flavor, repo0folder, openqa_cli: '''
archs=(ARCHITECTURS)
[ ! -f __envsub/files_repo.lst ] || ! grep -q -- "-POOL-" __envsub/files_repo.lst || additional_repo_suffix=-POOL
for flavor in {FLAVORALIASLIST,}; do
for arch in "${archs[@]}"; do
filter=$flavor
''' + openqa_call_start_distri(flavor_distri) + '''
[ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
[ $filter != Appliance ] || filter="qcow2"
version=VERSIONVALUE
if [ -z "${norsync_filter[$flavor]}" ] || [ -z $build1 ]; then {
iso=$(grep "$filter" __envsub/files_iso.lst 2>/dev/null | grep $arch | head -n 1)
''' + openqa_call_start_fix_iso(archs) + '''
build=$(echo $iso | grep -o -E '(Build|Snapshot)[^-]*' | grep -o -E '[0-9]\.?[0-9]+(\.[0-9]+)*' | tail -n 1) || :
buildex=$(echo $iso | grep -o -E '(Build|Snapshot)[^-]*') || :
[ -n "$iso" ] || [ "$flavor" != "''' + assets_flavor + '''" ] || build=$(grep -o -E '(Build|Snapshot)[^-]*' __envsub/files_asset.lst | grep -o -E '[0-9]\.?[0-9]+(\.[0-9]+)*' | head -n 1)
[ -n "$iso" ] || [ "$flavor" != "''' + assets_flavor + '''" ] || buildex=$(grep -o -E '(Build|Snapshot)[^-]*' __envsub/files_asset.lst | head -n 1)
[ -n "$iso$build" ] || build=$(grep -h -o -E '(Build|Snapshot)[^-]*' __envsub/Media1*.lst 2>/dev/null | head -n 1 | grep -o -E '[0-9]\.?[0-9]+(\.[0-9]+)*')|| :
[ -n "$build" ] || continue
buildex=${buildex/.install.iso/}
buildex=${buildex/.iso/}
buildex=${buildex/.raw.xz/}
buildex=${buildex/.qcow2/}
build1=$build
destiso=$iso
[ -z "__STAGING" ] || build1=__STAGING.$build
''' + openqa_call_fix_destiso(distri, version, staging) + '''
repo0folder=${destiso%.iso}
repo0folder=${repo0folder%.tar}
''' + (repo0folder if repo0folder else "") + '''
[ "$arch" != . ] || arch=x86_64
''' + openqa_call_news(news, news_archs) + '''
}
fi
echo "''' + openqa_cli + ''' \\\\\"
(
echo \" DISTRI=$distri \\\\
ARCH=$arch \\\\
BUILD=$build1 \\\\
''' + openqa_call_start_meta_variables(meta_variables)
openqa_call_legacy_builds_link=''
openqa_call_legacy_builds=''
def openqa_call_start_iso(checksum):
if checksum:
return ''' [ -z "$destiso" ] || echo \" ISO=${destiso} \\\\
CHECKSUM_ISO=\$(cut -b-64 /var/lib/openqa/factory/other/${destiso}.sha256 | grep -E '[0-9a-f]{5,40}' | head -n1) \\\\
ASSET_256=${destiso}.sha256 \\\\\"'''
return ''' [ -z "$destiso]" || echo \" ISO=${destiso} \\\\
ASSET_256=${destiso}.sha256 \\\\\"'''
def openqa_call_start_ex1(checksum, tag):
res = tag + '=${destiso} \\\\'
if checksum:
res += '''
CHECKSUM_''' + tag + '''=\$(cut -b-64 /var/lib/openqa/factory/other/${destiso}.sha256 | grep -E '[0-9a-f]{5,40}' | head -n1) \\\\
ASSET_256=${destiso}.sha256 \\\\'''
return res
def openqa_call_start_ex(checksum):
return ''' if [[ ${norsync_filter[$filter]} == 1 ]]; then
:
elif [[ $destiso =~ \.iso$ ]]; then
echo \" ''' + openqa_call_start_ex1(checksum, 'ISO') + '''\"
elif [[ $destiso =~ \.spdx.json$ ]]; then
echo \" ''' + openqa_call_start_ex1(checksum, 'ISO') + '''\"
elif [[ $destiso =~ \.tar$ ]]; then
echo \" ''' + openqa_call_start_ex1(checksum, 'ISO') + '''\"
elif [[ $destiso =~ \.(hdd|qcow2|raw|raw\.xz|raw\.gz|vhdx\.xz|vmdk|vmdk\.xz)$ ]]; then
echo \" ''' + openqa_call_start_ex1(checksum, 'HDD_1') + '''\"
elif [ -n "$destiso" ]; then
echo \" ''' + openqa_call_start_ex1(checksum, 'ASSET_1') + '''\"
fi
'''
openqa_call_start_hdds='''
i=1
while read src; do
folder=""
for mask in "${!hdd_folder[@]}"; do
if [[ $src =~ $mask ]]; then
folder="${hdd_folder[$mask]}"
break
fi
done
n=$((i++))
echo " ASSET_$((n+255))=$src.sha256 \\\\"
if [[ $src =~ .iso$ ]]; then
echo " ISO=$src \\\\"
echo " CHECKSUM_ISO=\$(cut -b-64 /var/lib/openqa/factory/other/$src.sha256 | grep -E '[0-9a-f]{5,40}' | head -n1) \\\\"
else
echo " HDD_$n=$src \\\\"
echo " CHECKSUM_HDD_$n=\$(cut -b-64 /var/lib/openqa/factory/other/$src.sha256 | grep -E '[0-9a-f]{5,40}' | head -n1) \\\\"
fi
done < <(grep ${arch} __envsub/files_iso.lst | sort)
'''
# if MIRROREPO is set - expressions for FLAVORASREPOORS will evaluate to false
def openqa_call_repo0():
return ''' [ -z "FLAVORASREPOORSMIRRORREPO" ] || [ $( echo "$flavor" | grep -E -c "^(FLAVORASREPOORS)$" ) == 0"MIRRORREPO" ] || {
echo " MIRROR_PREFIX=http://openqa.opensuse.org/assets/repo \\\\
SUSEMIRROR=http://openqa.opensuse.org/assets/repo/REPO0_ISO \\\\
MIRROR_HTTP=http://openqa.opensuse.org/assets/repo/REPO0_ISO \\\\
MIRROR_HTTPS=https://openqa.opensuse.org/assets/repo/REPO0_ISO \\\\
FULLURL=1 \\\\"
}'''
openqa_call_repo0a = ' [ -z "FLAVORASREPOORS" ] || [ $( echo "$flavor" | grep -E -c "^(FLAVORASREPOORS)$" ) -eq 0 ] || '
openqa_call_repo0b = ' echo " REPO_0=REPO0_ISO \\\\"'
openqa_call_repo5 = ''' destRepo=${destiso%.iso}
filter1=${filter//-DVD/-POOL}
destRepo=${destRepo//$filter/$filter1}
echo " REPO_5=$destRepo \\\\
REPO_6=$destRepo.license \\\\
REPO_REPOALIAS=$destRepo \\\\"
'''
def openqa_call_repot_part1():
return '''[ -z "__STAGING" ] || repo=${repo//Module/Staging:__STAGING-Module}
[ -z "__STAGING" ] || repo=${repo//Product/Staging:__STAGING-Product}'''
def openqa_call_repot_part2():
return 'repoDest=$repoPrefix-Build$build$repoSuffix'
def openqa_call_repot_part3():
return '''[[ $repoDest != *Media2* ]] || repoKey=${repoKey}_DEBUG
[[ $repoDest != *Media3* ]] || repoKey=${repoKey}_SOURCE'''
def openqa_call_build_id_from_iso1(build_id_from_iso):
if not build_id_from_iso:
return ""
return '''build2=$(grep $repot __envsub/files_iso_buildid.lst | grep $arch | grep -o -E '(Build|Snapshot)[^-]*' | grep -o -E '[0-9]+.?[0-9]+(\.[0-9]+)?' | head -n 1)
[ -z "$build2" ] || build1=$build2'''
def openqa_call_build_id_from_iso2(build_id_from_iso):
if not build_id_from_iso:
return ""
return '''[ "$repoKey" != LIVE_PATCHING ] || repoKey=LIVE
[[ $repoDest != *Media1* ]] || [[ $repo =~ license ]] || [ -z "$build2" ] || echo " BUILD_$repoKey=$build2 \\\\"'''
def openqa_call_extra(repos):
return ''
openqa_call_repot = lambda build_id_from_iso, repos: '''
for repot in {REPOLIST,}; do
while read repo; do
''' + openqa_call_repot_part1() + '''
repoPrefix=${repo%-Media*}
repoSuffix=${repo#$repoPrefix}
''' + openqa_call_build_id_from_iso1(build_id_from_iso) + '''
''' + openqa_call_repot_part2() + '''
repoKey=${repot}
repoKey=${repoKey^^}
repoKey=${repoKey//-/_}
repoKey=${repoKey//./_}
repoKey=${repoKey//$/}
echo " REPO_$i=$repoDest \\\\"
''' + openqa_call_repot_part3() + '''
''' + openqa_call_build_id_from_iso2(build_id_from_iso) + '''
[[ $repo =~ license ]] || echo " REPO_REPOPREFIX$repoKey=$repoDest \\\\"
''' + openqa_call_extra(repos) + '''
: $((i++))
done < <(grep $repot$additional_repo_suffix __envsub/files_repo.lst | grep REPOTYPE | grep $arch | sort)
done'''
def openqa_call_repot1_debugsource():
return '''[[ $src != *Media2* ]] || repoKey=${repoKey}_DEBUGINFO
[[ $src != *Media2* ]] || dest=$dest-debuginfo
[[ $src != *Media3* ]] || repoKey=${repoKey}_SOURCE
[[ $src != *Media3* ]] || dest=$dest-source'''
openqa_call_repot1 = lambda: '''
while read src; do
dest=$src
dest=${dest%-Build*}
dest=${dest%.license}
destPrefix=${dest%$arch*}
destSuffix=${dest#$destPrefix}
mid=''
dest=$destPrefix$mid$destSuffix
repoPrefix=${dest%-Media*}
repoSuffix=${dest#$repoPrefix}
[[ ! $src =~ .license ]] || repoPrefix=$repoPrefix.license
B=$(grep -oE "Build|Snapshot" __envsub/files_iso.lst 2>/dev/null | head -1)
[ ! -z "$B" ] || B=Build
dest=$repoPrefix-$B$build$repoSuffix
repoKey=REPOKEY
repoKey=${repoKey^^}
repoKey=${repoKey//-/_}
repoKey=${repoKey//./_}
repoKey=${repoKey//$/}
''' + openqa_call_repot1_debugsource() + '''
dest=${dest//-Media1/}
dest=${dest//-Media2/}
dest=${dest//-Media3/}
'''
openqa_call_repot2 = '''
echo " REPO_$i=$dest \\\\"
[[ $src =~ license ]] || echo " REPO_$repoKey=$dest \\\\"
[[ ! $repoKey =~ _DEBUGINFO ]] || [ -z "DEBUG_PACKAGES" ] || echo " REPO_${{repoKey}}_PACKAGES='DEBUG_PACKAGES' \\\\"
[[ ! $repoKey =~ _SOURCE ]] || [ -z "SOURCE_PACKAGES" ] || echo " REPO_${{repoKey}}_PACKAGES='SOURCE_PACKAGES' \\\\"
: $((i++))
done < <(grep ${{arch//i686/i586}} __envsub/files_repo.lst {} | sort)'''
openqa_call_repot1_dest = lambda dest: '''
while read src; do
[[ ''' + dest + ''' =~ $arch ]] || [[ ''' + dest + ''' =~ ${arch//i686/i586} ]] || [[ "ARCHITECTURREPO" == . ]] || break
dest=''' + dest + '''
[[ ! $src =~ .*\.license ]] || dest=$dest.license
dest=$dest-$buildex
repoKey=REPOKEY
''' + openqa_call_repot1_debugsource() + '''
repoKey=${repoKey^^}
repoKey=${repoKey//-/_}
repoKey=${repoKey//./_}
repoKey=${repoKey//$/}
'''
def openqa_call_news_end(distri, news, news_arch):
if not news:
return ''
suff = ''
if news_arch and news_arch != 'x86_64':
suff = '-' + news_arch
folder='${n,,}'
if distri != 'microos':
folder = 'opensuse'
return '''for n in "${!news[@]}"; do
folder=''' + folder + '''
folder=${folder%-dvd}''' + suff + '''
echo /var/lib/openqa/osc-plugin-factory/factory-package-news/factory-package-news.py save --dir /var/lib/snapshot-changes/$folder/VERSIONVALUE --snapshot $build1 /var/lib/openqa/factory/iso/${news[$n]}
done'''
def openqa_call_end(version):
if version == 'Factory': return '''
[ $flavor != MicroOS-DVD ] || flavor=DVD
[ $flavor != Staging-MicroOS-DVD ] || flavor=Staging-DVD
echo " FLAVOR=${flavor//Tumbleweed-/} \\\\"
) | LC_COLLATE=C sort
echo ""
done
done
'''
return '''
echo " FLAVOR=$flavor \\\\"
) | LC_COLLATE=C sort
echo ""
done
done
'''
def media2_name():
return 'debug'
def media3_name():
return 'source'