From 3c46d85683aaa5dd0b66d9d5dfae0aa7bc46bc55 Mon Sep 17 00:00:00 2001 From: r00t Date: Sun, 11 Dec 2016 21:12:09 -0500 Subject: [PATCH] sync confirmed working. still need to test iPXE builds. --- bdisk/build.py | 2 +- bdisk/host.py | 17 +++++++++++++++++ bdisk/ipxe.py | 3 +-- bdisk/prep.py | 9 --------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/bdisk/build.py b/bdisk/build.py index 2ba390d..dfa5003 100755 --- a/bdisk/build.py +++ b/bdisk/build.py @@ -386,7 +386,7 @@ def genISO(conf): def displayStats(iso): for i in iso['name']: - print("{0}:\t\t\t == {1} {2} ==".format(datetime.datetime.now(), iso[i]['type'], iso[i]['fmt'])) + print("{0}: == {1} {2} ==".format(datetime.datetime.now(), iso[i]['type'], iso[i]['fmt'])) print('\t\t\t = Size: {0}'.format(iso[i]['size'])) print('\t\t\t = SHA256: {0}'.format(iso[i]['sha'])) print('\t\t\t = Location: {0}'.format(iso[i]['file'])) diff --git a/bdisk/host.py b/bdisk/host.py index 86a2131..05573a1 100755 --- a/bdisk/host.py +++ b/bdisk/host.py @@ -2,6 +2,7 @@ import os import sys import platform import re +import glob import configparser import validators import git @@ -75,6 +76,22 @@ def parseConfig(confs): config_dict['bdisk']['ver'] = refs[0] + 'r' + refs[2] for i in ('http', 'tftp', 'rsync', 'git'): config_dict['sync'][i] = config['sync'].getboolean(i) + # And the build number. + # TODO: support tracking builds per version. i.e. in buildnum: + # v2.51r13:0 + # v2.51r17:3 + if os.path.isfile(config_dict['build']['dlpath'] + '/buildnum'): + with open(config_dict['build']['dlpath'] + '/buildnum', 'r') as f: + config_dict['build']['buildnum'] = int(f.readlines()[0]) + else: + config_dict['build']['buildnum'] = 0 + # But logically we should start the build over at 0 if we don't have any existing ISO's. + if os.path.isdir(config_dict['build']['isodir']): + if os.listdir(config_dict['build']['isodir']) == []: + conf_dict['build']['buildnum'] = 0 + # ...or if we don't have any previous builds for this ISO version. + elif not glob.glob('{0}/*v{1}r*.iso'.format(config_dict['build']['isodir'], config_dict['build']['ver'])): + config_dict['build']['buildnum'] = 0 config_dict['ipxe']['iso'] = config['ipxe'].getboolean('iso') config_dict['ipxe']['usb'] = config['ipxe'].getboolean('usb') # and build a list of arch(es) we want to build diff --git a/bdisk/ipxe.py b/bdisk/ipxe.py index 1da0b6f..c2d4b85 100755 --- a/bdisk/ipxe.py +++ b/bdisk/ipxe.py @@ -110,8 +110,7 @@ def buildIPXE(conf): DEVNULL = open(os.devnull, 'w') if os.path.isfile(build['dlpath'] + '/ipxe.log'): os.remove(build['dlpath'] + '/ipxe.log') - print(('{0}: [IPXE] Building iPXE ({1})...\n\t\t\t PROGRESS: ' + - 'tail -f {2}/ipxe.log').format( + print(('{0}: [IPXE] Building iPXE ({1})... PROGRESS: tail -f {2}/ipxe.log ...').format( datetime.datetime.now(), ipxe_src, build['dlpath'])) diff --git a/bdisk/prep.py b/bdisk/prep.py index 5d0242d..4cd98a0 100755 --- a/bdisk/prep.py +++ b/bdisk/prep.py @@ -191,15 +191,6 @@ def prepChroot(build, bdisk, user): build['user'] = os.environ['USER'] if 'SUDO_USER' in os.environ: build['realuser'] = os.environ['SUDO_USER'] - # Get the build number... - # TODO: support tracking builds per version. i.e. in buildnum: - # v2.51-g7381cc3:0 - # v2.51-gb3bb039:3 - if os.path.isfile(dlpath + '/buildnum'): - with open(dlpath + '/buildnum', 'r') as f: - build['buildnum'] = int(f.readlines()[0]) - else: - build['buildnum'] = 0 build['buildnum'] += 1 with open(dlpath + '/buildnum', 'w+') as f: f.write(str(build['buildnum']) + "\n")