Skip to content

Commit

Permalink
Can use local cp for release
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Apr 10, 2024
1 parent a836df5 commit fd0f9d1
Showing 1 changed file with 70 additions and 18 deletions.
88 changes: 70 additions & 18 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ from urllib.parse import urlparse
ssh_path = 'galette/galette-repository/plugins/'
ssh_host = 'ssh.tuxfamily.org'
galette_dl_repo = 'http://download.tuxfamily.org/galette/plugins/'
is_local = False

local_dl_repo = os.path.join(
os.path.dirname(
os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -177,6 +179,8 @@ def _do_build(ver):
"""
Proceed build
"""
global is_local

exists = False
ascexists = False
rel_name = get_rel_name(ver)
Expand All @@ -193,24 +197,31 @@ def _do_build(ver):

url = galette_dl_repo + '/' + archive_name
urlasc = '%s.asc' % url
parsed = urlparse(url)
ascparsed = urlparse(urlasc)

connection = http.client.HTTPConnection(parsed[1], 80)
connection.request('HEAD', parsed[2])
response = connection.getresponse()
exists = response.status == 200
if is_local:
exists = os.path.isfile(url)
else:
parsed = urlparse(url)

connection = http.client.HTTPConnection(parsed[1], 80)
connection.request('HEAD', parsed[2])
response = connection.getresponse()
exists = response.status == 200

if not exists:
# also check from local repo
exists = os.path.exists(galette_archive)
if exists:
local = True

connection = http.client.HTTPConnection(ascparsed[1], 80)
connection.request('HEAD', ascparsed[2])
response = connection.getresponse()
ascexists = response.status == 200
if is_local:
ascexists = os.path.isfile(urlasc)
else:
ascparsed = urlparse(urlasc)
connection = http.client.HTTPConnection(ascparsed[1], 80)
connection.request('HEAD', ascparsed[2])
response = connection.getresponse()
ascexists = response.status == 200

if not ascexists:
# also check from local repo
Expand Down Expand Up @@ -294,7 +305,7 @@ def _do_build(ver):
)

if upload:
do_scp(galette_archive)
do_upload(galette_archive)


def do_sign(archive):
Expand All @@ -303,6 +314,20 @@ def do_sign(archive):
p1.communicate()


def do_upload(galette_archive):
"""
proceed file upload
:param galette_archive:
:return:
"""
global is_local

if is_local:
do_cp(galette_archive)
else:
do_scp(galette_archive)


def do_scp(archive):
global ssh_key, ssh_host, ssh_path

Expand All @@ -319,6 +344,19 @@ def do_scp(archive):
p1.communicate()


def do_cp(archive):
global galette_dl_repo

path = galette_dl_repo
if extra:
path = os.path.join(path, 'dev')

shutil.copyfile(
archive,
os.path.join(path, os.path.basename(archive))
)


def add_libs(rel_name, galette_archive):
"""
Add external libraries to the archive
Expand Down Expand Up @@ -414,6 +452,7 @@ def add_libs(rel_name, galette_archive):
galette.close()
shutil.rmtree(src_dir)


def valid_commit(repo, c):
"""
Validate commit existence in repository
Expand Down Expand Up @@ -448,7 +487,7 @@ def main():
"""
Main method
"""
global verbose, tagrefs, force, extra, assume_yes, nightly, sign, ssh_key, repo, ssh_host, ssh_path, galette_dl_repo
global verbose, tagrefs, force, extra, assume_yes, nightly, sign, ssh_key, repo, ssh_host, ssh_path, galette_dl_repo, is_local

parser = argparse.ArgumentParser(description='Release Galette Auto Plugin')
group = parser.add_mutually_exclusive_group()
Expand Down Expand Up @@ -491,6 +530,12 @@ def main():
help='Build nightly',
action="store_true"
)
parser.add_argument(
'-l',
'--local',
help='Use local copy (defined from galette_dl_repo) rather than SSH',
action='store_true'
)
parser.add_argument(
'-k',
'--ssh-key',
Expand Down Expand Up @@ -529,14 +574,21 @@ def main():
)
assume_yes = args.assume_yes

if args.ssh_key:
ssh_key = args.ssh_key
if args.local:
if not args.download_url:
print_err('download_url is mandatory for local builds!')
sys.exit(1)
is_local = args.local

else:
if args.ssh_key:
ssh_key = args.ssh_key

if args.ssh_host:
ssh_host = args.ssh_host
if args.ssh_host:
ssh_host = args.ssh_host

if args.ssh_path:
ssh_path = args.ssh_path
if args.ssh_path:
ssh_path = args.ssh_path

if args.download_url:
galette_dl_repo = args.download_url
Expand Down

0 comments on commit fd0f9d1

Please sign in to comment.