Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Docker Build Images
scripts
Commits
3e325c11
Commit
3e325c11
authored
Jul 12, 2019
by
Markus Frosch
Browse files
upload: Add verbosity and --noop
parent
caf5eea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
icinga-build-upload-aptly
View file @
3e325c11
#!/usr/bin/env python
import
sys
,
os
import
sys
import
os
import
os.path
import
argparse
import
fnmatch
from
hashlib
import
sha1
...
...
@@ -69,7 +71,8 @@ def upload_checksum(files):
h
=
sha1
()
d
=
dict
()
for
file
in
files
:
d
[
file
]
=
fh
=
sha1_file
(
file
)
name
=
os
.
path
.
basename
(
file
)
d
[
name
]
=
fh
=
sha1_file
(
file
)
h
.
update
(
fh
)
return
(
h
.
hexdigest
(),
d
)
...
...
@@ -152,7 +155,7 @@ def aptly_url(url):
parser
=
argparse
.
ArgumentParser
(
description
=
'Uploading build results to an Aptly server'
)
parser
.
add_argument
(
'--server'
,
help
=
'APTLY API service to talk to (e.g. http://127.0.0.1:8080/api)'
,
default
=
os
.
environ
.
get
(
'APTLY_SERVER'
),
metavar
=
'APTLY_SERVER'
)
default
=
os
.
environ
.
get
(
'APTLY_SERVER'
,
'http://127.0.0.1:8080/api'
),
metavar
=
'APTLY_SERVER'
)
parser
.
add_argument
(
'--username'
,
help
=
'APTLY API username'
,
default
=
os
.
environ
.
get
(
'APTLY_USERNAME'
),
metavar
=
'APTLY_USERNAME'
)
parser
.
add_argument
(
'--password'
,
help
=
'APTLY API password'
,
...
...
@@ -170,9 +173,11 @@ parser.add_argument('--architectures', metavar='list',
help
=
(
'Specify list of architectures to publish the repo with,'
'separated by comma (e.g. amd64,i386 or armhf)'
))
parser
.
add_argument
(
'--insecure'
,
action
=
'store_true'
,
help
=
'Disable SSL verification'
)
parser
.
add_argument
(
'--noop'
,
action
=
'store_true'
,
help
=
'Only prepare upload'
)
args
=
parser
.
parse_args
()
if
not
args
.
server
:
if
not
args
.
server
and
not
args
.
noop
:
raise
StandardError
,
"Specifying an aptly server is required (--server or APTLY_SERVER)"
if
not
os
.
path
.
exists
(
args
.
result
):
...
...
@@ -233,6 +238,14 @@ if args.architectures:
if
'amd64'
in
upload_meta
[
'architectures'
]
and
not
'i386'
in
upload_meta
[
'architectures'
]:
upload_meta
[
'architectures'
].
append
(
'i386'
)
print
"Prepared upload to: %s"
%
(
aptly_url
(
'/files/'
+
upload_name
))
print
"Metadata is:"
+
json
.
dumps
(
upload_meta
,
sort_keys
=
True
,
indent
=
4
)
print
if
args
.
noop
:
print
"Running in noop mode, stopping here!"
sys
.
exit
(
0
)
# ensure target is absent
r
=
aptly_session
().
delete
(
aptly_url
(
'/files/'
+
upload_name
))
if
r
.
status_code
==
requests
.
codes
.
ok
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment