Make an initial RPM package for COPR
I'm not a RPM pro, so patches welcome! I'm surely doing something wrong.
This commit is contained in:
66
misc/copr-build.py
Executable file
66
misc/copr-build.py
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# README:
|
||||
# for initial setup, browse to: https://copr.fedoraproject.org/api/
|
||||
# and it will have a ~/.config/copr config that you can download.
|
||||
# happy hacking!
|
||||
|
||||
import os
|
||||
import sys
|
||||
import copr
|
||||
import time
|
||||
|
||||
COPR = 'mgmt'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: %s <srpm url>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
url = sys.argv[1]
|
||||
|
||||
client = copr.CoprClient.create_from_file_config(os.path.expanduser("~/.config/copr"))
|
||||
|
||||
result = client.create_new_build(COPR, [url])
|
||||
if result.output != 'ok':
|
||||
print(result.error)
|
||||
sys.exit(1)
|
||||
print(result.message)
|
||||
|
||||
# modified from: https://python-copr.readthedocs.org/en/latest/Examples.html#work-with-builds
|
||||
for bw in result.builds_list:
|
||||
print("Build #{}: {}".format(bw.build_id, bw.handle.get_build_details().status))
|
||||
|
||||
# cancel all created build
|
||||
#for bw in result.builds_list:
|
||||
# bw.handle.cancel_build()
|
||||
|
||||
# get build status for each chroot
|
||||
#for bw in result.builds_list:
|
||||
# print("build: {}".format(bw.build_id))
|
||||
# for ch, status in bw.handle.get_build_details().data["chroots"].items():
|
||||
# print("\t chroot {}:\t {}".format(ch, status))
|
||||
|
||||
# simple build progress:
|
||||
|
||||
watched = set(result.builds_list)
|
||||
done = set()
|
||||
state = {}
|
||||
for bw in watched: # store initial states
|
||||
state[bw.build_id] = bw.handle.get_build_details().status
|
||||
|
||||
while watched != done:
|
||||
for bw in watched:
|
||||
if bw in done:
|
||||
continue
|
||||
status = bw.handle.get_build_details().status
|
||||
if status != state.get(bw.build_id):
|
||||
print("Build #{}: {}".format(bw.build_id, status))
|
||||
state[bw.build_id] = status # update status
|
||||
|
||||
if status in ['skipped', 'failed', 'succeeded']:
|
||||
done.add(bw)
|
||||
|
||||
if watched == done: break # avoid long while sleep
|
||||
else: time.sleep(10)
|
||||
|
||||
print 'Done!'
|
||||
13
misc/mgmt.bashrc
Executable file
13
misc/mgmt.bashrc
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
_cli_bash_autocomplete_mgmt() {
|
||||
local cur prev opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _cli_bash_autocomplete_mgmt mgmt
|
||||
1
misc/mgmt.conf.example
Normal file
1
misc/mgmt.conf.example
Normal file
@@ -0,0 +1 @@
|
||||
# example mgmt configuration file, currently has not options at the moment!
|
||||
Reference in New Issue
Block a user