Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab-ci
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Clea OS
infrastructure
gitlab-ci
Commits
36019d1e
Commit
36019d1e
authored
3 years ago
by
Felix Gerking
Browse files
Options
Downloads
Patches
Plain Diff
package_release: Improve md5sums.txt file creation
Now md5sums.txt can be assembled from different copy processes.
parent
7ee49064
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package_release.py
+42
-32
42 additions, 32 deletions
package_release.py
with
42 additions
and
32 deletions
package_release.py
+
42
−
32
View file @
36019d1e
...
...
@@ -20,6 +20,30 @@ def md5(fname):
return
hash_md5
.
hexdigest
()
def
write_md5sums_file
(
md5sums
,
subdir
,
output_dir
,
outlocal_dir
):
with
tempfile
.
TemporaryDirectory
()
as
tmp
:
source_file
=
os
.
path
.
join
(
tmp
,
subdir
,
"
md5sums.txt
"
)
os
.
makedirs
(
os
.
path
.
dirname
(
source_file
),
exist_ok
=
True
)
with
open
(
source_file
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f_md5
:
for
f
,
h
in
md5sums
.
items
():
f_md5
.
write
(
"
{} {}
\n
"
.
format
(
h
,
f
))
if
output_dir
is
not
None
:
target_file
=
os
.
path
.
join
(
output_dir
,
subdir
,
os
.
path
.
basename
(
source_file
)
)
print
(
"
Copy: %s -> %s
"
%
(
source_file
,
target_file
))
shutil
.
copyfile
(
source_file
,
target_file
,
follow_symlinks
=
True
)
if
outlocal_dir
is
not
None
:
target_file
=
os
.
path
.
join
(
outlocal_dir
,
subdir
,
os
.
path
.
basename
(
source_file
)
)
print
(
"
Copy: %s -> %s
"
%
(
source_file
,
target_file
))
shutil
.
copyfile
(
source_file
,
target_file
,
follow_symlinks
=
True
)
def
copy_files
(
files
,
input_dir
,
subdir
,
output_dir
,
outlocal_dir
):
md5sums
=
{}
if
output_dir
is
not
None
:
...
...
@@ -49,28 +73,6 @@ def copy_files(files, input_dir, subdir, output_dir, outlocal_dir):
else
:
print
(
"
Missing:
"
+
source_file
)
# Write md5sums file:
with
tempfile
.
TemporaryDirectory
()
as
tmp
:
source_file
=
os
.
path
.
join
(
tmp
,
subdir
,
"
md5sums.txt
"
)
os
.
makedirs
(
os
.
path
.
dirname
(
source_file
),
exist_ok
=
True
)
with
open
(
source_file
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f_md5
:
for
f
,
h
in
md5sums
.
items
():
f_md5
.
write
(
"
{} {}
\n
"
.
format
(
h
,
f
))
if
output_dir
is
not
None
:
target_file
=
os
.
path
.
join
(
output_dir
,
subdir
,
os
.
path
.
basename
(
source_file
)
)
print
(
"
Copy: %s -> %s
"
%
(
source_file
,
target_file
))
shutil
.
copyfile
(
source_file
,
target_file
,
follow_symlinks
=
True
)
if
outlocal_dir
is
not
None
:
target_file
=
os
.
path
.
join
(
outlocal_dir
,
subdir
,
os
.
path
.
basename
(
source_file
)
)
print
(
"
Copy: %s -> %s
"
%
(
source_file
,
target_file
))
shutil
.
copyfile
(
source_file
,
target_file
,
follow_symlinks
=
True
)
return
md5sums
...
...
@@ -257,26 +259,34 @@ def main():
artifacts_all
.
append
(
artifact
.
split
(
"
.
"
)[
0
]
+
"
.manifest
"
)
artifacts_all
.
append
(
artifact
.
split
(
"
.
"
)[
0
]
+
"
.testdata.json
"
)
md5sums
=
copy_files
(
artifacts_all
,
args
.
images_dir
,
machine
,
output_dir
,
outlocal_dir
)
# If the path for the licenses is set, we check for the list with all
# licenses. If the list is found, we copy it to the output directory
# and also add it to the artifacts dictionary.
license_manifest
=
None
if
args
.
licenses_dir
is
not
None
and
os
.
path
.
isdir
(
args
.
licenses_dir
):
manifest
=
glob
.
glob
(
license_
manifest
=
glob
.
glob
(
os
.
path
.
join
(
args
.
licenses_dir
,
"
**
"
,
"
license.manifest
"
)
)
if
manifest
:
copy_files
(
[
"
license.manifest
"
],
os
.
path
.
dirname
(
manifest
[
0
]),
machine
,
output_dir
,
outlocal_dir
,
if
license_manifest
:
md5sums
.
update
(
copy_files
(
[
"
license.manifest
"
],
os
.
path
.
dirname
(
license_manifest
[
0
]),
machine
,
output_dir
,
outlocal_dir
,
)
)
artifacts_all
.
append
(
"
license.manifest
"
)
md5sums
=
copy_files
(
artifacts_all
,
args
.
images_dir
,
machine
,
output_dir
,
outlocal_dir
# Everything copied? Create md5sums file
write_md5sums_file
(
md5sums
,
machine
,
output_dir
,
outlocal_dir
)
# Generate metadata
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment