-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various improvements #1
base: master
Are you sure you want to change the base?
Changes from 4 commits
9c92bad
b0a6286
c01dfee
2717ec3
dca6829
2b0c3bb
6988409
1a4a58f
3ac2b05
73c7908
ff03789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import logging | ||
import gnupg | ||
import git | ||
import glob | ||
import shutil | ||
import re | ||
import json | ||
|
@@ -63,13 +64,18 @@ | |
|
||
github_user = github_repo.split('/')[0] | ||
github_slug = github_repo.split('/')[1] | ||
|
||
git_working_folder = github_slug + "-" + gh_branch | ||
|
||
if os.path.exists(github_slug): | ||
shutil.rmtree(github_slug) | ||
if os.path.exists(git_working_folder): | ||
shutil.rmtree(git_working_folder) | ||
|
||
logging.debug("cwd : {}".format(os.getcwd())) | ||
logging.debug(os.listdir()) | ||
|
||
git_repo = git.Repo.clone_from( | ||
'https://{}@github.com/{}.git'.format(github_token, github_repo), | ||
github_slug, | ||
'https://x-access-token:{}@github.com/{}.git'.format(github_token, github_repo), | ||
git_working_folder, | ||
Comment on lines
-71
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means you can just use a bog standard I can give this a new input name and check for either if you'd rather for backwards compatibility? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget why, however I'm pretty sure I have tried using GitHub token and failed (some permission error i forgot). I will try it again when I have the time, maybe GitHub have fix the problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it's because you need |
||
) | ||
|
||
git_refs = git_repo.remotes.origin.refs | ||
|
@@ -86,7 +92,7 @@ | |
logging.debug("cwd : {}".format(os.getcwd())) | ||
logging.debug(os.listdir()) | ||
|
||
deb_file_handle = DebFile(filename=deb_file_path) | ||
deb_file_handle = DebFile(filename=glob.glob(deb_file_path)[0]) | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
deb_file_control = deb_file_handle.debcontrol() | ||
|
||
current_metadata = { | ||
|
@@ -125,10 +131,10 @@ | |
|
||
logging.info('-- Importing key --') | ||
|
||
key_dir = os.path.join(github_slug, 'public.key') | ||
key_file = os.path.join(git_working_folder, 'public.key') | ||
gpg = gnupg.GPG() | ||
|
||
detectPublicKey(gpg, key_dir, key_public) | ||
detectPublicKey(gpg, key_file, key_public) | ||
private_key_id = importPrivateKey(gpg, key_private) | ||
|
||
logging.info('-- Done importing key --') | ||
|
@@ -137,7 +143,7 @@ | |
|
||
logging.info('-- Preparing repo directory --') | ||
|
||
apt_dir = os.path.join(github_slug, apt_folder) | ||
apt_dir = os.path.join(git_working_folder, apt_folder) | ||
apt_conf_dir = os.path.join(apt_dir, 'conf') | ||
|
||
if not os.path.isdir(apt_dir): | ||
|
@@ -163,19 +169,27 @@ | |
logging.info('-- Adding package to repo --') | ||
|
||
logging.info('Adding {}'.format(deb_file_path)) | ||
os.system( | ||
'reprepro -b {} --export=silent-never includedeb {} {}'.format( | ||
apt_dir, | ||
deb_file_version, | ||
deb_file_path, | ||
) | ||
reprepro_includedeb_cmd = 'reprepro -b {} --export=silent-never includedeb {} {}'.format( | ||
apt_dir, | ||
deb_file_version, | ||
deb_file_path, | ||
) | ||
reprepro_includedeb_exit = os.waitstatus_to_exitcode(os.system(reprepro_includedeb_cmd)) | ||
if (reprepro_includedeb_exit != 0) { | ||
logging.error('Command {} failed with {}'.format(reprepro_includedeb_cmd, reprepro_includedeb_exit)) | ||
sys.exit(reprepro_includedeb_exit) | ||
} | ||
|
||
logging.debug('Signing to unlock key on gpg agent') | ||
gpg.sign('test', keyid=private_key_id, passphrase=key_passphrase) | ||
|
||
logging.debug('Export and sign repo') | ||
os.system('reprepro -b {} export'.format(apt_dir)) | ||
reprepro_export_cmd = 'reprepro -b {} export'.format(apt_dir) | ||
reprepro_export_exit = os.waitstatus_to_exitcode(os.system(reprepro_export_cmd)) | ||
if (reprepro_export_exit != 0) { | ||
logging.error('Command {} failed with {}'.format(reprepro_export_cmd, reprepro_export_exit)) | ||
sys.exit(reprepro_export_exit) | ||
} | ||
|
||
logging.info('-- Done adding package to repo --') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was having issues with it trying to commit into the same path as the existing checkout was in (which was a different branch).