[gentoo-commits] proj/grss:master commit in: grs/

2022-07-19 Thread Anthony G. Basile
commit: 099b2e7ac4bbf546103e263a3a5ff165a556a4c5
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Jul 20 02:22:36 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Jul 20 02:22:36 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=099b2e7a

grs/Interpret.py: fix typo

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index db9be7d..48990fb 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -120,7 +120,7 @@ class Interpret(Daemon):
 workdir = CONST.workdirs[self.run_number]
 package = CONST.packages[self.run_number]
 portage = CONST.portages[self.run_number]
-distfiles = CONST.distfiles[self.run_number]
+distfiles = CONST.distfiless[self.run_number]
 kernelroot = CONST.kernelroots[self.run_number]
 portage_configroot = CONST.portage_configroots[self.run_number]
 



[gentoo-commits] proj/grss:master commit in: grs/

2022-07-19 Thread Anthony G. Basile
commit: a5b44d6b3130b0f676c2408a5d483c9c70da4919
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Jul 20 01:49:11 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Jul 20 01:49:11 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=a5b44d6b

grs/MountDirectories.py: bind mount /var/cache/distfiles

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Constants.py| 2 ++
 grs/Interpret.py| 3 ++-
 grs/MountDirectories.py | 8 +---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/grs/Constants.py b/grs/Constants.py
index f9a640e..8d8df14 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -88,6 +88,7 @@ class Constants():
 'workdir' : '/var/tmp/grs/%s/work',
 'package' : '/var/tmp/grs/%s/packages',
 'portage' : '/var/db/repos/gentoo',
+'distfiles'   : '/var/cache/distfiles',
 'kernelroot'  : '/var/tmp/grs/%s/kernel',
 'portage_configroot'  : '/var/tmp/grs/%s/system',
 'pidfile' : '/run/grs-%s.pid'
@@ -163,6 +164,7 @@ CONST.TMPDIR = '/var/tmp/grs'
 CONST.WORKDIR = '/var/tmp/grs/work'
 CONST.PACKAGE = '/var/tmp/grs/package'
 CONST.PORTAGE = '/var/db/repos/gentoo'
+CONST.DISTFILES = '/var/cache/distfiles'
 CONST.KERNELROOT = '/var/tmp/grs/kernel'
 CONST.PORTAGE_CONFIGROOT = '/var/tmp/grs/system'
 CONST.PIDFILE = '/run/grs.pid'

diff --git a/grs/Interpret.py b/grs/Interpret.py
index a06807f..db9be7d 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -120,6 +120,7 @@ class Interpret(Daemon):
 workdir = CONST.workdirs[self.run_number]
 package = CONST.packages[self.run_number]
 portage = CONST.portages[self.run_number]
+distfiles = CONST.distfiles[self.run_number]
 kernelroot = CONST.kernelroots[self.run_number]
 portage_configroot = CONST.portage_configroots[self.run_number]
 
@@ -129,7 +130,7 @@ class Interpret(Daemon):
 _lo = Log(logfile)
 _sy = Synchronize(repo_uri, name, libdir, logfile)
 _se = Seed(stage_uri, tmpdir, portage_configroot, package, logfile)
-_md = MountDirectories(portage_configroot, package, portage, logfile)
+_md = MountDirectories(portage_configroot, package, portage, 
distfiles, logfile)
 _po = Populate(libdir, workdir, portage_configroot, logfile)
 _ru = RunScript(libdir, portage_configroot, logfile)
 _pc = PivotChroot(tmpdir, portage_configroot, logfile)

diff --git a/grs/MountDirectories.py b/grs/MountDirectories.py
index 36949d0..24d2f66 100644
--- a/grs/MountDirectories.py
+++ b/grs/MountDirectories.py
@@ -27,7 +27,7 @@ class MountDirectories():
 """
 
 def __init__(self, portage_configroot=CONST.PORTAGE_CONFIGROOT, \
-package=CONST.PACKAGE, portage=CONST.PORTAGE, 
logfile=CONST.LOGFILE):
+package=CONST.PACKAGE, portage=CONST.PORTAGE, 
distfiles=CONST.DISTFILES, logfile=CONST.LOGFILE):
 # The order is respected.  Note that 'dev' needs to be mounted beore 
'dev/pts'.
 self.directories = [
 'dev',
@@ -37,12 +37,14 @@ class MountDirectories():
 'sys',
 {'run' : ('tmpfs', 'none')},
 [portage, 'var/db/repos/gentoo'],
-[package, 'var/cache/binpkgs']
+[package, 'var/cache/binpkgs'],
+[distfiles, 'var/cache/distfiles']
 ]
 # Once initiated, we only work with one portage_configroot
 self.portage_configroot = portage_configroot
-self.package = package
 self.portage = portage
+self.package = package
+self.distfiles = distfiles
 self.logfile = logfile
 # We need to umount in the reverse order
 self.rev_directories = deepcopy(self.directories)



[gentoo-commits] proj/grss:master commit in: grs/

2022-07-19 Thread Anthony G. Basile
commit: 3b90324241c0224d10c7bedb725be4c30521192c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Jul 19 20:22:53 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Jul 19 20:22:53 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=3b903242

grs/Kernel.py: remove deprecated option -arch-override

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Kernel.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 1f9ba31..8fcf35c 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -136,7 +136,6 @@ class Kernel():
 cmd += '--bootdir=%s '   % boot_dir
 cmd += '--kernel-modules-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
-cmd += '--arch-override=%s ' % arch
 if os.path.isfile(self.busybox_config):
 cmd += '--busybox-config=%s ' % self.busybox_config
 if os.path.isfile(self.genkernel_config):



[gentoo-commits] proj/grss:master commit in: grs/

2022-07-19 Thread Anthony G. Basile
commit: e8635e7e6c77150eadeefe09301b550bc410a383
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Jul 19 20:18:37 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Jul 19 20:18:37 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=e8635e7e

grs/Kernel.py: use new name --kernel-modules-prefix

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Kernel.py | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 3abea6a..1f9ba31 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -131,12 +131,12 @@ class Kernel():
 cmd += '--makeopts=-j9 '
 cmd += '--symlink '
 cmd += '--no-mountboot '
-cmd += '--kernel-config=%s ' % self.kernel_config
-cmd += '--kerneldir=%s ' % kernel_source
-cmd += '--bootdir=%s '   % boot_dir
-cmd += '--module-prefix=%s ' % image_dir
-cmd += '--modprobedir=%s '   % modprobe_dir
-cmd += '--arch-override=%s ' % arch
+cmd += '--kernel-config=%s ' % self.kernel_config
+cmd += '--kerneldir=%s ' % kernel_source
+cmd += '--bootdir=%s '   % boot_dir
+cmd += '--kernel-modules-prefix=%s ' % image_dir
+cmd += '--modprobedir=%s '   % modprobe_dir
+cmd += '--arch-override=%s ' % arch
 if os.path.isfile(self.busybox_config):
 cmd += '--busybox-config=%s ' % self.busybox_config
 if os.path.isfile(self.genkernel_config):



[gentoo-commits] proj/grss:master commit in: grs/

2022-07-18 Thread Anthony G. Basile
commit: 254ab00f5f6552165a5ca0cd485cdc13e555ba8a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Jul 18 21:13:30 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Jul 18 21:13:30 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=254ab00f

grs/MountDirectories.py: mount /run as tmpfs

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/MountDirectories.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grs/MountDirectories.py b/grs/MountDirectories.py
index 1ada579..36949d0 100644
--- a/grs/MountDirectories.py
+++ b/grs/MountDirectories.py
@@ -35,6 +35,7 @@ class MountDirectories():
 {'dev/shm' : ('tmpfs', 'shm')},
 'proc',
 'sys',
+{'run' : ('tmpfs', 'none')},
 [portage, 'var/db/repos/gentoo'],
 [package, 'var/cache/binpkgs']
 ]



[gentoo-commits] proj/grss:master commit in: grs/, /, bin/, tests/

2022-07-18 Thread Anthony G. Basile
commit: 248bff2120901089cacf41a26a044adf3c2e8126
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Jul 18 19:50:00 2022 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Jul 18 19:50:00 2022 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=248bff21

Switch to new /var/db/repos/gentoo and /var/cache/binpkgs defaults

Signed-off-by: Anthony G. Basile  gentoo.org>

 TODO   | 2 +-
 bin/grsup  | 2 +-
 grs/Constants.py   | 4 ++--
 grs/ISOIt.py   | 2 +-
 grs/MountDirectories.py| 4 ++--
 tests/test-mountdirectories.py | 8 
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/TODO b/TODO
index 2cb96b2..270b30b 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
 My TODO list:
 
 1. A local copy of PORTDIR should be created in CONST.TMPDIR + GRS name.  This 
is
-to prevent wierdness in case /usr/portage changes during a run.
+to prevent wierdness in case /var/db/repos/gentoo changes during a run.
 
 2. Upon building a system we should make use of the binpkgs in CONST.TMPDIR + 
GRS name
 as a time saver.  This is something to go into the build scripts in the GRS 
repo and not

diff --git a/bin/grsup b/bin/grsup
index 319236f..8e2679c 100755
--- a/bin/grsup
+++ b/bin/grsup
@@ -92,7 +92,7 @@ def install_kernel(version = 'latest', logfile = 
CONST.LOGFILE):
 
 # Download the linux-image tarball to packages/linux-image
 request = urllib.request.urlopen('%s/%s/%s' % (baseurl, 'linux-images', 
kernel))
-package = '/usr/portage/packages/linux-images'
+package = '/var/cache/binpkgs/linux-images'
 os.makedirs(package, mode=0o755, exist_ok=True)
 kpath = os.path.join(package, kernel)
 with open(kpath, 'wb') as f:

diff --git a/grs/Constants.py b/grs/Constants.py
index 3c4b3bc..f9a640e 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -87,7 +87,7 @@ class Constants():
 'tmpdir'  : '/var/tmp/grs/%s',
 'workdir' : '/var/tmp/grs/%s/work',
 'package' : '/var/tmp/grs/%s/packages',
-'portage' : '/usr/portage',
+'portage' : '/var/db/repos/gentoo',
 'kernelroot'  : '/var/tmp/grs/%s/kernel',
 'portage_configroot'  : '/var/tmp/grs/%s/system',
 'pidfile' : '/run/grs-%s.pid'
@@ -162,7 +162,7 @@ CONST.LOGFILE = '/var/log/grs.log'
 CONST.TMPDIR = '/var/tmp/grs'
 CONST.WORKDIR = '/var/tmp/grs/work'
 CONST.PACKAGE = '/var/tmp/grs/package'
-CONST.PORTAGE = '/usr/portage'
+CONST.PORTAGE = '/var/db/repos/gentoo'
 CONST.KERNELROOT = '/var/tmp/grs/kernel'
 CONST.PORTAGE_CONFIGROOT = '/var/tmp/grs/system'
 CONST.PIDFILE = '/run/grs.pid'

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index 20e820f..e8b8a8c 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -63,7 +63,7 @@ class ISOIt(HashIt):
 
 # Emerge busybox.
 os.symlink(
-'/usr/portage/profiles/hardened/linux/amd64',
+'/var/db/repos/gentoo/profiles/default/linux/amd64/17.1/hardened',
 makeprofile_path
 )
 cmd = 'emerge --nodeps -1q busybox'

diff --git a/grs/MountDirectories.py b/grs/MountDirectories.py
index a1a42af..1ada579 100644
--- a/grs/MountDirectories.py
+++ b/grs/MountDirectories.py
@@ -35,8 +35,8 @@ class MountDirectories():
 {'dev/shm' : ('tmpfs', 'shm')},
 'proc',
 'sys',
-[portage, 'usr/portage'],
-[package, 'usr/portage/packages']
+[portage, 'var/db/repos/gentoo'],
+[package, 'var/cache/binpkgs']
 ]
 # Once initiated, we only work with one portage_configroot
 self.portage_configroot = portage_configroot

diff --git a/tests/test-mountdirectories.py b/tests/test-mountdirectories.py
index f12819f..0393ae1 100755
--- a/tests/test-mountdirectories.py
+++ b/tests/test-mountdirectories.py
@@ -34,13 +34,13 @@ if __name__ == "__main__":
 open(empty_file, 'a').close()
 
 configroot = '/tmp/test-mountdirectories'
-directories = [ 'dev', 'dev/pts', 'dev/shm', 'proc', 'sys', 'usr/portage', 
'usr/portage/packages' ]
+directories = [ 'dev', 'dev/pts', 'dev/shm', 'proc', 'sys', 
'var/db/repos/gentoo', 'var/cache/binpkgs' ]
 for d in directories:
 try:
 os.makedirs(os.path.join(configroot, d))
 except FileExistsError:
 pass
-alt_empty_file = os.path.join(configroot, 'usr/portage/packages/empty')
+alt_empty_file = os.path.join(configroot, 'var/cache/binpkgs/empty')
 
 md = MountDirectories(portage_configroot=configroot, package=package, 
logfile='/dev/null')
 
@@ -54,13 +54,13 @@ if __name__ == "__main__":
 assert(some_mounted == True)
 assert(all_mounted == True)
 
-# /tmp/test-package/aaa and 
/tmp/test-mountdirectories/usr/portage/packages/empty exist
+# /tmp/test-package/aaa and 

[gentoo-commits] proj/grss:master commit in: grs/

2019-04-20 Thread Anthony G. Basile
commit: 9d61dc4ca6b4a8f68806d336c5b6eb888332582e
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Apr 19 12:29:40 2019 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Apr 19 12:29:45 2019 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=9d61dc4c

grs/Kernel.py: correctly parse vanilla-sources

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Kernel.py | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 82e6d04..3abea6a 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -67,10 +67,15 @@ class Kernel():
 pkg_name = flavor + '-sources-' + vanilla_version + '-' + revision
 except AttributeError:
 # Or the verison is of the form '4.0.6-hardened' with one -
-_match = re.search(r'(\S+?)-(\S+)', gentoo_version)
-vanilla_version = _match.group(1)
-flavor = _match.group(2)
-pkg_name = flavor + '-sources-' + vanilla_version
+try:
+_match = re.search(r'(\S+?)-(\S+)', gentoo_version)
+vanilla_version = _match.group(1)
+flavor = _match.group(2)
+pkg_name = flavor + '-sources-' + vanilla_version
+except AttributeError:
+# Finally the verison is of the form '4.0.6' with no -
+vanilla_version = gentoo_version
+pkg_name = 'vanilla-sources-' + vanilla_version
 pkg_name = '=sys-kernel/' + pkg_name
 return (gentoo_version, pkg_name, has_modules)
 



[gentoo-commits] proj/grss:master commit in: grs/

2018-11-18 Thread Anthony G. Basile
commit: 4081b20f9f1c6837ae06704422215eb51910491b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Nov 18 19:08:59 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Nov 18 19:08:59 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=4081b20f

grs/MountDirectories.py: location of /usr/portage is configurable

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Constants.py| 2 ++
 grs/Interpret.py| 3 ++-
 grs/MountDirectories.py | 5 +++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/grs/Constants.py b/grs/Constants.py
index bdaee25..3c4b3bc 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -87,6 +87,7 @@ class Constants():
 'tmpdir'  : '/var/tmp/grs/%s',
 'workdir' : '/var/tmp/grs/%s/work',
 'package' : '/var/tmp/grs/%s/packages',
+'portage' : '/usr/portage',
 'kernelroot'  : '/var/tmp/grs/%s/kernel',
 'portage_configroot'  : '/var/tmp/grs/%s/system',
 'pidfile' : '/run/grs-%s.pid'
@@ -161,6 +162,7 @@ CONST.LOGFILE = '/var/log/grs.log'
 CONST.TMPDIR = '/var/tmp/grs'
 CONST.WORKDIR = '/var/tmp/grs/work'
 CONST.PACKAGE = '/var/tmp/grs/package'
+CONST.PORTAGE = '/usr/portage'
 CONST.KERNELROOT = '/var/tmp/grs/kernel'
 CONST.PORTAGE_CONFIGROOT = '/var/tmp/grs/system'
 CONST.PIDFILE = '/run/grs.pid'

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 422357d..a06807f 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -119,6 +119,7 @@ class Interpret(Daemon):
 tmpdir = CONST.tmpdirs[self.run_number]
 workdir = CONST.workdirs[self.run_number]
 package = CONST.packages[self.run_number]
+portage = CONST.portages[self.run_number]
 kernelroot = CONST.kernelroots[self.run_number]
 portage_configroot = CONST.portage_configroots[self.run_number]
 
@@ -128,7 +129,7 @@ class Interpret(Daemon):
 _lo = Log(logfile)
 _sy = Synchronize(repo_uri, name, libdir, logfile)
 _se = Seed(stage_uri, tmpdir, portage_configroot, package, logfile)
-_md = MountDirectories(portage_configroot, package, logfile)
+_md = MountDirectories(portage_configroot, package, portage, logfile)
 _po = Populate(libdir, workdir, portage_configroot, logfile)
 _ru = RunScript(libdir, portage_configroot, logfile)
 _pc = PivotChroot(tmpdir, portage_configroot, logfile)

diff --git a/grs/MountDirectories.py b/grs/MountDirectories.py
index 692c320..a1a42af 100644
--- a/grs/MountDirectories.py
+++ b/grs/MountDirectories.py
@@ -27,7 +27,7 @@ class MountDirectories():
 """
 
 def __init__(self, portage_configroot=CONST.PORTAGE_CONFIGROOT, \
-package=CONST.PACKAGE, logfile=CONST.LOGFILE):
+package=CONST.PACKAGE, portage=CONST.PORTAGE, 
logfile=CONST.LOGFILE):
 # The order is respected.  Note that 'dev' needs to be mounted beore 
'dev/pts'.
 self.directories = [
 'dev',
@@ -35,12 +35,13 @@ class MountDirectories():
 {'dev/shm' : ('tmpfs', 'shm')},
 'proc',
 'sys',
-'usr/portage',
+[portage, 'usr/portage'],
 [package, 'usr/portage/packages']
 ]
 # Once initiated, we only work with one portage_configroot
 self.portage_configroot = portage_configroot
 self.package = package
+self.portage = portage
 self.logfile = logfile
 # We need to umount in the reverse order
 self.rev_directories = deepcopy(self.directories)



[gentoo-commits] proj/grss:master commit in: grs/

2018-11-11 Thread Anthony G. Basile
commit: 58b059a17bf4be4b97d72b8e242f0365949deaa6
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Nov 12 03:08:36 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Nov 12 03:08:36 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=58b059a1

grs/Interpret.py: fix typo

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 74d04e3..422357d 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -247,7 +247,7 @@ class Interpret(Daemon):
 elif verb == 'netbootit':
 # 'netbootit' can either be just a 'verb', 'verb obj' or 
'verb obj obj'
 if len(objs) == 2:
-semantic_action(_line, objs, 2, _nb.netbootit, 
objs[0], obj[1])
+semantic_action(_line, objs, 2, _nb.netbootit, 
objs[0], objs[1])
 elif len(objs) == 1:
 semantic_action(_line, objs, 1, _nb.netbootit, objs[0])
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-11-11 Thread Anthony G. Basile
commit: 604406fecf6be1d674e123f630957f15b1ed1dec
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Nov 11 23:57:34 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Nov 11 23:57:41 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=604406fe

grs/TarIt.py: fix typo

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/TarIt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/TarIt.py b/grs/TarIt.py
index 89e7465..00f0b6a 100644
--- a/grs/TarIt.py
+++ b/grs/TarIt.py
@@ -44,7 +44,7 @@ class TarIt(HashIt):
 def tarit(self, alt_name=None):
 # Create the tarball with the default name unless an alt_name is given.
 if alt_name:
-self.medium_name = '%s.tar.xz' % alt_name)
+self.medium_name = '%s.tar.xz' % alt_name
 self.digest_name = '%s.DIGESTS' % self.medium_name
 # We have to cd into the system's portage configroot and then out 
again.
 cwd = os.getcwd()



[gentoo-commits] proj/grss:master commit in: grs/

2018-11-11 Thread Anthony G. Basile
commit: 85345d4e5f9ab61413299368e506edc247d78a6b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Nov 11 23:35:31 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Nov 11 23:35:31 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=85345d4e

grs/Netboot.py: control the entire alt-name for the initramfs/kernel/ISO

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Netboot.py | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 33c7b9d..59bd34b 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -41,20 +41,22 @@ class Netboot(HashIt):
 self.kernelroot = kernelroot
 self.logfile = logfile
 # Prepare a year, month and day for a name timestamp.
-self.year = str(datetime.now().year).zfill(4)
-self.month = str(datetime.now().month).zfill(2)
-self.day = str(datetime.now().day).zfill(2)
-self.medium_name = 'initramfs-%s-%s%s%s' % (name, self.year, 
self.month, self.day)
+year = str(datetime.now().year).zfill(4)
+month = str(datetime.now().month).zfill(2)
+day = str(datetime.now().day).zfill(2)
+self.medium_name = 'initramfs-%s-%s%s%s' % (name, year, month, day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
-self.kernelname = 'kernel-%s-%s%s%s' % (name, self.year, self.month, 
self.day)
-self.cd_name = '%s-%s%s%s.iso' % (name, self.year, self.month, 
self.day)
+self.kernelname = 'kernel-%s-%s%s%s' % (name, year, month, day)
+self.cd_name = '%s-%s%s%s.iso' % (name, year, month, day)
 
 
 def netbootit(self, do_cd=None, alt_name=None):
 """ TODO """
 if alt_name:
-self.medium_name = 'initramfs-%s-%s%s%s' % (alt_name, self.year, 
self.month, self.day)
+self.medium_name = 'initramfs-%s' % alt_name
 self.digest_name = '%s.DIGESTS' % self.medium_name
+self.kernelname = 'kernel-%s' % alt_name
+self.cd_name = '%s.iso' % alt_name
 
 # 1. Copy the kernel to the tmpdir directory.
 kernel_src = os.path.join(self.portage_configroot, 'boot/kernel')



[gentoo-commits] proj/grss:master commit in: grs/

2018-11-11 Thread Anthony G. Basile
commit: be05b024339d7273767060b3679a91c434ee5455
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Nov 11 23:15:35 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Nov 11 23:16:20 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=be05b024

grs/TarIt.py: control the entire alt-name for the tarball

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/TarIt.py | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/grs/TarIt.py b/grs/TarIt.py
index aef1b42..89e7465 100644
--- a/grs/TarIt.py
+++ b/grs/TarIt.py
@@ -34,17 +34,17 @@ class TarIt(HashIt):
 self.portage_configroot = portage_configroot
 self.logfile = logfile
 # Prepare a year, month and day for a tarball name timestamp.
-self.year = str(datetime.now().year).zfill(4)
-self.month = str(datetime.now().month).zfill(2)
-self.day = str(datetime.now().day).zfill(2)
-self.medium_name = '%s-%s%s%s.tar.xz' % (name, self.year, self.month, 
self.day)
+year = str(datetime.now().year).zfill(4)
+month = str(datetime.now().month).zfill(2)
+day = str(datetime.now().day).zfill(2)
+self.medium_name = '%s-%s%s%s.tar.xz' % (name, year, month, day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
 
 
 def tarit(self, alt_name=None):
 # Create the tarball with the default name unless an alt_name is given.
 if alt_name:
-self.medium_name = '%s-%s%s%s.tar.xz' % (alt_name, self.year, 
self.month, self.day)
+self.medium_name = '%s.tar.xz' % alt_name)
 self.digest_name = '%s.DIGESTS' % self.medium_name
 # We have to cd into the system's portage configroot and then out 
again.
 cwd = os.getcwd()



[gentoo-commits] proj/grss:master commit in: grs/

2018-06-25 Thread Anthony G. Basile
commit: 44dfdc8b645cb2d13fa0e966bfa7f7591119c980
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Jun 25 20:32:19 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Jun 25 20:32:19 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=44dfdc8b

grs/Constants.py: add CONFIGFILE for an alt to '/etc/grs/systems.conf'

 grs/Constants.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/grs/Constants.py b/grs/Constants.py
index ecbac40..bdaee25 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -57,6 +57,12 @@ class Constants():
 """
 
 def __init__(self, configfile='/etc/grs/systems.conf'):
+# Grab an alternative config file from the env var CONFIGFILE
+# TODO: I've designed myself into a bit of a corner here, and
+# there is no easy way of adding a command line option to grsrun
+# or grsup which propagates to this class.
+if 'CONFIGFILE' in os.environ:
+configfile = os.environ['CONFIGFILE']
 # If there's no config file, we're dead in the water.
 if not os.path.isfile(configfile):
 raise Exception('Configuration file %s not found\n' % configfile)



[gentoo-commits] proj/grss:master commit in: grs/

2018-04-14 Thread Anthony G. Basile
commit: 4eea4b02f33038cbf8d0ea706dd212df964cac4a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Apr 14 14:52:57 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Apr 14 14:52:57 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=4eea4b02

grs/Kernel.py: look for firmware-dir in portage_configroot

 grs/Kernel.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 7582e81..82e6d04 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -92,6 +92,10 @@ class Kernel():
 boot_dir = os.path.join(image_dir, 'boot')
 modprobe_dir = os.path.join(image_dir, 'etc/modprobe.d')
 modules_dir = os.path.join(image_dir, 'lib/modules')
+
+# The firmware directory, if it exists, will be in 
self.portage_configroot
+firmware_dir = os.path.join(self.portage_configroot, 'lib/firmware')
+
 # Prepare tarball filename and path.  If the tarball already exists,
 # don't rebuild/reinstall it.  Note: It should have been installed to
 # the system's portage configroot when it was first built, so no need
@@ -132,6 +136,8 @@ class Kernel():
 cmd += '--busybox-config=%s ' % self.busybox_config
 if os.path.isfile(self.genkernel_config):
 cmd += '--config=%s ' % self.genkernel_config
+if  os.path.isdir(firmware_dir):
+cmd += '--firmware-dir=%s ' % firmware_dir
 if has_modules:
 cmd += 'all'
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-04-09 Thread Anthony G. Basile
commit: d0d9a3b850b4f2c6ced830142e6314ce5d26d2cf
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Apr 10 03:14:15 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Apr 10 03:14:15 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=d0d9a3b8

grs/Kernel.py: allow genkernel to install firmware

 grs/Kernel.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 6b15a46..7582e81 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -120,7 +120,6 @@ class Kernel():
 cmd += '--logfile=/dev/null '
 cmd += '--no-save-config '
 cmd += '--makeopts=-j9 '
-cmd += '--no-firmware '
 cmd += '--symlink '
 cmd += '--no-mountboot '
 cmd += '--kernel-config=%s ' % self.kernel_config



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-19 Thread Anthony G. Basile
commit: f9a259f9f4b69644eed30f46955b77aaf2aa97fc
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb 20 02:27:14 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb 20 02:27:36 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=f9a259f9

grs/Synchronize.py: improve 'git submodule update' command

 grs/Synchronize.py | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index be41bd6..da38285 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -50,11 +50,8 @@ class Synchronize():
 # If there is a .gitmodules, then init/update the submodules
 git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
 if os.path.isfile(git_modulesfile):
-# This may re-init submodules, but its harmless.  We need
-# to keep trying for newly added modules.
-cmd = 'git -C %s submodule init' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
-cmd = 'git -C %s submodule update --remote' % self.local_repo
+# Recursively update any submodules following the remote branch
+cmd = 'git -C %s submodule update --init --recursive --remote' % 
self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-19 Thread Anthony G. Basile
commit: 8e616d7126450fe4f3fb34e22fc5ce10492fbd99
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb 20 02:04:47 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb 20 02:04:47 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=8e616d71

grs/Synchronize.py: update tracking the remote branch

 grs/Synchronize.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index d2d4cb5..be41bd6 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -54,7 +54,7 @@ class Synchronize():
 # to keep trying for newly added modules.
 cmd = 'git -C %s submodule init' % self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
-cmd = 'git -C %s submodule update' % self.local_repo
+cmd = 'git -C %s submodule update --remote' % self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-18 Thread Anthony G. Basile
commit: b9dc8458eaba1a97380f6a59795afd267739f04c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Feb 18 22:38:45 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Feb 18 22:38:45 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=b9dc8458

grs/Kernel.py: fix typo

 grs/Kernel.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 2bc3e72..6b15a46 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -132,7 +132,7 @@ class Kernel():
 if os.path.isfile(self.busybox_config):
 cmd += '--busybox-config=%s ' % self.busybox_config
 if os.path.isfile(self.genkernel_config):
-cmd += '--config=%s ' % self.genkernel_config):
+cmd += '--config=%s ' % self.genkernel_config
 if has_modules:
 cmd += 'all'
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-18 Thread Anthony G. Basile
commit: a7fc9bfe8447be1804066f5c5da4209784960c7e
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Feb 18 16:36:23 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Feb 18 16:36:23 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=a7fc9bfe

grs/Kernel.py: use scripts/genkernel.conf if provided

 grs/Kernel.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index cbe470e..2bc3e72 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -42,6 +42,7 @@ class Kernel():
 self.logfile = logfile
 self.kernel_config = os.path.join(self.libdir, 'scripts/kernel-config')
 self.busybox_config = os.path.join(self.libdir, 
'scripts/busybox-config')
+self.genkernel_config = os.path.join(self.libdir, 
'scripts/genkernel.conf')
 
 
 def parse_kernel_config(self):
@@ -130,6 +131,8 @@ class Kernel():
 cmd += '--arch-override=%s ' % arch
 if os.path.isfile(self.busybox_config):
 cmd += '--busybox-config=%s ' % self.busybox_config
+if os.path.isfile(self.genkernel_config):
+cmd += '--config=%s ' % self.genkernel_config):
 if has_modules:
 cmd += 'all'
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-06 Thread Anthony G. Basile
commit: d3100bd866cb5339b897378894f79bcd51ede89c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb  6 11:57:31 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb  6 11:57:31 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=d3100bd8

grs/Synchronize.py: checkout the branch before updating the submodule

 grs/Synchronize.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index 8a55c84..d2d4cb5 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -43,6 +43,10 @@ class Synchronize():
 cmd = 'git clone %s %s' % (self.remote_repo, self.local_repo)
 Execute(cmd, timeout=60, logfile=self.logfile)
 
+# Make sure we're on the correct branch for the desired GRS system.
+cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch)
+Execute(cmd, timeout=60, logfile=self.logfile)
+
 # If there is a .gitmodules, then init/update the submodules
 git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
 if os.path.isfile(git_modulesfile):
@@ -53,10 +57,6 @@ class Synchronize():
 cmd = 'git -C %s submodule update' % self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
 
-# Make sure we're on the correct branch for the desired GRS system.
-cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch)
-Execute(cmd, timeout=60, logfile=self.logfile)
-
 
 def isgitdir(self):
 """ If there is a .git/config file, assume its a local git repository. 
"""



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-06 Thread Anthony G. Basile
commit: 732c2e65b8af57bcfaa99d5a4a741e6e2b616b14
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb  6 11:33:29 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb  6 11:41:57 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=732c2e65

grs/Synchronize.py: always re-init submodules

 grs/Synchronize.py | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index 199928b..8a55c84 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -30,9 +30,6 @@ class Synchronize():
 self.logfile = logfile
 
 def sync(self):
-# If there is a .gitmodules, then update the submodules
-git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
-
 if self.isgitdir():
 # If the local repo exists, then make it pristine an pull
 cmd = 'git -C %s reset HEAD --hard' % self.local_repo
@@ -41,18 +38,20 @@ class Synchronize():
 Execute(cmd, timeout=60, logfile=self.logfile)
 cmd = 'git -C %s pull' % self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
-if os.path.isfile(git_modulesfile):
-cmd = 'git -C %s submodule update' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
 else:
 # else clone afresh.
 cmd = 'git clone %s %s' % (self.remote_repo, self.local_repo)
 Execute(cmd, timeout=60, logfile=self.logfile)
-if os.path.isfile(git_modulesfile):
-cmd = 'git -C %s submodule init' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
-cmd = 'git -C %s submodule update' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
+
+# If there is a .gitmodules, then init/update the submodules
+git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
+if os.path.isfile(git_modulesfile):
+# This may re-init submodules, but its harmless.  We need
+# to keep trying for newly added modules.
+cmd = 'git -C %s submodule init' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
+cmd = 'git -C %s submodule update' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
 
 # Make sure we're on the correct branch for the desired GRS system.
 cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch)



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-06 Thread Anthony G. Basile
commit: fc61730175767bbfb2f8ad6658b353eb5a23772c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb  6 11:33:29 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb  6 11:33:29 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=fc617301

grs/Synchronize.py: always re-init submodules

 grs/Synchronize.py | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index 199928b..97174f5 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -30,9 +30,6 @@ class Synchronize():
 self.logfile = logfile
 
 def sync(self):
-# If there is a .gitmodules, then update the submodules
-git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
-
 if self.isgitdir():
 # If the local repo exists, then make it pristine an pull
 cmd = 'git -C %s reset HEAD --hard' % self.local_repo
@@ -48,11 +45,16 @@ class Synchronize():
 # else clone afresh.
 cmd = 'git clone %s %s' % (self.remote_repo, self.local_repo)
 Execute(cmd, timeout=60, logfile=self.logfile)
-if os.path.isfile(git_modulesfile):
-cmd = 'git -C %s submodule init' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
-cmd = 'git -C %s submodule update' % self.local_repo
-Execute(cmd, timeout=60, logfile=self.logfile)
+
+# If there is a .gitmodules, then init/update the submodules
+git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
+if os.path.isfile(git_modulesfile):
+# This may re-init submodules, but its harmless.  We need
+# to keep trying for newly added modules.
+cmd = 'git -C %s submodule init' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
+cmd = 'git -C %s submodule update' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
 
 # Make sure we're on the correct branch for the desired GRS system.
 cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch)



[gentoo-commits] proj/grss:master commit in: grs/

2018-02-06 Thread Anthony G. Basile
commit: ad2f9b41833ff60223030dc826106a99a5c52221
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Feb  6 10:55:41 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Feb  6 10:55:41 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=ad2f9b41

grs/Synchronize.py: add git submodules support

 grs/Synchronize.py | 13 +
 1 file changed, 13 insertions(+)

diff --git a/grs/Synchronize.py b/grs/Synchronize.py
index 3ce7d5c..199928b 100644
--- a/grs/Synchronize.py
+++ b/grs/Synchronize.py
@@ -30,6 +30,9 @@ class Synchronize():
 self.logfile = logfile
 
 def sync(self):
+# If there is a .gitmodules, then update the submodules
+git_modulesfile = os.path.join(self.local_repo, '.gitmodules')
+
 if self.isgitdir():
 # If the local repo exists, then make it pristine an pull
 cmd = 'git -C %s reset HEAD --hard' % self.local_repo
@@ -38,14 +41,24 @@ class Synchronize():
 Execute(cmd, timeout=60, logfile=self.logfile)
 cmd = 'git -C %s pull' % self.local_repo
 Execute(cmd, timeout=60, logfile=self.logfile)
+if os.path.isfile(git_modulesfile):
+cmd = 'git -C %s submodule update' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
 else:
 # else clone afresh.
 cmd = 'git clone %s %s' % (self.remote_repo, self.local_repo)
 Execute(cmd, timeout=60, logfile=self.logfile)
+if os.path.isfile(git_modulesfile):
+cmd = 'git -C %s submodule init' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
+cmd = 'git -C %s submodule update' % self.local_repo
+Execute(cmd, timeout=60, logfile=self.logfile)
+
 # Make sure we're on the correct branch for the desired GRS system.
 cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch)
 Execute(cmd, timeout=60, logfile=self.logfile)
 
+
 def isgitdir(self):
 """ If there is a .git/config file, assume its a local git repository. 
"""
 git_configdir = os.path.join(self.local_repo, '.git')



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-28 Thread Anthony G. Basile
commit: face3fcd8f63c42a750223236da6c3ebc3d8cb17
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 28 12:31:04 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 28 12:31:04 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=face3fcd

grs/Kernel.py: use scripts/busybox-config if provided

 grs/Kernel.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index bd89ee2..cbe470e 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -41,6 +41,7 @@ class Kernel():
 self.package = package
 self.logfile = logfile
 self.kernel_config = os.path.join(self.libdir, 'scripts/kernel-config')
+self.busybox_config = os.path.join(self.libdir, 
'scripts/busybox-config')
 
 
 def parse_kernel_config(self):
@@ -127,10 +128,13 @@ class Kernel():
 cmd += '--module-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
 cmd += '--arch-override=%s ' % arch
+if os.path.isfile(self.busybox_config):
+cmd += '--busybox-config=%s ' % self.busybox_config
 if has_modules:
 cmd += 'all'
 else:
 cmd += 'bzImage'
+
 Execute(cmd, timeout=None, logfile=self.logfile)
 
 # Strip the modules to shrink their size enormously!



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-28 Thread Anthony G. Basile
commit: 54e95c897ccf46d94bd888b0cad815c748ba8417
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 28 12:09:25 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 28 12:09:25 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=54e95c89

grs: prettify __init__ arguments

 grs/ISOIt.py   | 8 ++--
 grs/Kernel.py  | 8 ++--
 grs/PivotChroot.py | 4 +++-
 grs/Populate.py| 7 +--
 grs/RunScript.py   | 4 +++-
 grs/Seed.py| 8 ++--
 grs/TarIt.py   | 7 ++-
 7 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index d24a542..20e820f 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -27,8 +27,12 @@ class ISOIt(HashIt):
 """ Create a bootable ISO of the system. """
 
 def __init__(
-self, name, libdir=CONST.LIBDIR, tmpdir=CONST.TMPDIR,
-portage_configroot=CONST.PORTAGE_CONFIGROOT, logfile=CONST.LOGFILE
+self,
+name,
+libdir=CONST.LIBDIR,
+tmpdir=CONST.TMPDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+logfile=CONST.LOGFILE
 ):
 self.libdir = libdir
 self.tmpdir = tmpdir

diff --git a/grs/Kernel.py b/grs/Kernel.py
index fe411bd..bd89ee2 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -28,8 +28,12 @@ class Kernel():
 """ Build a linux-image pkg and install when building a system. """
 
 def __init__(
-self, libdir=CONST.LIBDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
-kernelroot=CONST.KERNELROOT, package=CONST.PACKAGE, 
logfile=CONST.LOGFILE
+self,
+libdir=CONST.LIBDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+kernelroot=CONST.KERNELROOT,
+package=CONST.PACKAGE,
+logfile=CONST.LOGFILE
 ):
 self.libdir = libdir
 self.portage_configroot = portage_configroot

diff --git a/grs/PivotChroot.py b/grs/PivotChroot.py
index 8958c99..46cb839 100644
--- a/grs/PivotChroot.py
+++ b/grs/PivotChroot.py
@@ -27,7 +27,9 @@ class PivotChroot(Rotator):
 """ Move an inner chroot out to the new system portage configroot.  """
 
 def __init__(
-self, tmpdir=CONST.TMPDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
+self,
+tmpdir=CONST.TMPDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
 logfile=CONST.LOGFILE
 ):
 self.tmpdir = tmpdir

diff --git a/grs/Populate.py b/grs/Populate.py
index 8232c36..71c743a 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -27,8 +27,11 @@ class Populate():
 """
 
 def __init__(
-self, libdir=CONST.LIBDIR, workdir=CONST.WORKDIR,
-portage_configroot=CONST.PORTAGE_CONFIGROOT, logfile=CONST.LOGFILE
+self,
+libdir=CONST.LIBDIR,
+workdir=CONST.WORKDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+logfile=CONST.LOGFILE
 ):
 self.libdir = libdir
 self.workdir = workdir

diff --git a/grs/RunScript.py b/grs/RunScript.py
index ff45aed..1ecc221 100644
--- a/grs/RunScript.py
+++ b/grs/RunScript.py
@@ -25,7 +25,9 @@ class RunScript():
 """ Run a script within the chroot. """
 
 def __init__(
-self, libdir=CONST.LIBDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
+self,
+libdir=CONST.LIBDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
 logfile=CONST.LOGFILE
 ):
 self.libdir = libdir

diff --git a/grs/Seed.py b/grs/Seed.py
index f610228..ae8c524 100644
--- a/grs/Seed.py
+++ b/grs/Seed.py
@@ -29,8 +29,12 @@ class Seed(Rotator):
 """ Download a stage tarball and unpack it into an empty system portage 
configroot. """
 
 def __init__(
-self, stage_uri, tmpdir=CONST.TMPDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
-package=CONST.PACKAGE, logfile=CONST.LOGFILE
+self,
+stage_uri,
+tmpdir=CONST.TMPDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+package=CONST.PACKAGE,
+logfile=CONST.LOGFILE
 ):
 self.stage_uri = stage_uri
 self.portage_configroot = portage_configroot

diff --git a/grs/TarIt.py b/grs/TarIt.py
index b3d3b32..aef1b42 100644
--- a/grs/TarIt.py
+++ b/grs/TarIt.py
@@ -25,7 +25,12 @@ from grs.HashIt import HashIt
 class TarIt(HashIt):
 """ Create a tarball of the system. """
 
-def __init__(self, name, portage_configroot=CONST.PORTAGE_CONFIGROOT, 
logfile=CONST.LOGFILE):
+def __init__(
+self,
+name,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+logfile=CONST.LOGFILE
+):
 self.portage_configroot = portage_configroot
 self.logfile = logfile
 # Prepare a year, month and day for a tarball name timestamp.



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: 8a9bfffe0feb3b3165392216370f13742a863ca3
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Jan 15 01:31:35 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Jan 15 01:31:35 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=8a9bfffe

grs/Netboot.py: fix location of ISO tarball under /usr/share

 grs/Netboot.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 976a24d..33c7b9d 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -119,7 +119,7 @@ class Netboot(HashIt):
 # locating the tarball
 if do_cd == 'cd':
 # TODO: Before a regular release, we'll have to fix this path
-tarball_path = '/usr/share/grs-/ISO-1.tar.gz'
+tarball_path = '/usr/share/grs/ISO-1.tar.gz'
 cmd = 'tar --xattrs -xf %s -C %s' % (tarball_path, self.kernelroot)
 Execute(cmd, timeout=120, logfile=self.logfile)
 



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: 07caf3e213b541c6e165e1d65d73640cb2deee10
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Jan 15 01:23:31 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Jan 15 01:23:31 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=07caf3e2

grs/Netboot.py: return to using busybox from system root

 grs/Kernel.py  | 1 -
 grs/Netboot.py | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 924bdf9..fe411bd 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -123,7 +123,6 @@ class Kernel():
 cmd += '--module-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
 cmd += '--arch-override=%s ' % arch
-cmd += '--utils-arch=%s '% arch
 if has_modules:
 cmd += 'all'
 else:

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 6b1fe7c..976a24d 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -81,6 +81,7 @@ class Netboot(HashIt):
 a kernel and initramfs is to drop the Kernel.py module altogether and
 emerge genkernel in the fledgeling system via the script directive, set
 genkernel.conf via the populate directive and then just run genkernel.
+'''
 
 # 2.5 Don't trust genkernel's busybox, but copy in our own version
 # built in the system chroot.  This ensures it will work on the
@@ -89,7 +90,6 @@ class Netboot(HashIt):
 busybox_src = os.path.join(self.portage_configroot, 'bin/busybox')
 busybox_dst = os.path.join(self.kernelroot, 'initramfs/bin/busybox')
 shutil.copy(busybox_src, busybox_dst)
-'''
 
 # 3. Make the squashfs image in the tmpdir directory.
 squashfs_dir = os.path.join(initramfs_root, 'mnt/cdrom')



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: 55b0ee8dbf49619836f9a4dffa8b5401e449dfd2
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 14 18:22:01 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 14 18:22:01 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=55b0ee8d

grs/Kernel.py: utils to have same arch as kernel

 grs/Kernel.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index fe411bd..924bdf9 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -123,6 +123,7 @@ class Kernel():
 cmd += '--module-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
 cmd += '--arch-override=%s ' % arch
+cmd += '--utils-arch=%s '% arch
 if has_modules:
 cmd += 'all'
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: 1027c98b5617fceeadc96f479284d645e35595c5
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 14 17:05:30 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 14 17:05:30 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=1027c98b

grs/Netboot.py: fix path to ISO directory

 grs/Netboot.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index c012c05..6b1fe7c 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -47,7 +47,7 @@ class Netboot(HashIt):
 self.medium_name = 'initramfs-%s-%s%s%s' % (name, self.year, 
self.month, self.day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
 self.kernelname = 'kernel-%s-%s%s%s' % (name, self.year, self.month, 
self.day)
-self.cd_name = '%s-%s%s%s.ISO' % (name, self.year, self.month, 
self.day)
+self.cd_name = '%s-%s%s%s.iso' % (name, self.year, self.month, 
self.day)
 
 
 def netbootit(self, do_cd=None, alt_name=None):
@@ -118,8 +118,9 @@ class Netboot(HashIt):
 # TODO: This code is rushed and we need a better way of
 # locating the tarball
 if do_cd == 'cd':
-tarball_path = '/usr/share/grs-*/ISO-*.tar.gz'
-cmd = 'tar --xattrs -xf %s -C %s' % (tarball_path, initramfs_root)
+# TODO: Before a regular release, we'll have to fix this path
+tarball_path = '/usr/share/grs-/ISO-1.tar.gz'
+cmd = 'tar --xattrs -xf %s -C %s' % (tarball_path, self.kernelroot)
 Execute(cmd, timeout=120, logfile=self.logfile)
 
 # Note: we are copying the netboot kernel and initramfs into



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: e98dba630d78e2dbd97b1e05df7a37b5f320a78c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 14 15:02:40 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 14 15:02:40 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=e98dba63

grs/Interpret.py: fix bug in semantic interpreter

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 2f3d5a5..74d04e3 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -247,7 +247,7 @@ class Interpret(Daemon):
 elif verb == 'netbootit':
 # 'netbootit' can either be just a 'verb', 'verb obj' or 
'verb obj obj'
 if len(objs) == 2:
-semantic_action(_line, objs, 1, _nb.netbootit, 
objs[0], obj[1])
+semantic_action(_line, objs, 2, _nb.netbootit, 
objs[0], obj[1])
 elif len(objs) == 1:
 semantic_action(_line, objs, 1, _nb.netbootit, objs[0])
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: d5ea03d6dca068ea7c4ee01209f2be600c52359b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 14 14:37:29 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 14 14:37:29 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=d5ea03d6

grs/Netboot.py: correct unpacking of ISO tarball

 grs/Netboot.py | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 60cb027..c012c05 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -119,12 +119,8 @@ class Netboot(HashIt):
 # locating the tarball
 if do_cd == 'cd':
 tarball_path = '/usr/share/grs-*/ISO-*.tar.gz'
-cmd = 'tar -Jcf %s .' % (tarball_path)
-
-cwd = os.getcwd()
-os.chdir(initramfs_root)
-Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
-os.chdir(cwd)
+cmd = 'tar --xattrs -xf %s -C %s' % (tarball_path, initramfs_root)
+Execute(cmd, timeout=120, logfile=self.logfile)
 
 # Note: we are copying the netboot kernel and initramfs into
 # the ISO directory, so the kernel_dst and initramfs_dst above



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-14 Thread Anthony G. Basile
commit: f4caf3c0c28d0773f29d044aadcb3ec507ccf662
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Jan 14 14:07:28 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Jan 14 14:07:28 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=f4caf3c0

grs/Netboot.py: add option to make efi hybrid bootable CD

 grs/Interpret.py |  6 --
 grs/Netboot.py   | 52 +++-
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 9baf41b..2f3d5a5 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -245,8 +245,10 @@ class Interpret(Daemon):
 semantic_action(_line, objs, 0, _io.isoit)
 medium_type = 'isoit'
 elif verb == 'netbootit':
-# 'netbootit' can either be just a verb, or a 'verb obj' 
pair.
-if len(objs):
+# 'netbootit' can either be just a 'verb', 'verb obj' or 
'verb obj obj'
+if len(objs) == 2:
+semantic_action(_line, objs, 1, _nb.netbootit, 
objs[0], obj[1])
+elif len(objs) == 1:
 semantic_action(_line, objs, 1, _nb.netbootit, objs[0])
 else:
 semantic_action(_line, objs, 0, _nb.netbootit)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index ae5a0a4..60cb027 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -47,9 +47,10 @@ class Netboot(HashIt):
 self.medium_name = 'initramfs-%s-%s%s%s' % (name, self.year, 
self.month, self.day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
 self.kernelname = 'kernel-%s-%s%s%s' % (name, self.year, self.month, 
self.day)
+self.cd_name = '%s-%s%s%s.ISO' % (name, self.year, self.month, 
self.day)
 
 
-def netbootit(self, alt_name=None):
+def netbootit(self, do_cd=None, alt_name=None):
 """ TODO """
 if alt_name:
 self.medium_name = 'initramfs-%s-%s%s%s' % (alt_name, self.year, 
self.month, self.day)
@@ -112,3 +113,52 @@ class Netboot(HashIt):
 os.chdir(initramfs_root)
 Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
 os.chdir(cwd)
+
+# 6. If do_cd='cd' then we package a bootable CD image
+# TODO: This code is rushed and we need a better way of
+# locating the tarball
+if do_cd == 'cd':
+tarball_path = '/usr/share/grs-*/ISO-*.tar.gz'
+cmd = 'tar -Jcf %s .' % (tarball_path)
+
+cwd = os.getcwd()
+os.chdir(initramfs_root)
+Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
+os.chdir(cwd)
+
+# Note: we are copying the netboot kernel and initramfs into
+# the ISO directory, so the kernel_dst and initramfs_dst above
+# are the sources for these files
+iso_dir = os.path.join(self.kernelroot, 'ISO')
+isolinux_dir = os.path.join(iso_dir, 'isolinux')
+shutil.copy(kernel_dst, '%s/kernel' % (isolinux_dir))
+shutil.copy(initramfs_dst, '%s/initrd' % (isolinux_dir))
+
+# Note gentoo.efimg and isolinux.bin are in the ISO tarball
+# isolinux.bin comes from sys-boot/syslinux
+# gentoo.efimg is created using
+#  1) dd if=/dev/zero of=gentoo.efimg bs=1k count=16k
+#  2) mkfs.vfat -F 16 -n GENTOO gentoo.efimg
+# gentoo.efimg contains ./EFI/BOOT/BOOTX64.EFI
+# BOOTX64.EFI is created using
+#  1) mount -o loop gentoo.efimg zzz
+#  2) mkdir -p zzz/EFI/BOOT/
+#  3) grub-mkstandalone /boot/grub/grub.cfg=grub-stub.cfg 
--compress=xz -O x86_64-efi -o zzz/EFI/BOOT/BOOTX64.EFI
+#  4) umount zzz
+# Here grub-stub.cfg contains the following lines
+#  search --no-floppy --set=root --file /grub/grub.cfg
+#  configfile /grub/grub.cfg
+args = '-J -R -z '  # Joliet/Rock Ridge/RRIP
+args += '-b isolinux/isolinux.bin ' # Use isolinux boot
+args += '-c isolinux/boot.cat ' # Create the catalog file
+args += '-no-emul-boot '# No disk emulation for El 
Torito
+args += '-boot-load-size 4 '# 4x512-bit sectors for 
no-emulation mode
+args += '-boot-info-table ' # Create El Torito boot 
info table
+args += '-eltorito-alt-boot '   # Add an alternative boot 
entry
+args += '-eltorito-platform efi '   # The additional boot 
entry is EFI
+args += '-b gentoo.efimg '  # Use EFI boot
+args += '-no-emul-boot '# No disk emulation for El 
Torito
+
+cd_path = os.path.join(self.tmpdir, self.cd_name)
+cmd = 'mkisofs %s -o 

[gentoo-commits] proj/grss:master commit in: grs/

2018-01-13 Thread Anthony G. Basile
commit: 75b1b7cc4faf3c2fd455a5b6260e51c2b2a38c0b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Jan 13 17:37:04 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Jan 13 17:37:04 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=75b1b7cc

grs/Netboot.py: change name of source init script for netboot

Since we want an init script for ISO images too, we need to rename
the netboot init script to avoid a name collision.

 grs/Netboot.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 307b3b3..ae5a0a4 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -99,7 +99,7 @@ class Netboot(HashIt):
 Execute(cmd, timeout=None, logfile=self.logfile)
 
 # 4. Copy in the init script
-init_src = os.path.join(self.libdir, 'scripts/init')
+init_src = os.path.join(self.libdir, 'scripts/init.netboot')
 init_dst = os.path.join(initramfs_root, 'init')
 shutil.copy(init_src, init_dst)
 os.chmod(init_dst, 0o0755)



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-10 Thread Anthony G. Basile
commit: 7fdb50bd3be0467d2bfefac8fde9554ed7956cce
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Jan 10 21:01:55 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Jan 10 21:01:55 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=7fdb50bd

grs/Netboot.py: switch from xz to gzip compression

 grs/Netboot.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 985bcfd..307b3b3 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -65,9 +65,9 @@ class Netboot(HashIt):
 shutil.rmtree(initramfs_root, ignore_errors=True)
 os.makedirs(initramfs_root, mode=0o755, exist_ok=False)
 
-# We will only use xz compression
+# We will use gzip compression
 initramfs_src = os.path.join(self.portage_configroot, 'boot/initramfs')
-cmd = 'xz -dc %s | cpio -idv' % (initramfs_src)
+cmd = 'cat %s | gunzip | cpio -idv' % (initramfs_src)
 
 cwd = os.getcwd()
 os.chdir(initramfs_root)
@@ -95,7 +95,7 @@ class Netboot(HashIt):
 shutil.rmtree(squashfs_dir, ignore_errors=True)
 os.makedirs(squashfs_dir, mode=0o755, exist_ok=False)
 squashfs_path = os.path.join(squashfs_dir, 'image.squashfs')
-cmd = 'mksquashfs %s %s -xattrs -comp xz' % (self.portage_configroot, 
squashfs_path)
+cmd = 'mksquashfs %s %s -xattrs -comp gzip' % 
(self.portage_configroot, squashfs_path)
 Execute(cmd, timeout=None, logfile=self.logfile)
 
 # 4. Copy in the init script
@@ -106,7 +106,7 @@ class Netboot(HashIt):
 
 # 5. Repack
 initramfs_dst = os.path.join(self.tmpdir, self.medium_name)
-cmd = 'find . -print | cpio -H newc -o | xz -9e --check=none -z -f > 
%s' % initramfs_dst
+cmd = 'find . -print | cpio -H newc -o | gzip -9 -f > %s' % 
initramfs_dst
 
 cwd = os.getcwd()
 os.chdir(initramfs_root)



[gentoo-commits] proj/grss:master commit in: grs/

2018-01-10 Thread Anthony G. Basile
commit: e11c2d0de7b0aec7157a3fd4d5344eb79304bd86
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Jan 10 20:40:24 2018 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Jan 10 20:40:24 2018 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=e11c2d0d

grs/Netboot.py: use busybox built by genkernel

 grs/Netboot.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 1b3ea80..985bcfd 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -74,6 +74,13 @@ class Netboot(HashIt):
 Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
 os.chdir(cwd)
 
+''' The issue here was that busybox was build in the host env like the
+kernel and that means that we are using the host's ARCH and the 
cpuflags
+which are now poluting the initramfs.  The better approach to building
+a kernel and initramfs is to drop the Kernel.py module altogether and
+emerge genkernel in the fledgeling system via the script directive, set
+genkernel.conf via the populate directive and then just run genkernel.
+
 # 2.5 Don't trust genkernel's busybox, but copy in our own version
 # built in the system chroot.  This ensures it will work on the
 # target system.
@@ -81,6 +88,7 @@ class Netboot(HashIt):
 busybox_src = os.path.join(self.portage_configroot, 'bin/busybox')
 busybox_dst = os.path.join(self.kernelroot, 'initramfs/bin/busybox')
 shutil.copy(busybox_src, busybox_dst)
+'''
 
 # 3. Make the squashfs image in the tmpdir directory.
 squashfs_dir = os.path.join(initramfs_root, 'mnt/cdrom')



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-28 Thread Anthony G. Basile
commit: dc4ac6709b7d4eefa335995483151a8c47052408
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Dec 28 17:54:24 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Dec 28 17:54:24 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=dc4ac670

grs/Netboot.py: use only xz compression

 grs/Netboot.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 62cc17c..1b3ea80 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -65,6 +65,7 @@ class Netboot(HashIt):
 shutil.rmtree(initramfs_root, ignore_errors=True)
 os.makedirs(initramfs_root, mode=0o755, exist_ok=False)
 
+# We will only use xz compression
 initramfs_src = os.path.join(self.portage_configroot, 'boot/initramfs')
 cmd = 'xz -dc %s | cpio -idv' % (initramfs_src)
 
@@ -97,7 +98,7 @@ class Netboot(HashIt):
 
 # 5. Repack
 initramfs_dst = os.path.join(self.tmpdir, self.medium_name)
-cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_dst
+cmd = 'find . -print | cpio -H newc -o | xz -9e --check=none -z -f > 
%s' % initramfs_dst
 
 cwd = os.getcwd()
 os.chdir(initramfs_root)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-28 Thread Anthony G. Basile
commit: d8303e6a6da6ab34a2d08b04bc026a211e00d2be
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Dec 28 17:19:19 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Dec 28 17:19:19 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=d8303e6a

grs/Netboot.py: build busybox inside the system chroot

 grs/Netboot.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index c4bb9ff..62cc17c 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -73,6 +73,14 @@ class Netboot(HashIt):
 Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
 os.chdir(cwd)
 
+# 2.5 Don't trust genkernel's busybox, but copy in our own version
+# built in the system chroot.  This ensures it will work on the
+# target system.
+# TODO: We need to make sure that we've linked busybox staticly.
+busybox_src = os.path.join(self.portage_configroot, 'bin/busybox')
+busybox_dst = os.path.join(self.kernelroot, 'initramfs/bin/busybox')
+shutil.copy(busybox_src, busybox_dst)
+
 # 3. Make the squashfs image in the tmpdir directory.
 squashfs_dir = os.path.join(initramfs_root, 'mnt/cdrom')
 shutil.rmtree(squashfs_dir, ignore_errors=True)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-27 Thread Anthony G. Basile
commit: 6f93749d08da2eac91cfc424eac5b5afaf23ab3b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Dec 27 09:25:45 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Dec 27 09:25:45 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=6f93749d

grs/Netboot.py: fix alt digest name

 grs/Netboot.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 469418c..c4bb9ff 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -53,9 +53,9 @@ class Netboot(HashIt):
 """ TODO """
 if alt_name:
 self.medium_name = 'initramfs-%s-%s%s%s' % (alt_name, self.year, 
self.month, self.day)
-self.digest_name = 'initramfs-%s.DIGESTS' % self.medium_name
+self.digest_name = '%s.DIGESTS' % self.medium_name
 
-# 1. Move the kernel to the tmpdir directory.
+# 1. Copy the kernel to the tmpdir directory.
 kernel_src = os.path.join(self.portage_configroot, 'boot/kernel')
 kernel_dst = os.path.join(self.tmpdir, self.kernelname)
 shutil.copy(kernel_src, kernel_dst)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-26 Thread Anthony G. Basile
commit: 906e7ab1dd3b7dfb10bafae1bcdf4a1bccc55cd8
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Dec 26 14:18:58 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Dec 26 14:18:58 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=906e7ab1

grs/Netboot.py: move kernel/initramfs to tmpdir

 grs/Netboot.py | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 0918f1a..469418c 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -45,7 +45,8 @@ class Netboot(HashIt):
 self.month = str(datetime.now().month).zfill(2)
 self.day = str(datetime.now().day).zfill(2)
 self.medium_name = 'initramfs-%s-%s%s%s' % (name, self.year, 
self.month, self.day)
-self.digest_name = 'initramfs-%s.DIGESTS' % self.medium_name
+self.digest_name = '%s.DIGESTS' % self.medium_name
+self.kernelname = 'kernel-%s-%s%s%s' % (name, self.year, self.month, 
self.day)
 
 
 def netbootit(self, alt_name=None):
@@ -54,30 +55,25 @@ class Netboot(HashIt):
 self.medium_name = 'initramfs-%s-%s%s%s' % (alt_name, self.year, 
self.month, self.day)
 self.digest_name = 'initramfs-%s.DIGESTS' % self.medium_name
 
-# 0. Pepare netboot directory
-netboot_dir = os.path.join(self.tmpdir, 'netboot')
-shutil.rmtree(netboot_dir, ignore_errors=True)
-os.makedirs(netboot_dir, mode=0o755, exist_ok=False)
-
-# 1. Move the kernel into the netboot directory.
-kernel_dir = os.path.join(self.portage_configroot, 'boot')
-kernel_path = os.path.join(kernel_dir, 'kernel')
-shutil.copy(kernel_path, netboot_dir)
+# 1. Move the kernel to the tmpdir directory.
+kernel_src = os.path.join(self.portage_configroot, 'boot/kernel')
+kernel_dst = os.path.join(self.tmpdir, self.kernelname)
+shutil.copy(kernel_src, kernel_dst)
 
 # 2. Unpack the initramfs into kernelroot/initramfs direcotry
 initramfs_root = os.path.join(self.kernelroot, 'initramfs')
 shutil.rmtree(initramfs_root, ignore_errors=True)
 os.makedirs(initramfs_root, mode=0o755, exist_ok=False)
 
-initramfs_path = os.path.join(kernel_dir, 'initramfs')
-cmd = 'xz -dc %s | cpio -idv' % (initramfs_path)
+initramfs_src = os.path.join(self.portage_configroot, 'boot/initramfs')
+cmd = 'xz -dc %s | cpio -idv' % (initramfs_src)
 
 cwd = os.getcwd()
 os.chdir(initramfs_root)
 Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
 os.chdir(cwd)
 
-# 3. Make the squashfs image in the netboot directory.
+# 3. Make the squashfs image in the tmpdir directory.
 squashfs_dir = os.path.join(initramfs_root, 'mnt/cdrom')
 shutil.rmtree(squashfs_dir, ignore_errors=True)
 os.makedirs(squashfs_dir, mode=0o755, exist_ok=False)
@@ -92,8 +88,8 @@ class Netboot(HashIt):
 os.chmod(init_dst, 0o0755)
 
 # 5. Repack
-initramfs_path = os.path.join(netboot_dir, self.medium_name)
-cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_path
+initramfs_dst = os.path.join(self.tmpdir, self.medium_name)
+cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_dst
 
 cwd = os.getcwd()
 os.chdir(initramfs_root)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-25 Thread Anthony G. Basile
commit: eb8e68b4cd1ff1f90dcf93ed8c1a58f71f4332d3
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Dec 25 23:41:21 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Dec 25 23:41:21 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=eb8e68b4

grs/Interpret.py: fix typo

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index d6fdad9..9baf41b 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -135,7 +135,7 @@ class Interpret(Daemon):
 _ke = Kernel(libdir, portage_configroot, kernelroot, package, logfile)
 _bi = TarIt(name, portage_configroot, logfile)
 _io = ISOIt(name, libdir, tmpdir, portage_configroot, logfile)
-_nb - Netboot(name, libdir, tmpdir, portage_configroot, kernelroot, 
logfile)
+_nb = Netboot(name, libdir, tmpdir, portage_configroot, kernelroot, 
logfile)
 
 # Just in case /var/tmp/grs doesn't already exist.
 os.makedirs(tmpdir, mode=0o755, exist_ok=True)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-25 Thread Anthony G. Basile
commit: 50e55fd33ba1bfcdd22a68cd7302716a7c5366f2
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Dec 26 00:03:17 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Dec 26 00:03:17 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=50e55fd3

grs/Netboot.py: add self.kernelroot

 grs/Netboot.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 11a78d2..22279cc 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -38,6 +38,7 @@ class Netboot(HashIt):
 self.libdir = libdir
 self.tmpdir = tmpdir
 self.portage_configroot = portage_configroot
+self.kernelroot = kernelroot
 self.logfile = logfile
 # Prepare a year, month and day for a name timestamp.
 self.year = str(datetime.now().year).zfill(4)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-25 Thread Anthony G. Basile
commit: ba36d48d5de17bafe584d74640e41660d6aa09b4
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Dec 26 00:04:26 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Dec 26 00:04:26 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=ba36d48d

grs/Netboot.py: chmod 755 the init script

 grs/Netboot.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/grs/Netboot.py b/grs/Netboot.py
index 22279cc..0918f1a 100644
--- a/grs/Netboot.py
+++ b/grs/Netboot.py
@@ -86,9 +86,10 @@ class Netboot(HashIt):
 Execute(cmd, timeout=None, logfile=self.logfile)
 
 # 4. Copy in the init script
-init_path = os.path.join(self.libdir, 'scripts/init')
-shutil.copy(init_path, initramfs_root)
-
+init_src = os.path.join(self.libdir, 'scripts/init')
+init_dst = os.path.join(initramfs_root, 'init')
+shutil.copy(init_src, init_dst)
+os.chmod(init_dst, 0o0755)
 
 # 5. Repack
 initramfs_path = os.path.join(netboot_dir, self.medium_name)



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-25 Thread Anthony G. Basile
commit: 0bf65c519cb9190fa5fffe66cd644606e5d67bb1
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Dec 25 23:38:31 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Dec 25 23:38:31 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=0bf65c51

grs/__init__.py: import Netboot class

 grs/Interpret.py | 1 +
 grs/__init__.py  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 7bdfa01..d6fdad9 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -27,6 +27,7 @@ from grs.ISOIt import ISOIt
 from grs.Log import Log
 from grs.Kernel import Kernel
 from grs.MountDirectories import MountDirectories
+from grs.Netboot import Netboot
 from grs.PivotChroot import PivotChroot
 from grs.Populate import Populate
 from grs.RunScript import RunScript

diff --git a/grs/__init__.py b/grs/__init__.py
index fb1b64b..4c5f585 100644
--- a/grs/__init__.py
+++ b/grs/__init__.py
@@ -25,6 +25,7 @@ from grs.ISOIt import ISOIt
 from grs.Log import Log
 from grs.Kernel import Kernel
 from grs.MountDirectories import MountDirectories
+from grs.Netboot import Netboot
 from grs.PivotChroot import PivotChroot
 from grs.Populate import Populate
 from grs.Rotator import Rotator



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-25 Thread Anthony G. Basile
commit: 9216169ba661bf2506468b394c525bc727feba62
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Dec 25 23:23:31 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Dec 25 23:24:24 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=9216169b

grs/Netboot.py: initial commit of netbootit directive.

 grs/Interpret.py | 10 ++
 grs/Netboot.py   | 99 
 2 files changed, 109 insertions(+)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 523cdda..7bdfa01 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -134,6 +134,7 @@ class Interpret(Daemon):
 _ke = Kernel(libdir, portage_configroot, kernelroot, package, logfile)
 _bi = TarIt(name, portage_configroot, logfile)
 _io = ISOIt(name, libdir, tmpdir, portage_configroot, logfile)
+_nb - Netboot(name, libdir, tmpdir, portage_configroot, kernelroot, 
logfile)
 
 # Just in case /var/tmp/grs doesn't already exist.
 os.makedirs(tmpdir, mode=0o755, exist_ok=True)
@@ -242,11 +243,20 @@ class Interpret(Daemon):
 else:
 semantic_action(_line, objs, 0, _io.isoit)
 medium_type = 'isoit'
+elif verb == 'netbootit':
+# 'netbootit' can either be just a verb, or a 'verb obj' 
pair.
+if len(objs):
+semantic_action(_line, objs, 1, _nb.netbootit, objs[0])
+else:
+semantic_action(_line, objs, 0, _nb.netbootit)
+medium_type = 'netbootit'
 elif verb == 'hashit':
 if medium_type == 'tarit':
 semantic_action(_line, objs, 0, _bi.hashit)
 elif medium_type == 'isoit':
 semantic_action(_line, objs, 0, _io.hashit)
+elif medium_type == 'netbootit':
+semantic_action(_line, objs, 0, _nb.hashit)
 else:
 raise Exception('Unknown medium to hash.')
 else:

diff --git a/grs/Netboot.py b/grs/Netboot.py
new file mode 100644
index 000..11a78d2
--- /dev/null
+++ b/grs/Netboot.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+#Netboot.py: this file is part of the GRS suite
+#Copyright (C) 2017  Anthony G. Basile
+#
+#This program is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with this program.  If not, see .
+
+import os
+import shutil
+from datetime import datetime
+from grs.Constants import CONST
+from grs.Execute import Execute
+from grs.HashIt import HashIt
+
+class Netboot(HashIt):
+""" Create a Netboot image of the system. """
+
+def __init__(
+self,
+name,
+libdir=CONST.LIBDIR,
+tmpdir=CONST.TMPDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT,
+kernelroot=CONST.KERNELROOT,
+logfile=CONST.LOGFILE
+):
+self.libdir = libdir
+self.tmpdir = tmpdir
+self.portage_configroot = portage_configroot
+self.logfile = logfile
+# Prepare a year, month and day for a name timestamp.
+self.year = str(datetime.now().year).zfill(4)
+self.month = str(datetime.now().month).zfill(2)
+self.day = str(datetime.now().day).zfill(2)
+self.medium_name = 'initramfs-%s-%s%s%s' % (name, self.year, 
self.month, self.day)
+self.digest_name = 'initramfs-%s.DIGESTS' % self.medium_name
+
+
+def netbootit(self, alt_name=None):
+""" TODO """
+if alt_name:
+self.medium_name = 'initramfs-%s-%s%s%s' % (alt_name, self.year, 
self.month, self.day)
+self.digest_name = 'initramfs-%s.DIGESTS' % self.medium_name
+
+# 0. Pepare netboot directory
+netboot_dir = os.path.join(self.tmpdir, 'netboot')
+shutil.rmtree(netboot_dir, ignore_errors=True)
+os.makedirs(netboot_dir, mode=0o755, exist_ok=False)
+
+# 1. Move the kernel into the netboot directory.
+kernel_dir = os.path.join(self.portage_configroot, 'boot')
+kernel_path = os.path.join(kernel_dir, 'kernel')
+shutil.copy(kernel_path, netboot_dir)
+
+# 2. Unpack the initramfs into kernelroot/initramfs direcotry
+initramfs_root = 

[gentoo-commits] proj/grss:master commit in: grs/

2017-12-23 Thread Anthony G. Basile
commit: 88b09b807c7c3f8e6da242eae864f9bc0c2daf33
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Dec 23 16:04:22 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Dec 23 16:04:22 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=88b09b80

grs/Interpret.py: fix number of args for _ke.kernel()

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 45eca5f..523cdda 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -227,7 +227,7 @@ class Interpret(Daemon):
 elif verb == 'pivot':
 semantic_action(_line, objs, 1, _pc.pivot, objs[0], _md)
 elif verb == 'kernel':
-semantic_action(_line, objs, 0, _ke.kernel, objs[0])
+semantic_action(_line, objs, 1, _ke.kernel, objs[0])
 elif verb == 'tarit':
 # 'tarit' can either be just a verb, or a 'verb obj' pair.
 if len(objs):



[gentoo-commits] proj/grss:master commit in: grs/

2017-12-23 Thread Anthony G. Basile
commit: f2fbce01954b6fadc3d18d7e9dba2934bdf204aa
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Dec 23 14:14:54 2017 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Dec 23 14:14:54 2017 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=f2fbce01

grs/Kernel.p: add arch on the kernel directive line

 grs/Interpret.py | 2 +-
 grs/Kernel.py| 7 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index ab16cfa..45eca5f 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -227,7 +227,7 @@ class Interpret(Daemon):
 elif verb == 'pivot':
 semantic_action(_line, objs, 1, _pc.pivot, objs[0], _md)
 elif verb == 'kernel':
-semantic_action(_line, objs, 0, _ke.kernel)
+semantic_action(_line, objs, 0, _ke.kernel, objs[0])
 elif verb == 'tarit':
 # 'tarit' can either be just a verb, or a 'verb obj' pair.
 if len(objs):

diff --git a/grs/Kernel.py b/grs/Kernel.py
index cd2ecee..fe411bd 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -69,7 +69,7 @@ class Kernel():
 return (gentoo_version, pkg_name, has_modules)
 
 
-def kernel(self):
+def kernel(self, arch='x86_64'):
 """ This emerges the kernel sources to a directory outside of the
 fledgeling system's portage configroot, builds and installs it
 to yet another external directory, bundles the kernel and modules
@@ -108,8 +108,8 @@ class Kernel():
 
 # Build and install the image outside the portage configroot so
 # we can both rsync it in *and* tarball it for downloads via grsup.
-# TODO: add more options (eg splash and firmware), which can be
-# specified vi the kernel line in the build script.
+# NOTE: more options (eg splash and firmware), can be specified
+# via the kernel line in the build script.
 cmd = 'genkernel '
 cmd += '--logfile=/dev/null '
 cmd += '--no-save-config '
@@ -122,6 +122,7 @@ class Kernel():
 cmd += '--bootdir=%s '   % boot_dir
 cmd += '--module-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
+cmd += '--arch-override=%s ' % arch
 if has_modules:
 cmd += 'all'
 else:



[gentoo-commits] proj/grss:master commit in: grs/

2016-03-23 Thread Anthony G. Basile
commit: 73b9004664d281b9e8bff36f81bf887d5c941d93
Author: Matteo Contri  tecem  it>
AuthorDate: Wed Mar 23 14:42:19 2016 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Mar 23 15:15:10 2016 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=73b90046

grs/Rotator.py: make glob stricter

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Rotator.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/grs/Rotator.py b/grs/Rotator.py
index a3684a9..f303c14 100644
--- a/grs/Rotator.py
+++ b/grs/Rotator.py
@@ -42,11 +42,12 @@ class Rotator():
 
 obj's paste an upper limit are deleted.
 """
-objs = glob.glob('%s.*' % obj)
+objs = glob.glob('%s.[0-9]*' % obj)
 indexed_obj = {}
 for _obj in objs:
 _match = re.search(r'^.+\.(\d+)$', _obj)
-indexed_obj[int(_match.group(1))] = _obj
+if (_match.group(1)):
+indexed_obj[int(_match.group(1))] = _obj
 count = list(indexed_obj.keys())
 count.sort()
 count.reverse()



[gentoo-commits] proj/grss:master commit in: grs/

2016-03-23 Thread Anthony G. Basile
commit: 53229170dbe506c5542bd9a68d3d909dfa93cc2c
Author: Matteo Contri  tecem  it>
AuthorDate: Wed Mar 23 14:42:19 2016 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Mar 23 15:11:41 2016 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=53229170

grs/Rotator.py: make glob more stricter

Signed-off-by: Anthony G. Basile  gentoo.org>

 grs/Rotator.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/grs/Rotator.py b/grs/Rotator.py
index a3684a9..f303c14 100644
--- a/grs/Rotator.py
+++ b/grs/Rotator.py
@@ -42,11 +42,12 @@ class Rotator():
 
 obj's paste an upper limit are deleted.
 """
-objs = glob.glob('%s.*' % obj)
+objs = glob.glob('%s.[0-9]*' % obj)
 indexed_obj = {}
 for _obj in objs:
 _match = re.search(r'^.+\.(\d+)$', _obj)
-indexed_obj[int(_match.group(1))] = _obj
+if (_match.group(1)):
+indexed_obj[int(_match.group(1))] = _obj
 count = list(indexed_obj.keys())
 count.sort()
 count.reverse()



[gentoo-commits] proj/grss:master commit in: grs/

2015-11-26 Thread Anthony G. Basile
commit: a92714aacc5da7c5075f1012656426616612534a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Nov 26 19:54:53 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Nov 26 19:54:53 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=a92714aa

grs/WorldConf.py: guard against / with no ebuilds.

 grs/WorldConf.py | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index 48b93af..83c2175 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -82,7 +82,11 @@ class WorldConf():
 # Construct a list of canonical named files for uninstalled pkgs.
 slot_atoms = []
 for _cp in uninstalled:
-_cpv = portdb.cp_list(_cp)[0]
+try:
+_cpv = portdb.cp_list(_cp)[0]
+except IndexError:
+print('Package with no ebuilds: %s' % _cp)
+continue
 slotvar = portdb.aux_get(_cpv, ['SLOT'])[0]
 try:
 _match = re.search(r'(.+?)\/(.+)', slotvar)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: 438ed1265ea9b4b7957d4b3b098abab6a37ebb5a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 19:10:10 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 19:10:10 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=438ed126

grs/Execute.py, Interpret.py: clean up signal code

While the following may look like a good idea, its not:

while True:
os.kill(pid, signal.SIGKILL)

If pid is zombied, we're stuck in an infinite loop.  Rather
for all processes in the cgroup we just aggressively send a
SIGKILL until only the first ancestor remains.

 grs/Execute.py   | 23 +++
 grs/Interpret.py | 18 +++---
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 0e70221..7b0e5a2 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -42,12 +42,6 @@ class Execute():
 logfile - A file to log output to.  If logfile = None, then we 
log
   to sys.stdout.
 """
-def signalexit():
-pid = os.getpid()
-while True:
-os.kill(pid, signal.SIGTERM)
-time.sleep(2.0)
-
 if shell:
 args = cmd
 else:
@@ -71,19 +65,16 @@ class Execute():
 if not timed_out:
 # _rc = None if we had a timeout
 _rc = proc.returncode
-if _rc:
-_file.write('EXIT CODE: %d\n' % _rc)
-if not failok:
-_file.write('SENDING SIGTERM\n')
-_file.close()
-signalexit()
+_file.write('EXIT CODE: %d\n' % _rc)
 
 if timed_out:
 _file.write('TIMEOUT ERROR: %s\n' % cmd)
-if not failok:
-_file.write('SENDING SIGTERM\n')
-_file.close()
-signalexit()
+
+if not failok and ( _rc != 0 or timed_out):
+pid = os.getpid()
+_file.write('SENDING SIGTERM: %s\n' % pid)
+_file.close()
+os.kill(pid, signal.SIGTERM)
 
 # Only close a logfile, don't close sys.stderr!
 if logfile:

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 3e2c408..5624fd4 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -64,12 +64,7 @@ class Interpret(Daemon):
 if mypid == pid:
 continue
 try:
-for i in range(10):
-os.kill(pid, signal.SIGTERM)
-time.sleep(0.2)
-while True:
-os.kill(pid, signal.SIGKILL)
-time.sleep(0.2)
+os.kill(pid, signal.SIGKILL)
 except ProcessLookupError:
 pass
 try:
@@ -79,13 +74,6 @@ class Interpret(Daemon):
 sys.exit(signum + 128)
 
 
-def signalexit():
-pid = os.getpid()
-while True:
-os.kill(pid, signal.SIGTERM)
-time.sleep(2.0)
-
-
 def semantic_action(_line, objs, nargs, func, *args):
 """ Execute the directive """
 err = None
@@ -104,7 +92,7 @@ class Interpret(Daemon):
 _lo.log('Bad command:   %s' % _line)
 _lo.log('Error message: %s' % err)
 _lo.log('SENDING SIGTERM\n')
-signalexit()
+os.kill(os.getpid(), signal.SIGTERM)
 
 
 def stampit(progress):
@@ -262,7 +250,7 @@ class Interpret(Daemon):
 _lo.log('Bad command: %s' % _line)
 _lo.log('Unknown verb: %s' % verb)
 _lo.log('SENDING SIGTERM\n')
-signalexit()
+os.kill(os.getpid(), signal.SIGTERM)
 
 stampit(progress)
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: e7233ec6f81bf3ec2fd77303c0bef67252c6494c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 19:42:36 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 19:42:36 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=e7233ec6

grs/Execute.py: suppress logging rc = 0.

 grs/Execute.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 7b0e5a2..87667be 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -65,7 +65,8 @@ class Execute():
 if not timed_out:
 # _rc = None if we had a timeout
 _rc = proc.returncode
-_file.write('EXIT CODE: %d\n' % _rc)
+if _rc != 0:
+_file.write('EXIT CODE: %d\n' % _rc)
 
 if timed_out:
 _file.write('TIMEOUT ERROR: %s\n' % cmd)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: ca4930493d12a8e2d8aa22ab70801f8569e88559
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 20:26:02 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 20:26:02 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=ca493049

lint: minor code cleanups.

 grs/Execute.py   | 3 +--
 grs/Interpret.py | 9 ++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 87667be..8d9da75 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -21,7 +21,6 @@ import signal
 import shlex
 import subprocess
 import sys
-import time
 from grs.Constants import CONST
 
 class Execute():
@@ -71,7 +70,7 @@ class Execute():
 if timed_out:
 _file.write('TIMEOUT ERROR: %s\n' % cmd)
 
-if not failok and ( _rc != 0 or timed_out):
+if not failok and (_rc != 0 or timed_out):
 pid = os.getpid()
 _file.write('SENDING SIGTERM: %s\n' % pid)
 _file.close()

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 5624fd4..ab16cfa 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -20,7 +20,6 @@ import os
 import re
 import signal
 import sys
-import time
 
 from grs.Constants import CONST
 from grs.Daemon import Daemon
@@ -81,6 +80,9 @@ class Interpret(Daemon):
 if self.mock_run:
 _lo.log(_line)
 return
+# We'll catch this exception to get in into the
+# GRS system log rather than the daemon log.  Without
+# the try-except, it would wind up in the daemon log.
 try:
 func(*args)
 except Exception as excpt:
@@ -89,10 +91,11 @@ class Interpret(Daemon):
 err = 'Number of parameters incorrect.'
 
 if err:
+pid = os.getpid()
 _lo.log('Bad command:   %s' % _line)
 _lo.log('Error message: %s' % err)
-_lo.log('SENDING SIGTERM\n')
-os.kill(os.getpid(), signal.SIGTERM)
+_lo.log('SENDING SIGTERM to %d' % pid)
+os.kill(pid, signal.SIGTERM)
 
 
 def stampit(progress):



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: 0d4eeb1055010e0ee9b08ee6e9296fff0f4021dd
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 11:25:46 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 11:25:46 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=0d4eeb10

grs/Interpret.py: don't run sync/seed during mock run.

 grs/Interpret.py | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index ea6d2e2..c90a9bd 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -156,13 +156,19 @@ class Interpret(Daemon):
 # sync() is done unconditionally for an update run.
 progress = os.path.join(tmpdir, '.completed_sync')
 if not os.path.exists(progress) or self.update_run:
-_sy.sync()
+if self.mock_run:
+_lo.log(_line)
+else:
+_sy.sync()
 stampit(progress)
 
 # seed() is never done for an update run
 progress = os.path.join(tmpdir, '.completed_seed')
 if not os.path.exists(progress) and not self.update_run:
-_se.seed()
+if self.mock_run:
+_lo.log(_line)
+else:
+_se.seed()
 stampit(progress)
 
 # Read the build script and execute a line at a time.



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: 30cbbe17a8f849e3fb41dc9a85756581c6395c6f
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 11:50:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 11:50:06 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=30cbbe17

grs/Interpret.py: fix minor errors in semantic_action().

 grs/Interpret.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 2bf880c..a42400d 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -94,8 +94,9 @@ class Interpret(Daemon):
 _lo.log(_line)
 return
 try:
-   f(*args) 
-except Exception as err:
+   func(*args) 
+except Exception as excpt:
+err = excpt
 pass
 else:
 err = 'Number of parameters incorrect.'



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: 4476229290dcd40ef1dd7320b84ea86e5e1b8fa9
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 12:28:22 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 12:28:22 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=44762292

grs/Interpret.py: fix minor errors.

 grs/Interpret.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index a42400d..3e2c408 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -94,10 +94,9 @@ class Interpret(Daemon):
 _lo.log(_line)
 return
 try:
-   func(*args) 
+func(*args)
 except Exception as excpt:
 err = excpt
-pass
 else:
 err = 'Number of parameters incorrect.'
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: c8e8855012e458322bacf094ac2e06ccac716cb0
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 11:15:44 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 11:15:44 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=c8e88550

grs/Interpret.py: exec() is bad, get rid of it.

 grs/Interpret.py | 55 ++-
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 12271d6..ea6d2e2 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -86,18 +86,23 @@ class Interpret(Daemon):
 time.sleep(2.0)
 
 
-def semantic_action(_line, objs, num_objs, execstr):
+def semantic_action(_line, objs, nargs, func, *args):
 """ Execute the directive """
-if self.mock_run:
-_lo.log(_line)
-return
-try:
-if len(objs) < num_objs:
-raise Exception('Number of objs for verb incorrect.')
-exec(execstr)
-except Exception as err:
-_lo.log('Bad command: %s' % _line)
-_lo.log('Exception throw: %s' % err)
+err = None
+if len(objs) == nargs:
+if self.mock_run:
+_lo.log(_line)
+return
+try:
+   f(*args) 
+except Exception as err:
+pass
+else:
+err = 'Number of parameters incorrect.'
+
+if err:
+_lo.log('Bad command:   %s' % _line)
+_lo.log('Error message: %s' % err)
 _lo.log('SENDING SIGTERM\n')
 signalexit()
 
@@ -213,44 +218,44 @@ class Interpret(Daemon):
 if verb == 'log':
 if objs[0] == 'stamp':
 objs[0] = '='*80
-semantic_action(_line, objs, 1, '_lo.log(\' 
\'.join(objs))')
+semantic_action(_line, objs, 1, _lo.log, ' '.join(objs))
 elif verb == 'mount':
-semantic_action(_line, objs, 0, '_md.mount_all()')
+semantic_action(_line, objs, 0, _md.mount_all)
 elif verb == 'unmount':
-semantic_action(_line, objs, 0, '_md.umount_all()')
+semantic_action(_line, objs, 0, _md.umount_all)
 elif verb == 'populate':
-semantic_action(_line, objs, 1, 
'_po.populate(cycle=int(objs[0]))')
+semantic_action(_line, objs, 1, _po.populate, int(objs[0]))
 elif verb == 'runscript':
-semantic_action(_line, objs, 1, '_ru.runscript(objs[0])')
+semantic_action(_line, objs, 1, _ru.runscript, objs[0])
 elif verb == 'pivot':
-semantic_action(_line, objs, 1, '_pc.pivot(objs[0], _md)')
+semantic_action(_line, objs, 1, _pc.pivot, objs[0], _md)
 elif verb == 'kernel':
-semantic_action(_line, objs, 0, '_ke.kernel()')
+semantic_action(_line, objs, 0, _ke.kernel)
 elif verb == 'tarit':
 # 'tarit' can either be just a verb, or a 'verb obj' pair.
 if len(objs):
-semantic_action(_line, objs, 1, '_bi.tarit(objs[0])')
+semantic_action(_line, objs, 1, _bi.tarit, objs[0])
 else:
-semantic_action(_line, objs, 0, '_bi.tarit()')
+semantic_action(_line, objs, 0, _bi.tarit)
 medium_type = 'tarit'
 elif verb == 'isoit':
 # 'isoit' can either be just a verb, or a 'verb obj' pair.
 if len(objs):
-semantic_action(_line, objs, 1, '_io.isoit(objs[1])')
+semantic_action(_line, objs, 1, _io.isoit, objs[0])
 else:
-semantic_action(_line, objs, 0, '_io.isoit()')
+semantic_action(_line, objs, 0, _io.isoit)
 medium_type = 'isoit'
 elif verb == 'hashit':
 if medium_type == 'tarit':
-semantic_action(_line, objs, 0, '_bi.hashit()')
+semantic_action(_line, objs, 0, _bi.hashit)
 elif medium_type == 'isoit':
-semantic_action(_line, objs, 0, '_io.hashit()')
+semantic_action(_line, objs, 0, _io.hashit)
 else:
 raise Exception('Unknown medium to hash.')
 else:
 _lo.log('Bad command: %s' % _line)
 _lo.log('Unknown verb: %s' % verb)
-  

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-10 Thread Anthony G. Basile
commit: 5c8cd4560eb2fe3acf10d90f0fc3798c60b9d1b3
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 11:28:32 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 11:28:32 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=5c8cd456

grs/Interpret.py: fix logging during sync/seed.

 grs/Interpret.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index c90a9bd..2bf880c 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -157,7 +157,7 @@ class Interpret(Daemon):
 progress = os.path.join(tmpdir, '.completed_sync')
 if not os.path.exists(progress) or self.update_run:
 if self.mock_run:
-_lo.log(_line)
+_lo.log('sync')
 else:
 _sy.sync()
 stampit(progress)
@@ -166,7 +166,7 @@ class Interpret(Daemon):
 progress = os.path.join(tmpdir, '.completed_seed')
 if not os.path.exists(progress) and not self.update_run:
 if self.mock_run:
-_lo.log(_line)
+_lo.log('seed')
 else:
 _se.seed()
 stampit(progress)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 3a1205cfcc515ac07fa63e20c8c9988731cbc3fb
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Oct  9 23:12:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Oct  9 23:38:34 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=3a1205cf

grs/Interpret.py: skip non-functional build lines

 grs/Interpret.py | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 072574e..43c0e48 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -161,9 +161,11 @@ class Interpret(Daemon):
 for _line in _file.readlines():
 line_number += 1
 
-# Skip lines with initial # as comments.
-_match = re.search(r'^(#).*$', _line)
-if _match:
+# Do nothing for lines with initial # or blank lines.
+# Create a progress stamp only if we are not doing an update 
run.
+if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+if not self.update_run:
+stampit(progress)
 continue
 
 # For a release run, execute every line of the build script.
@@ -198,9 +200,6 @@ class Interpret(Daemon):
 # build script are implemented.  Note: 'hashit' can only come
 # after 'tarit' or 'isoit' so that it knows the medium_name
 # to hash, ie whether its a .tar.xz or a .iso
-if verb == '':
-stampit(progress)
-continue
 if verb == 'log':
 if smartlog(_line, obj, True):
 stampit(progress)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 0fbe9351d3aa7571cc1b01679e2dd3f86dee40ed
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Oct  9 23:36:28 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Oct  9 23:38:37 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=0fbe9351

grs/Interpret.py: clean up parsing a line.

 grs/Interpret.py | 29 +++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 43c0e48..7add215 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -159,10 +159,13 @@ class Interpret(Daemon):
 line_number = 0
 medium_type = None
 for _line in _file.readlines():
+# Increment the line number by one and create the name of the
+# file for the progress stamp.
 line_number += 1
+progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
 
-# Do nothing for lines with initial # or blank lines.
-# Create a progress stamp only if we are not doing an update 
run.
+# Do nothing for lines with initial # or blank lines.  Create
+# a progress stamp only if we are not doing an update run.
 if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
 if not self.update_run:
 stampit(progress)
@@ -173,7 +176,8 @@ class Interpret(Daemon):
 ignore_stamp = False
 _match = re.search(r'^(\+)(.*)$', _line)
 if _match:
-# There is a leading +, so remove it and skip if doing an 
update run
+# There is a leading +, so remove it and ignore any 
progress
+# stamp if its an update run.
 ignore_stamp = self.update_run
 _line = _match.group(2)
 else:
@@ -181,20 +185,17 @@ class Interpret(Daemon):
 if self.update_run:
 continue
 
-progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
+# Skip a line if the progres stamp exists, or ignore it
+# because its an update run.
 if os.path.exists(progress) and not ignore_stamp:
 continue
 
-# This is pretty simple interpretive logic, either its a
-# single 'verb', or a 'verb obj' pair.  While restrictive,
-# its good enough for now.
-try:
-_match = re.search(r'(\S+)\s+(\S+)', _line)
-verb = _match.group(1)
-obj = _match.group(2)
-except AttributeError:
-verb = _line.strip()
-obj = None
+# This is pretty simple syntax.  The first word on a line
+# is a verb.  The remaining words are objcts.
+sentence = _line.split()
+verb = sentence[0]
+objs = sentence[1:]
+obj = objs[0]
 
 # This long concatenated if is where the semantics of the
 # build script are implemented.  Note: 'hashit' can only come



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 685abf8bc45f4ad28fc7668c5464f114c0d9740d
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:40:35 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:40:35 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=685abf8b

grs/Interpret.py: clean up white space padding on _line.

 grs/Interpret.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index d326d9c..4f184a0 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -166,6 +166,9 @@ class Interpret(Daemon):
 line_number = 0
 medium_type = None
 for _line in _file.readlines():
+# Get rid of whitespace padding immediately
+_line = _line.strip()
+
 # Increment the line number by one and create the name of the
 # file for the progress stamp.
 line_number += 1
@@ -173,7 +176,7 @@ class Interpret(Daemon):
 
 # Do nothing for lines with initial # or blank lines.  Create
 # a progress stamp only if we are not doing an update run.
-if re.search(r'^(#).*$', _line) or _line.strip() == '' or 
_line.strip() == '+':
+if re.search(r'^(#).*$', _line) or _line == '' or _line == '+':
 if not self.update_run:
 stampit(progress)
 continue



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: dfbc38ca93e107146c24121cade975789a7e984a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:24:17 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:31:50 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=dfbc38ca

grs/Interpret.py: skip blank lines with leading +

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 15b6cfa..d326d9c 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -173,7 +173,7 @@ class Interpret(Daemon):
 
 # Do nothing for lines with initial # or blank lines.  Create
 # a progress stamp only if we are not doing an update run.
-if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+if re.search(r'^(#).*$', _line) or _line.strip() == '' or 
_line.strip() == '+':
 if not self.update_run:
 stampit(progress)
 continue



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 12356f10563d378306b3eeafa7b708e5d4888477
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:46:35 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:52:10 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=12356f10

grs/Interpret.py and Execute.py: pid is out of scope.

 grs/Execute.py   |  4 ++--
 grs/Interpret.py | 10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 0690e8e..0e70221 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -74,14 +74,14 @@ class Execute():
 if _rc:
 _file.write('EXIT CODE: %d\n' % _rc)
 if not failok:
-_file.write('SENDING SIGTERM to pid = %d\n' % pid)
+_file.write('SENDING SIGTERM\n')
 _file.close()
 signalexit()
 
 if timed_out:
 _file.write('TIMEOUT ERROR: %s\n' % cmd)
 if not failok:
-_file.write('SENDING SIGTERM to pid = %d\n' % pid)
+_file.write('SENDING SIGTERM\n')
 _file.close()
 signalexit()
 

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 4f184a0..12271d6 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -86,19 +86,19 @@ class Interpret(Daemon):
 time.sleep(2.0)
 
 
-def semantic_action(_line, objs, n, execstr):
+def semantic_action(_line, objs, num_objs, execstr):
 """ Execute the directive """
 if self.mock_run:
 _lo.log(_line)
 return
 try:
-if len(objs) < n:
+if len(objs) < num_objs:
 raise Exception('Number of objs for verb incorrect.')
 exec(execstr)
-except Exception as e:
+except Exception as err:
 _lo.log('Bad command: %s' % _line)
-_lo.log('Exception throw: %s' % e)
-_lo.log('SENDING SIGTERM to pid = %d\n' % pid)
+_lo.log('Exception throw: %s' % err)
+_lo.log('SENDING SIGTERM\n')
 signalexit()
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: d6f40c5fbf0b53a069359a0d0ad6adefa509b8c2
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Oct  9 23:36:28 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Oct  9 23:36:28 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=d6f40c5f

grs/Interpret.py: clean up parsing a line.

 grs/Interpret.py | 29 +++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 43c0e48..7add215 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -159,10 +159,13 @@ class Interpret(Daemon):
 line_number = 0
 medium_type = None
 for _line in _file.readlines():
+# Increment the line number by one and create the name of the
+# file for the progress stamp.
 line_number += 1
+progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
 
-# Do nothing for lines with initial # or blank lines.
-# Create a progress stamp only if we are not doing an update 
run.
+# Do nothing for lines with initial # or blank lines.  Create
+# a progress stamp only if we are not doing an update run.
 if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
 if not self.update_run:
 stampit(progress)
@@ -173,7 +176,8 @@ class Interpret(Daemon):
 ignore_stamp = False
 _match = re.search(r'^(\+)(.*)$', _line)
 if _match:
-# There is a leading +, so remove it and skip if doing an 
update run
+# There is a leading +, so remove it and ignore any 
progress
+# stamp if its an update run.
 ignore_stamp = self.update_run
 _line = _match.group(2)
 else:
@@ -181,20 +185,17 @@ class Interpret(Daemon):
 if self.update_run:
 continue
 
-progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
+# Skip a line if the progres stamp exists, or ignore it
+# because its an update run.
 if os.path.exists(progress) and not ignore_stamp:
 continue
 
-# This is pretty simple interpretive logic, either its a
-# single 'verb', or a 'verb obj' pair.  While restrictive,
-# its good enough for now.
-try:
-_match = re.search(r'(\S+)\s+(\S+)', _line)
-verb = _match.group(1)
-obj = _match.group(2)
-except AttributeError:
-verb = _line.strip()
-obj = None
+# This is pretty simple syntax.  The first word on a line
+# is a verb.  The remaining words are objcts.
+sentence = _line.split()
+verb = sentence[0]
+objs = sentence[1:]
+obj = objs[0]
 
 # This long concatenated if is where the semantics of the
 # build script are implemented.  Note: 'hashit' can only come



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 438583d1e40fd764d491974d1b0ebd75cacf2148
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 00:35:08 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 00:35:15 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=438583d1

grs/Interpret.py: restructure semantic actions.

 grs/Interpret.py | 106 ++-
 1 file changed, 42 insertions(+), 64 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 7add215..15b6cfa 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -79,20 +79,27 @@ class Interpret(Daemon):
 sys.exit(signum + 128)
 
 
-def smartlog(_log, obj, has_obj):
-""" This logs whether or not we have a grammatically incorrect
-directive, or we are doing a mock run, and returns whether
-or not we should execute the directive:
-True  = skip this directive
-False = don't skip it
-"""
-if (has_obj and not obj) or (not has_obj and obj):
-_lo.log('Bad command: %s' % _log)
-return True
+def signalexit():
+pid = os.getpid()
+while True:
+os.kill(pid, signal.SIGTERM)
+time.sleep(2.0)
+
+
+def semantic_action(_line, objs, n, execstr):
+""" Execute the directive """
 if self.mock_run:
-_lo.log(_log)
-return True
-return False
+_lo.log(_line)
+return
+try:
+if len(objs) < n:
+raise Exception('Number of objs for verb incorrect.')
+exec(execstr)
+except Exception as e:
+_lo.log('Bad command: %s' % _line)
+_lo.log('Exception throw: %s' % e)
+_lo.log('SENDING SIGTERM to pid = %d\n' % pid)
+signalexit()
 
 
 def stampit(progress):
@@ -195,82 +202,53 @@ class Interpret(Daemon):
 sentence = _line.split()
 verb = sentence[0]
 objs = sentence[1:]
-obj = objs[0]
 
 # This long concatenated if is where the semantics of the
 # build script are implemented.  Note: 'hashit' can only come
 # after 'tarit' or 'isoit' so that it knows the medium_name
 # to hash, ie whether its a .tar.xz or a .iso
 if verb == 'log':
-if smartlog(_line, obj, True):
-stampit(progress)
-continue
-if obj == 'stamp':
-_lo.log('='*80)
-else:
-_lo.log(obj)
+if objs[0] == 'stamp':
+objs[0] = '='*80
+semantic_action(_line, objs, 1, '_lo.log(\' 
\'.join(objs))')
 elif verb == 'mount':
-if smartlog(_line, obj, False):
-stampit(progress)
-continue
-_md.mount_all()
+semantic_action(_line, objs, 0, '_md.mount_all()')
 elif verb == 'unmount':
-if smartlog(_line, obj, False):
-stampit(progress)
-continue
-_md.umount_all()
+semantic_action(_line, objs, 0, '_md.umount_all()')
 elif verb == 'populate':
-if smartlog(_line, obj, True):
-stampit(progress)
-continue
-_po.populate(cycle=int(obj))
+semantic_action(_line, objs, 1, 
'_po.populate(cycle=int(objs[0]))')
 elif verb == 'runscript':
-if smartlog(_line, obj, True):
-stampit(progress)
-continue
-_ru.runscript(obj)
+semantic_action(_line, objs, 1, '_ru.runscript(objs[0])')
 elif verb == 'pivot':
-if smartlog(_line, obj, True):
-stampit(progress)
-continue
-_pc.pivot(obj, _md)
+semantic_action(_line, objs, 1, '_pc.pivot(objs[0], _md)')
 elif verb == 'kernel':
-if smartlog(_line, obj, False):
-stampit(progress)
-continue
-_ke.kernel()
+semantic_action(_line, objs, 0, '_ke.kernel()')
 elif verb == 'tarit':
-# 'tarit' can either be just a verb,
-# or a 'verb obj' pair.
-if obj:
-smartlog(_line, obj, True)
- 

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: fb73cabb4a601a8172d6de653851c4a348b6abc1
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 00:39:49 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 00:39:49 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=fb73cabb

grs/Execute.py: refactor signalexit().

 grs/Execute.py | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 3afbecc..0690e8e 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -44,17 +44,9 @@ class Execute():
 """
 def signalexit():
 pid = os.getpid()
-_file.write('SENDING SIGTERM to pid = %d\n' % pid)
-_file.close()
-try:
-for i in range(10):
-os.kill(pid, signal.SIGTERM)
-time.sleep(0.2)
-while True:
-os.kill(pid, signal.SIGKILL)
-time.sleep(0.2)
-except ProcessLookupError:
-pass
+while True:
+os.kill(pid, signal.SIGTERM)
+time.sleep(2.0)
 
 if shell:
 args = cmd
@@ -82,11 +74,15 @@ class Execute():
 if _rc:
 _file.write('EXIT CODE: %d\n' % _rc)
 if not failok:
+_file.write('SENDING SIGTERM to pid = %d\n' % pid)
+_file.close()
 signalexit()
 
 if timed_out:
 _file.write('TIMEOUT ERROR: %s\n' % cmd)
 if not failok:
+_file.write('SENDING SIGTERM to pid = %d\n' % pid)
+_file.close()
 signalexit()
 
 # Only close a logfile, don't close sys.stderr!



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 94db11827e4de100f00b168da884b7e18d7d9b0c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:24:17 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:24:17 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=94db1182

grs/Interpret.py: skip blank lines with leading +

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 15b6cfa..f678050 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -173,7 +173,7 @@ class Interpret(Daemon):
 
 # Do nothing for lines with initial # or blank lines.  Create
 # a progress stamp only if we are not doing an update run.
-if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+if re.search(r'^(#).*$', _line) of _line.strip == '' or 
_line.strip() == '+':
 if not self.update_run:
 stampit(progress)
 continue



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 752975a56d7af79197aa26154d6977401561d51b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:24:17 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:29:24 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=752975a5

grs/Interpret.py: skip blank lines with leading +

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 15b6cfa..799d794 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -173,7 +173,7 @@ class Interpret(Daemon):
 
 # Do nothing for lines with initial # or blank lines.  Create
 # a progress stamp only if we are not doing an update run.
-if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+if re.search(r'^(#).*$', _line) or _line.strip == '' or 
_line.strip() == '+':
 if not self.update_run:
 stampit(progress)
 continue



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: 6a6e851240ee9198398182dfa6598ee19a3fa33f
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Oct 10 01:46:35 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Oct 10 01:46:35 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=6a6e8512

grs/Interpret.py and Execute.py: pid is out of scope.

 grs/Interpret.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 4f184a0..d042da3 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -78,7 +78,7 @@ class Interpret(Daemon):
 pass
 sys.exit(signum + 128)
 
-
+)
 def signalexit():
 pid = os.getpid()
 while True:
@@ -98,7 +98,7 @@ class Interpret(Daemon):
 except Exception as e:
 _lo.log('Bad command: %s' % _line)
 _lo.log('Exception throw: %s' % e)
-_lo.log('SENDING SIGTERM to pid = %d\n' % pid)
+_lo.log('SENDING SIGTERM\n')
 signalexit()
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: b9a608b54d31deae83cac1d7143c245472211861
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Oct  9 23:12:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Oct  9 23:16:50 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=b9a608b5

grs/Interpret.py: skip non-functional build lines

 grs/Interpret.py |  11 +-
 grs/zzz.lint | 363 +++
 2 files changed, 368 insertions(+), 6 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 072574e..43c0e48 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -161,9 +161,11 @@ class Interpret(Daemon):
 for _line in _file.readlines():
 line_number += 1
 
-# Skip lines with initial # as comments.
-_match = re.search(r'^(#).*$', _line)
-if _match:
+# Do nothing for lines with initial # or blank lines.
+# Create a progress stamp only if we are not doing an update 
run.
+if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+if not self.update_run:
+stampit(progress)
 continue
 
 # For a release run, execute every line of the build script.
@@ -198,9 +200,6 @@ class Interpret(Daemon):
 # build script are implemented.  Note: 'hashit' can only come
 # after 'tarit' or 'isoit' so that it knows the medium_name
 # to hash, ie whether its a .tar.xz or a .iso
-if verb == '':
-stampit(progress)
-continue
 if verb == 'log':
 if smartlog(_line, obj, True):
 stampit(progress)

diff --git a/grs/zzz.lint b/grs/zzz.lint
new file mode 100644
index 000..f2845ed
--- /dev/null
+++ b/grs/zzz.lint
@@ -0,0 +1,363 @@
+* Module grs
+C:  1, 0: Missing module docstring (missing-docstring)
+* Module grs.Daemon
+C:  1, 0: Missing module docstring (missing-docstring)
+C: 48, 4: Missing method docstring (missing-docstring)
+C: 89, 4: Missing method docstring (missing-docstring)
+C: 93, 4: Missing method docstring (missing-docstring)
+C: 97, 4: Missing method docstring (missing-docstring)
+* Module grs.Interpret
+C:  1, 0: Missing module docstring (missing-docstring)
+R: 42, 4: Too many local variables (34/15) (too-many-locals)
+E: 58,39: Instance of 'Interpret' has no 'subcgroupdir' member (no-member)
+W: 67,32: Unused variable 'i' (unused-variable)
+W: 50,28: Unused argument 'frame' (unused-argument)
+E: 92,15: Instance of 'Interpret' has no 'mock_run' member (no-member)
+E:110,35: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:111,37: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:112,27: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:113,31: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:114,33: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:115,31: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:116,33: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:117,33: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:118,39: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:119,55: Instance of 'Interpret' has no 'run_number' member (no-member)
+E:146,43: Instance of 'Interpret' has no 'update_run' member (no-member)
+E:152,48: Instance of 'Interpret' has no 'update_run' member (no-member)
+E:175,35: Instance of 'Interpret' has no 'update_run' member (no-member)
+E:179,23: Instance of 'Interpret' has no 'update_run' member (no-member)
+R: 42, 4: Too many branches (38/12) (too-many-branches)
+R: 42, 4: Too many statements (134/50) (too-many-statements)
+* Module grs.Synchronize
+C:  1, 0: Missing module docstring (missing-docstring)
+C: 32, 4: Missing method docstring (missing-docstring)
+* Module grs.RunScript
+C:  1, 0: Missing module docstring (missing-docstring)
+C: 35, 4: Missing method docstring (missing-docstring)
+R: 24, 0: Too few public methods (1/2) (too-few-public-methods)
+* Module grs.MountDirectories
+C:  1, 0: Missing module docstring (missing-docstring)
+R: 50, 4: Method could be a function (no-self-use)
+W: 86,22: Unused variable 'all_mounted' (unused-variable)
+* Module grs.Rotator
+C:  1, 0: Missing module docstring (missing-docstring)
+R: 27, 4: Method could be a function (no-self-use)
+* Module grs.PivotChroot
+C:  1, 0: Missing module docstring (missing-docstring)
+C: 38, 4: Missing method docstring (missing-docstring)
+* Module grs.HashIt
+C:  1, 0: Missing module docstring (missing-docstring)
+E: 36,30: Instance of 'HashIt' has no 'portage_configroot' member (no-member)
+E: 40,29: Instance of 'HashIt' has no 

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-09 Thread Anthony G. Basile
commit: b0f3ea3a17df523436e82fb0629eeb458dcd0025
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Fri Oct  9 23:12:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Fri Oct  9 23:12:06 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=b0f3ea3a

grs/Interpret.py: skip non-functional build lines

 grs/Interpret.py | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 072574e..744c3cc 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -161,9 +161,9 @@ class Interpret(Daemon):
 for _line in _file.readlines():
 line_number += 1
 
-# Skip lines with initial # as comments.
-_match = re.search(r'^(#).*$', _line)
-if _match:
+# Skip lines with initial # or blank lines.
+if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
+stampit(progress)
 continue
 
 # For a release run, execute every line of the build script.
@@ -198,9 +198,6 @@ class Interpret(Daemon):
 # build script are implemented.  Note: 'hashit' can only come
 # after 'tarit' or 'isoit' so that it knows the medium_name
 # to hash, ie whether its a .tar.xz or a .iso
-if verb == '':
-stampit(progress)
-continue
 if verb == 'log':
 if smartlog(_line, obj, True):
 stampit(progress)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-08 Thread Anthony G. Basile
commit: 2b87ad4ab4658b834f9cb0683ea3f7fb75781719
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Oct  8 18:08:39 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Oct  8 18:08:39 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=2b87ad4a

grs/Interpret.py: prepare for refactoring large if clause.

 grs/Interpret.py | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 4e411fd..072574e 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -79,7 +79,7 @@ class Interpret(Daemon):
 sys.exit(signum + 128)
 
 
-def smartlog(_log, obj, has_obj=True):
+def smartlog(_log, obj, has_obj):
 """ This logs whether or not we have a grammatically incorrect
 directive, or we are doing a mock run, and returns whether
 or not we should execute the directive:
@@ -202,7 +202,7 @@ class Interpret(Daemon):
 stampit(progress)
 continue
 if verb == 'log':
-if smartlog(_line, obj):
+if smartlog(_line, obj, True):
 stampit(progress)
 continue
 if obj == 'stamp':
@@ -220,17 +220,17 @@ class Interpret(Daemon):
 continue
 _md.umount_all()
 elif verb == 'populate':
-if smartlog(_line, obj):
+if smartlog(_line, obj, True):
 stampit(progress)
 continue
 _po.populate(cycle=int(obj))
 elif verb == 'runscript':
-if smartlog(_line, obj):
+if smartlog(_line, obj, True):
 stampit(progress)
 continue
 _ru.runscript(obj)
 elif verb == 'pivot':
-if smartlog(_line, obj):
+if smartlog(_line, obj, True):
 stampit(progress)
 continue
 _pc.pivot(obj, _md)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-08 Thread Anthony G. Basile
commit: ddfe7d46bafa8875b43f86c8310e22bf7243e7a1
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Oct  8 17:26:01 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Oct  8 17:26:01 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=ddfe7d46

lint: rename internal variables.

 grs/Daemon.py  |  18 
 grs/Execute.py |  22 +-
 grs/ISOIt.py   |   6 +--
 grs/Interpret.py   | 122 ++---
 grs/Kernel.py  |  22 +-
 grs/Log.py |   4 +-
 grs/PivotChroot.py |   8 ++--
 grs/Populate.py|  22 +-
 grs/Rotator.py |  16 +++
 grs/Seed.py|   4 +-
 grs/WorldConf.py   |  40 +-
 11 files changed, 142 insertions(+), 142 deletions(-)

diff --git a/grs/Daemon.py b/grs/Daemon.py
index 0cefaef..b97f4e0 100644
--- a/grs/Daemon.py
+++ b/grs/Daemon.py
@@ -67,23 +67,23 @@ class Daemon:
 sys.exit(1)
 
 # Dup stdin to /dev/null, and stdout and stderr to grs-daemon-.err
-si = open(os.devnull, 'r')
-os.dup2(si.fileno(), sys.stdin.fileno())
+_si = open(os.devnull, 'r')
+os.dup2(_si.fileno(), sys.stdin.fileno())
 
 os.makedirs('/var/log/grs', mode=0o755, exist_ok=True)
-se = open('/var/log/grs/grs-daemon-%d.err' % os.getpid(), 'a+')
+_se = open('/var/log/grs/grs-daemon-%d.err' % os.getpid(), 'a+')
 
 sys.stdout.flush()
-os.dup2(se.fileno(), sys.stdout.fileno())
+os.dup2(_se.fileno(), sys.stdout.fileno())
 sys.stderr.flush()
-os.dup2(se.fileno(), sys.stderr.fileno())
+os.dup2(_se.fileno(), sys.stderr.fileno())
 
 # Use atexit to remove the pidfile when we shutdown.
 # No matter where the exit is initiated, eg from Execute.py
 # we are sure that atexit() will run and delete the pidfile.
 atexit.register(self.delpid)
-with open(self.pidfile, 'w') as pf:
-pf.write('%d\n' % os.getpid())
+with open(self.pidfile, 'w') as _pf:
+_pf.write('%d\n' % os.getpid())
 
 
 def delpid(self):
@@ -99,8 +99,8 @@ class Daemon:
 # 1) If the pidfile is stale, remove it and startup as usual.
 # 2) If we're already running, then don't start a second instance.
 try:
-with open(self.pidfile, 'r') as pf:
-pid = int(pf.read().strip())
+with open(self.pidfile, 'r') as _pf:
+pid = int(_pf.read().strip())
 except IOError:
 pid = None
 

diff --git a/grs/Execute.py b/grs/Execute.py
index c42cab2..3afbecc 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -44,8 +44,8 @@ class Execute():
 """
 def signalexit():
 pid = os.getpid()
-f.write('SENDING SIGTERM to pid = %d\n' % pid)
-f.close()
+_file.write('SENDING SIGTERM to pid = %d\n' % pid)
+_file.close()
 try:
 for i in range(10):
 os.kill(pid, signal.SIGTERM)
@@ -63,10 +63,10 @@ class Execute():
 extra_env = dict(os.environ, **extra_env)
 
 if logfile:
-f = open(logfile, 'a')
-proc = subprocess.Popen(args, stdout=f, stderr=f, env=extra_env, 
shell=shell)
+_file = open(logfile, 'a')
+proc = subprocess.Popen(args, stdout=_file, stderr=_file, 
env=extra_env, shell=shell)
 else:
-f = sys.stderr
+_file = sys.stderr
 proc = subprocess.Popen(args, env=extra_env, shell=shell)
 
 try:
@@ -77,18 +77,18 @@ class Execute():
 timed_out = True
 
 if not timed_out:
-# rc = None if we had a timeout
-rc = proc.returncode
-if rc:
-f.write('EXIT CODE: %d\n' % rc)
+# _rc = None if we had a timeout
+_rc = proc.returncode
+if _rc:
+_file.write('EXIT CODE: %d\n' % _rc)
 if not failok:
 signalexit()
 
 if timed_out:
-f.write('TIMEOUT ERROR: %s\n' % cmd)
+_file.write('TIMEOUT ERROR: %s\n' % cmd)
 if not failok:
 signalexit()
 
 # Only close a logfile, don't close sys.stderr!
 if logfile:
-f.close()
+_file.close()

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index ae6b217..d24a542 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -76,9 +76,9 @@ class ISOIt(HashIt):
 'bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 'mnt/tmpfs', 
'proc', 'sbin', 'sys',
 'tmp', 'usr/bin', 'usr/sbin', 'var', 'var/run'
 ]
-for p in root_paths:
-d = os.path.join(initramfs_root, p)
-os.makedirs(d, mode=0o755, exist_ok=True)
+for _path in root_paths:
+_dir = os.path.join(initramfs_root, _path)
+

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-08 Thread Anthony G. Basile
commit: aad8f61094ca20dcad007e6ab97b94c9f8efcfc5
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Thu Oct  8 23:58:04 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Thu Oct  8 23:58:04 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=aad8f610

grs/WorldConf.py: fix renaming s -> _section.

 grs/WorldConf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index bad4f83..48b93af 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -53,7 +53,7 @@ class WorldConf():
 )
 config.read(CONST.WORLD_CONFIG)
 for _section in config.sections():
-for (directory, value) in config[s].items():
+for (directory, value) in config[_section].items():
 p_slot_atom = re.sub(r'[/:]', '_', _section)
 dpath = os.path.join(CONST.PORTAGE_CONFIGDIR, directory)
 fpath = os.path.join(dpath, p_slot_atom)



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 31e872a14e53e87a1788dd96cbae1e11683a6487
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 08:07:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 08:07:06 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=31e872a1

lint: remove unused imports.

 grs/Daemon.py  | 2 --
 grs/PivotChroot.py | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/grs/Daemon.py b/grs/Daemon.py
index 79aaa42..0cefaef 100644
--- a/grs/Daemon.py
+++ b/grs/Daemon.py
@@ -18,9 +18,7 @@
 
 import atexit
 import os
-import signal
 import sys
-import time
 
 class Daemon:
 """ Adopted from Sander Marechal's "A simple unix/linux daemon in Python"

diff --git a/grs/PivotChroot.py b/grs/PivotChroot.py
index 6324b6e..248bbac 100644
--- a/grs/PivotChroot.py
+++ b/grs/PivotChroot.py
@@ -16,13 +16,10 @@
 #You should have received a copy of the GNU General Public License
 #along with this program.  If not, see .
 
-import glob
-import re
 import os
 import shutil
 
 from grs.Constants import CONST
-from grs.MountDirectories import MountDirectories
 from grs.Rotator import Rotator
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 56bfb6c2fbb15dbc1b9bd2b618a47cc82d5f9a6c
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 08:37:09 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 08:37:09 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=56bfb6c2

lint: use raw strings with regexes.

 grs/Interpret.py | 6 +++---
 grs/Kernel.py| 6 +++---
 grs/Populate.py  | 2 +-
 grs/Rotator.py   | 4 ++--
 grs/WorldConf.py | 8 
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index fd36650..db5bdd4 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -162,14 +162,14 @@ class Interpret(Daemon):
 line_number += 1
 
 # Skip lines with initial # as comments.
-m = re.search('^(#).*$', l)
+m = re.search(r'^(#).*$', l)
 if m:
 continue
 
 # For a release run, execute every line of the build script.
 # For an update run, exexute only lines with a leading +.
 ignore_stamp = False
-m = re.search('^(\+)(.*)$', l)
+m = re.search(r'^(\+)(.*)$', l)
 if m:
 # There is a leading +, so remove it and skip if doing an 
update run
 ignore_stamp = self.update_run
@@ -187,7 +187,7 @@ class Interpret(Daemon):
 # single 'verb', or a 'verb obj' pair.  While restrictive,
 # its good enough for now.
 try:
-m = re.search('(\S+)\s+(\S+)', l)
+m = re.search(r'(\S+)\s+(\S+)', l)
 verb = m.group(1)
 obj = m.group(2)
 except AttributeError:

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 559aa57..a8205ba 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -47,18 +47,18 @@ class Kernel():
 # The version line looks like the following:
 # Linux/x86 4.0.6-hardened-r2 Kernel Configuration
 # The 2nd group contains the version.
-m = re.search('^#\s+(\S+)\s+(\S+).+$', version_line)
+m = re.search(r'^#\s+(\S+)\s+(\S+).+$', version_line)
 gentoo_version = m.group(2)
 try:
 # Either the verison is of the form '4.0.6-hardened-r2' with two 
-'s
-m = re.search('(\S+?)-(\S+?)-(\S+)', gentoo_version)
+m = re.search(r'(\S+?)-(\S+?)-(\S+)', gentoo_version)
 vanilla_version = m.group(1)
 flavor = m.group(2)
 revision = m.group(3)
 pkg_name = flavor + '-sources-' + vanilla_version + '-' + revision
 except AttributeError:
 # Or the verison is of the form '4.0.6-hardened' with one -
-m = re.search('(\S+?)-(\S+)', gentoo_version)
+m = re.search(r'(\S+?)-(\S+)', gentoo_version)
 vanilla_version = m.group(1)
 flavor = m.group(2)
 pkg_name = flavor + '-sources-' + vanilla_version

diff --git a/grs/Populate.py b/grs/Populate.py
index a1822ee..3271cb7 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -64,7 +64,7 @@ class Populate():
 cycled_files = {}
 for dirpath, dirnames, filenames in os.walk(self.workdir):
 for f in filenames:
-m = re.search('^(.+)\.CYCLE\.(\d+)', f)
+m = re.search(r'^(.+)\.CYCLE\.(\d+)', f)
 if m:
 filename = m.group(1)
 cycle_no = int(m.group(2))

diff --git a/grs/Rotator.py b/grs/Rotator.py
index a1282b2..9daf7d2 100644
--- a/grs/Rotator.py
+++ b/grs/Rotator.py
@@ -45,7 +45,7 @@ class Rotator():
 objs = glob.glob('%s.*' % obj)
 indexed_obj = {}
 for o in objs:
-m = re.search('^.+\.(\d+)$', o)
+m = re.search(r'^.+\.(\d+)$', o)
 indexed_obj[int(m.group(1))] = o
 count = list(indexed_obj.keys())
 count.sort()
@@ -58,7 +58,7 @@ class Rotator():
 except NotADirectoryError:
 os.unlink(current_obj)
 continue
-m = re.search('^(.+)\.\d+$', current_obj)
+m = re.search(r'^(.+)\.\d+$', current_obj)
 next_obj = '%s.%d' % (m.group(1), c+1)
 shutil.move(current_obj, next_obj)
 

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index c5882bf..b55110f 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -53,7 +53,7 @@ class WorldConf():
 config.read(CONST.WORLD_CONFIG)
 for s in config.sections():
 for (directory, value) in config[s].items():
-p_slot_atom = re.sub('[/:]', '_', s)
+p_slot_atom = re.sub(r'[/:]', '_', s)
 dpath = os.path.join(CONST.PORTAGE_CONFIGDIR, directory)
 fpath = os.path.join(dpath, p_slot_atom)
 os.makedirs(dpath, mode=0o755, exist_ok=True)
@@ 

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 10b901b228bbb3667719e0b430cf3bf9d98197b2
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 11:12:46 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 11:12:46 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=10b901b2

lint: more unused imports.

 grs/Log.py   | 3 ---
 grs/WorldConf.py | 1 -
 2 files changed, 4 deletions(-)

diff --git a/grs/Log.py b/grs/Log.py
index aa49b12..a7ac1a3 100644
--- a/grs/Log.py
+++ b/grs/Log.py
@@ -1,10 +1,7 @@
 #!/usr/bin/env python
 
 import datetime
-import glob
 import os
-import re
-import shutil
 
 from grs.Constants import CONST
 from grs.Rotator import Rotator

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index e196338..d28f300 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -17,7 +17,6 @@
 #along with this program.  If not, see .
 
 import configparser
-import copy
 import os
 import portage
 import re



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 5261e5a0b373c0484fb0ec0fcde2a5f91ffbd5c0
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 11:03:02 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 11:03:02 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=5261e5a0

lint: fix line length.

 grs/Execute.py |  4 +++-
 grs/ISOIt.py   | 20 
 grs/Kernel.py  |  5 -
 grs/PivotChroot.py |  5 -
 grs/Populate.py|  5 -
 grs/RunScript.py   |  5 -
 grs/Seed.py|  5 -
 grs/WorldConf.py   |  8 ++--
 8 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 1220a53..c42cab2 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -27,7 +27,9 @@ from grs.Constants import CONST
 class Execute():
 """ Execute a shell command """
 
-def __init__(self, cmd, timeout=1, extra_env={}, failok=False, 
shell=False, logfile=CONST.LOGFILE):
+def __init__(
+self, cmd, timeout=1, extra_env={}, failok=False, shell=False, 
logfile=CONST.LOGFILE
+):
 """ Execute a shell command.
 
 cmd - Simple string of the command to be execute as a

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index d5a410c..e64e9d3 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -26,7 +26,10 @@ from grs.HashIt import HashIt
 class ISOIt(HashIt):
 """ Create a bootable ISO of the system. """
 
-def __init__(self, name, libdir=CONST.LIBDIR, tmpdir=CONST.TMPDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT, logfile=CONST.LOGFILE):
+def __init__(
+self, name, libdir=CONST.LIBDIR, tmpdir=CONST.TMPDIR,
+portage_configroot=CONST.PORTAGE_CONFIGROOT, logfile=CONST.LOGFILE
+):
 self.libdir = libdir
 self.tmpdir = tmpdir
 self.portage_configroot = portage_configroot
@@ -55,15 +58,24 @@ class ISOIt(HashIt):
 shutil.copy(busybox_config, savedconfig_path)
 
 # Emerge busybox.
-os.symlink('/usr/portage/profiles/hardened/linux/amd64', 
makeprofile_path)
+os.symlink(
+'/usr/portage/profiles/hardened/linux/amd64',
+makeprofile_path
+)
 cmd = 'emerge --nodeps -1q busybox'
-emerge_env = {'USE' : '-* savedconfig', 'ROOT' : busybox_root, 
'PORTAGE_CONFIGROOT' : busybox_root}
+emerge_env = {
+'USE' : '-* savedconfig', 'ROOT' : busybox_root,
+'PORTAGE_CONFIGROOT' : busybox_root
+}
 Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
 
 # Remove any old initramfs root and prepare a new one.
 initramfs_root = os.path.join(self.tmpdir, 'initramfs')
 shutil.rmtree(initramfs_root, ignore_errors=True)
-root_paths = ['bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 
'mnt/tmpfs', 'proc', 'sbin', 'sys', 'tmp', 'usr/bin', 'usr/sbin', 'var', 
'var/run']
+root_paths = [
+'bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 'mnt/tmpfs', 
'proc', 'sbin',
+'sys', 'tmp', 'usr/bin', 'usr/sbin', 'var', 'var/run'
+]
 for p in root_paths:
 d = os.path.join(initramfs_root, p)
 os.makedirs(d, mode=0o755, exist_ok=True)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index a8205ba..326b56c 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -27,7 +27,10 @@ from grs.Execute import Execute
 class Kernel():
 """ Build a linux-image pkg and install when building a system. """
 
-def __init__(self, libdir=CONST.LIBDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT, kernelroot=CONST.KERNELROOT, 
package=CONST.PACKAGE, logfile=CONST.LOGFILE):
+def __init__(
+self, libdir=CONST.LIBDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
+kernelroot=CONST.KERNELROOT, package=CONST.PACKAGE, 
logfile=CONST.LOGFILE
+):
 self.libdir = libdir
 self.portage_configroot = portage_configroot
 self.kernelroot = kernelroot

diff --git a/grs/PivotChroot.py b/grs/PivotChroot.py
index 248bbac..ce9a35c 100644
--- a/grs/PivotChroot.py
+++ b/grs/PivotChroot.py
@@ -26,7 +26,10 @@ from grs.Rotator import Rotator
 class PivotChroot(Rotator):
 """ Move an inner chroot out to the new system portage configroot.  """
 
-def __init__(self, tmpdir=CONST.TMPDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT, logfile=CONST.LOGFILE):
+def __init__(
+self, tmpdir=CONST.TMPDIR, 
portage_configroot=CONST.PORTAGE_CONFIGROOT,
+logfile=CONST.LOGFILE
+):
 self.tmpdir = tmpdir
 self.portage_configroot = portage_configroot
 self.logfile = logfile

diff --git a/grs/Populate.py b/grs/Populate.py
index 3271cb7..1c3f08e 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -27,7 +27,10 @@ class Populate():
 for a particular cycle number.
 """
 
-def __init__(self, libdir=CONST.LIBDIR, workdir=CONST.WORKDIR, 

[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 665fc43168025d76c7c474df1835beaa5088589f
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 11:34:01 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 11:34:01 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=665fc431

grs/Populate.py: use isinstance() instead of type().

 grs/Populate.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/grs/Populate.py b/grs/Populate.py
index db35ee2..c6dce8d 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -46,7 +46,8 @@ class Populate():
 Execute(cmd, timeout=60, logfile=self.logfile)
 
 # Select the cycle
-if cycle: self.select_cycle(cycle)
+if cycle:
+self.select_cycle(cycle)
 
 # Copy from the workdir to the system's portage configroot.
 cmd = 'rsync -av %s/ %s' % (self.workdir, self.portage_configroot)
@@ -73,7 +74,7 @@ class Populate():
 cycled_files.setdefault(cycle_no, [])
 cycled_files[cycle_no].append([dirpath, filename])
 # If cycle is just a boolean, then default to the maximum cycle number.
-if type(cycle) is bool:
+if isinstance(cycle, bool):
 cycle_no = max(cycled_files)
 else:
 cycle_no = cycle



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: 2e2d3ef3dc540b756bcbddd3d2f871367b297c59
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 11:09:09 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 11:09:09 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=2e2d3ef3

lint: fix indentations.

 grs/ISOIt.py | 12 ++--
 grs/WorldConf.py |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index e64e9d3..ae6b217 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -59,13 +59,13 @@ class ISOIt(HashIt):
 
 # Emerge busybox.
 os.symlink(
-'/usr/portage/profiles/hardened/linux/amd64',
-makeprofile_path
+'/usr/portage/profiles/hardened/linux/amd64',
+makeprofile_path
 )
 cmd = 'emerge --nodeps -1q busybox'
 emerge_env = {
-'USE' : '-* savedconfig', 'ROOT' : busybox_root,
-'PORTAGE_CONFIGROOT' : busybox_root
+'USE' : '-* savedconfig', 'ROOT' : busybox_root,
+'PORTAGE_CONFIGROOT' : busybox_root
 }
 Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
 
@@ -73,8 +73,8 @@ class ISOIt(HashIt):
 initramfs_root = os.path.join(self.tmpdir, 'initramfs')
 shutil.rmtree(initramfs_root, ignore_errors=True)
 root_paths = [
-'bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 'mnt/tmpfs', 
'proc', 'sbin',
-'sys', 'tmp', 'usr/bin', 'usr/sbin', 'var', 'var/run'
+'bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 'mnt/tmpfs', 
'proc', 'sbin', 'sys',
+'tmp', 'usr/bin', 'usr/sbin', 'var', 'var/run'
 ]
 for p in root_paths:
 d = os.path.join(initramfs_root, p)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index 5cc7672..e196338 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -50,7 +50,7 @@ class WorldConf():
 
 # Now we can read world.conf and populate an empty /etc/portage.
 config = configparser.RawConfigParser(
-delimiters=':', allow_no_value=True, comment_prefixes=None
+delimiters=':', allow_no_value=True, comment_prefixes=None
 )
 config.read(CONST.WORLD_CONFIG)
 for s in config.sections():
@@ -94,7 +94,7 @@ class WorldConf():
 
 # Also let's get a list of all the possible canonical file names
 config = configparser.RawConfigParser(
-delimiters=':', allow_no_value=True, comment_prefixes=None
+delimiters=':', allow_no_value=True, comment_prefixes=None
 )
 config.read(CONST.WORLD_CONFIG)
 canon = []



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-07 Thread Anthony G. Basile
commit: c4b3254ab91a2079a9fdc657462489215f7b4e0b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Oct  7 11:12:46 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Oct  7 11:20:40 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=c4b3254a

lint: more unused imports.

 grs/Constants.py | 1 -
 grs/Log.py   | 3 ---
 grs/Populate.py  | 1 -
 grs/Seed.py  | 2 --
 grs/WorldConf.py | 1 -
 5 files changed, 8 deletions(-)

diff --git a/grs/Constants.py b/grs/Constants.py
index 669f086..ecbac40 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -17,7 +17,6 @@
 #along with this program.  If not, see .
 
 import os
-import sys
 import configparser
 from copy import deepcopy
 

diff --git a/grs/Log.py b/grs/Log.py
index aa49b12..a7ac1a3 100644
--- a/grs/Log.py
+++ b/grs/Log.py
@@ -1,10 +1,7 @@
 #!/usr/bin/env python
 
 import datetime
-import glob
 import os
-import re
-import shutil
 
 from grs.Constants import CONST
 from grs.Rotator import Rotator

diff --git a/grs/Populate.py b/grs/Populate.py
index 1c3f08e..db35ee2 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -18,7 +18,6 @@
 
 import os
 import re
-import shutil
 from grs.Constants import CONST
 from grs.Execute import Execute
 

diff --git a/grs/Seed.py b/grs/Seed.py
index e2c65c8..2bc429f 100644
--- a/grs/Seed.py
+++ b/grs/Seed.py
@@ -16,9 +16,7 @@
 #You should have received a copy of the GNU General Public License
 #along with this program.  If not, see .
 
-import glob
 import os
-import re
 import shutil
 import urllib.request
 

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index e196338..d28f300 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -17,7 +17,6 @@
 #along with this program.  If not, see .
 
 import configparser
-import copy
 import os
 import portage
 import re



[gentoo-commits] proj/grss:master commit in: grs/

2015-10-06 Thread Anthony G. Basile
commit: b14969c273f930374d8c5f6211619c0190752377
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Tue Oct  6 10:13:21 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Tue Oct  6 10:13:21 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=b14969c2

lint: fix white spaces

 grs/Constants.py| 44 ++--
 grs/Daemon.py   |  2 +-
 grs/Execute.py  |  3 +--
 grs/ISOIt.py| 31 ++-
 grs/Interpret.py| 25 -
 grs/Kernel.py   | 13 ++---
 grs/Log.py  |  6 +++---
 grs/MountDirectories.py |  8 
 grs/PivotChroot.py  |  3 +--
 grs/Populate.py |  9 -
 grs/Rotator.py  |  6 +++---
 grs/RunScript.py|  3 +--
 grs/Seed.py |  3 +--
 grs/Synchronize.py  |  2 +-
 grs/TarIt.py|  4 ++--
 grs/WorldConf.py|  2 +-
 16 files changed, 77 insertions(+), 87 deletions(-)

diff --git a/grs/Constants.py b/grs/Constants.py
index 0025eb4..669f086 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -57,21 +57,21 @@ class Constants():
 a GRS namespace.
 """
 
-def __init__(self, configfile = '/etc/grs/systems.conf'):
+def __init__(self, configfile='/etc/grs/systems.conf'):
 # If there's no config file, we're dead in the water.
 if not os.path.isfile(configfile):
 raise Exception('Configuration file %s not found\n' % configfile)
 
-self.config = configparser.ConfigParser(delimiters = ':', 
comment_prefixes = '#')
+self.config = configparser.ConfigParser(delimiters=':', 
comment_prefixes='#')
 self.config.read(configfile)
 
 # These values will probably fail in the future, but that's okay
 # because they really should never be used.  They live outside of
 # any GRS namespace and are just 'defaults'.
-server= 'http://distfiles.gentoo.org/'
-stagedir  = 
'releases/amd64/autobuilds/current-stage3-amd64-uclibc-hardened/'
+server = 'http://distfiles.gentoo.org/'
+stagedir = 
'releases/amd64/autobuilds/current-stage3-amd64-uclibc-hardened/'
 stagefile = 'stage3-amd64-uclibc-hardened-20150510.tar.bz2'
-default_stage_uri =  server + stagedir + stagefile
+default_stage_uri = server + stagedir + stagefile
 
 # This is the space of all possible constants for any given GRS 
namespace
 space = {
@@ -129,7 +129,7 @@ class Constants():
 
 # Don't retrieve the original else you can overwrite it,
 # rather deep copy it.
-def __getattr__(self, key, value = None):
+def __getattr__(self, key, value=None):
 if key in self.__dict__:
 return deepcopy(self.__dict__[key])
 
@@ -143,26 +143,26 @@ class Constants():
 CONST = Constants()
 
 # Constants outside any GRS namespace.
-CONST.PACKAGE_NAME= "Gentoo Reference System"
-CONST.PACKAGE_VERSION = 0.0
+CONST.PACKAGE_NAME = "Gentoo Reference System"
+CONST.PACKAGE_VERSION = 0.0
 CONST.PACKAGE_DESCRIPTION = "Update a GRS by cloning a predefined system."
-CONST.BUG_REPORTS = 'http://bugs.gentoo.org'
+CONST.BUG_REPORTS = 'http://bugs.gentoo.org'
 
 # The are defaults in case objects of other classes which depend on values
 # of libdir, logfile, etc. are instantiated outside of any namespaces.
 # They should not be needed under normal working condidtions.
-CONST.LIBDIR  = '/var/lib/grs'
-CONST.LOGFILE = '/var/log/grs.log'
-CONST.TMPDIR  = '/var/tmp/grs'
-CONST.WORKDIR = '/var/tmp/grs/work'
-CONST.PACKAGE = '/var/tmp/grs/package'
-CONST.KERNELROOT  = '/var/tmp/grs/kernel'
-CONST.PORTAGE_CONFIGROOT  = '/var/tmp/grs/system'
-CONST.PIDFILE = '/run/grs.pid'
+CONST.LIBDIR = '/var/lib/grs'
+CONST.LOGFILE = '/var/log/grs.log'
+CONST.TMPDIR = '/var/tmp/grs'
+CONST.WORKDIR = '/var/tmp/grs/work'
+CONST.PACKAGE = '/var/tmp/grs/package'
+CONST.KERNELROOT = '/var/tmp/grs/kernel'
+CONST.PORTAGE_CONFIGROOT = '/var/tmp/grs/system'
+CONST.PIDFILE = '/run/grs.pid'
 
 # These are used by grsup and are hard coded values.
-CONST.PORTAGE_CONFIGDIR   = '/etc/portage'
-CONST.PORTAGE_DIRTYFILE   = '/etc/portage/.grs_dirty'
-CONST.WORLD_CONFIG= '/etc/grs/world.conf'
-CONST.GRS_CGROUP  = 'grs'
-CONST.GRS_CGROUPDIR   = '/sys/fs/cgroup/grs'
+CONST.PORTAGE_CONFIGDIR = '/etc/portage'
+CONST.PORTAGE_DIRTYFILE = '/etc/portage/.grs_dirty'
+CONST.WORLD_CONFIG = '/etc/grs/world.conf'
+CONST.GRS_CGROUP = 'grs'
+CONST.GRS_CGROUPDIR = '/sys/fs/cgroup/grs'

diff --git a/grs/Daemon.py b/grs/Daemon.py
index 58927f8..79aaa42 100644
--- a/grs/Daemon.py
+++ b/grs/Daemon.py
@@ -84,7 +84,7 @@ class Daemon:
 # No matter where the exit is initiated, eg from Execute.py
 # we are sure that atexit() will run and delete the pidfile.
 

[gentoo-commits] proj/grss:master commit in: grs/

2015-09-16 Thread Anthony G. Basile
commit: f496edb2c69a19f25f5398c144ef84608b9dce1a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Sep 16 22:13:06 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Sep 16 22:13:06 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=f496edb2

grs/ISOIt.py: mksquashfs and mkisofs can take a long time.

 grs/ISOIt.py | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index 49b97bf..a8973c6 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -120,10 +120,11 @@ class ISOIt(HashIt):
 # If this fails, we'll have to rebuild the kernel!
 #shutil.rmtree(kernelimage_dir, ignore_errors=True)
 
-# 3. make the squashfs image and copy it into the iso/boot
+# 3. Make the squashfs image and copy it into the iso/boot.
+# This can take a long time.
 squashfs_path = os.path.join(iso_dir, 'rootfs')
 cmd = 'mksquashfs %s %s -xattrs -comp xz' % (self.portage_configroot, 
squashfs_path)
-Execute(cmd, timeout=600, logfile=self.logfile)
+Execute(cmd, timeout=None, logfile=self.logfile)
 
 # 4. Emerge grub:0 to grab stage2_eltorito
 grub_root = os.path.join(self.tmpdir, 'grub')
@@ -135,7 +136,7 @@ class ISOIt(HashIt):
 shutil.copy(eltorito_path, isogrub_dir)
 shutil.copy(menulst_path, isogrub_dir)
 
-# 5. create the iso image
+# 5. Create the iso image.  This can take a long time.
 args  = '-R '   # Rock Ridge protocol
 args += '-b boot/grub/stage2_eltorito ' # El Torito boot image
 args += '-no-emul-boot '# No disk emulation for El 
Torito
@@ -143,4 +144,4 @@ class ISOIt(HashIt):
 args += '-boot-info-table ' # Create El Torito boot info 
table
 medium_path = os.path.join(self.tmpdir, self.medium_name)
 cmd = 'mkisofs %s -o %s %s' % (args, medium_path, iso_dir)
-Execute(cmd, timeout=600, logfile=self.logfile)
+Execute(cmd, timeout=None, logfile=self.logfile)



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-15 Thread Anthony G. Basile
commit: 9d17125630f15b8219a5b967c14fae1a4a4936bc
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Sep 16 00:42:25 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Sep 16 00:42:25 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=9d171256

grs/Execute.py: fix typo.

 grs/Execute.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 32286ec..355fbe8 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -27,7 +27,7 @@ from grs.Constants import CONST
 class Execute():
 """ Execute a shell command """
 
-def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, shell 
= False \
+def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, shell 
= False, \
 logfile = CONST.LOGFILE):
 """ Execute a shell command.
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-15 Thread Anthony G. Basile
commit: 7fd80a5aacbcae4eb5d2526b9d9a831eb089fcdb
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Sep 16 05:21:18 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Sep 16 05:21:18 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=7fd80a5a

grs/Kernel.py: build either modular or static kernel.

 grs/Kernel.py | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 7f96d91..7ec5615 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -40,12 +40,15 @@ class Kernel():
 def parse_kernel_config(self):
 """ Parse the version to be built/installed from the kernel-config 
file. """
 with open(self.kernel_config, 'r') as f:
-for i in range(3):
-line = f.readline()
+lines = f.readlines()
+# Are we building a modular kernel or statically linked?
+has_modules = 'CONFIG_MODULES=y\n' in lines
+# The third line is the version line in the kernel config file.
+version_line = lines[2]
 # The version line looks like the following:
 # Linux/x86 4.0.6-hardened-r2 Kernel Configuration
 # The 2nd group contains the version.
-m = re.search('^#\s+(\S+)\s+(\S+).+$', line)
+m = re.search('^#\s+(\S+)\s+(\S+).+$', version_line)
 gentoo_version = m.group(2)
 try:
 # Either the verison is of the form '4.0.6-hardened-r2' with two 
-'s
@@ -61,7 +64,7 @@ class Kernel():
 flavor = m.group(2)
 pkg_name = flavor + '-sources-' + vanilla_version
 pkg_name = '=sys-kernel/' + pkg_name
-return (gentoo_version, pkg_name)
+return (gentoo_version, pkg_name, has_modules)
 
 
 def kernel(self):
@@ -72,7 +75,7 @@ class Kernel():
 and finally installs it to the system's portage configroot.
 """
 # Grab the parsed verison and pkg atom.
-(gentoo_version, pkg_name) = self.parse_kernel_config()
+(gentoo_version, pkg_name, has_modules) = self.parse_kernel_config()
 
 # Prepare the paths to where we'll emerge and build the kernel,
 # as well as paths for genkernel.
@@ -117,10 +120,14 @@ class Kernel():
 cmd += '--bootdir=%s '   % boot_dir
 cmd += '--module-prefix=%s ' % image_dir
 cmd += '--modprobedir=%s '   % modprobe_dir
-cmd += 'all'
+if has_modules:
+cmd += 'all'
+else:
+cmd += 'bzImage'
 Execute(cmd, timeout=None, logfile=self.logfile)
 
 # Strip the modules to shrink their size enormously!
+# This will do nothing if there is not modules_dir
 for dirpath, dirnames, filenames in os.walk(modules_dir):
 for filename in filenames:
 if filename.endswith('.ko'):



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-15 Thread Anthony G. Basile
commit: 8b6bca504dd7ef66426c50f8d510987021f872ad
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Wed Sep 16 00:37:10 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Wed Sep 16 00:37:10 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=8b6bca50

grs/Execute.py: allow running of a cmd in a shell.

 grs/Execute.py | 12 
 grs/ISOIt.py   |  4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/grs/Execute.py b/grs/Execute.py
index 25f618f..32286ec 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -27,7 +27,8 @@ from grs.Constants import CONST
 class Execute():
 """ Execute a shell command """
 
-def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, 
logfile = CONST.LOGFILE):
+def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, shell 
= False \
+logfile = CONST.LOGFILE):
 """ Execute a shell command.
 
 cmd - Simple string of the command to be execute as a
@@ -54,15 +55,18 @@ class Execute():
 except ProcessLookupError:
 pass
 
-args = shlex.split(cmd)
+if shell:
+args = cmd
+else:
+args = shlex.split(cmd)
 extra_env = dict(os.environ, **extra_env)
 
 if logfile:
 f = open(logfile, 'a')
-proc = subprocess.Popen(args, stdout=f, stderr=f, env=extra_env)
+proc = subprocess.Popen(args, stdout=f, stderr=f, env=extra_env, 
shell=shell)
 else:
 f = sys.stderr
-proc = subprocess.Popen(args, env=extra_env)
+proc = subprocess.Popen(args, env=extra_env, shell=shell)
 
 try:
 proc.wait(timeout)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index ff63506..49b97bf 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -93,8 +93,8 @@ class ISOIt(HashIt):
 cwd = os.getcwd()
 os.chdir(initramfs_root)
 cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_path
-# Can't pipe commands, so we'll have to find another way
-#Execute(cmd, timeout=600, logfile=self.logfile)
+# Piped commands must be run in a shell.
+Execute(cmd, timeout=600, logfile=self.logfile, shell=True)
 os.chdir(cwd)
 
 



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-14 Thread Anthony G. Basile
commit: b4b3090dd905c7f0323c446bae1155b5c4f59710
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Sep 14 07:21:42 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Sep 14 07:21:42 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=b4b3090d

grs/Interpret.py: fix medium_type for hashit.

 grs/Interpret.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 05fdc64..b99fd35 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -158,6 +158,7 @@ class Interpret(Daemon):
 build_script = os.path.join(libdir, 'build')
 with open(build_script, 'r') as s:
 line_number = 0
+medium_type = None
 for l in s.readlines():
 line_number += 1
 
@@ -198,7 +199,6 @@ class Interpret(Daemon):
 # build script are implemented.  Note: 'hashit' can only come
 # after 'tarit' or 'isoit' so that it knows the medium_name
 # to hash, ie whether its a .tar.xz or a .iso
-medium_type = None
 if verb == '':
 stampit(progress)
 continue



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-13 Thread Anthony G. Basile
commit: 363fc06845b0666dda39b48c205aa382168acd7a
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sun Sep 13 17:35:51 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sun Sep 13 17:35:51 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=363fc068

grs/ISOIt.py: add in build for initramfs and iso.

 grs/ISOIt.py | 104 +++
 1 file changed, 83 insertions(+), 21 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index 9b3a920..2a0be81 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -39,31 +39,93 @@ class ISOIt(HashIt):
 self.digest_name = '%s.DIGESTS' % self.medium_name
 
 
+def initramfs(self, isoboot_dir):
+""" TODO """
+# Paths to where we'll build busybox and the initramfs.
+busybox_root = os.path.join(self.workdir, 'busybox')
+busybox_path = os.path.join(busybox_root, 'bin/busybox')
+savedconfig_path = os.path.join(busybox_root, 
'etc/portage/savedconfig/sys-apps/busybox')
+busybox_config   = os.path.join(self.libdir, 'scripts/busybox-config')
+
+# Remove any old busybox build directory and prepare new one.
+shutil.rmtree(busybox_root, ignore_errors=True)
+os.makedirs(savedconfig_dir, mode=0o755, exist_ok=True)
+shutil.copyfile(busybox_config, savedconfig_path)
+
+# Emerge busybox.
+cmd = 'emerge --nodeps -1 busybox'
+emerge_env = { 'USE' : '-* savedconfig', 'ROOT' : busybox_root }
+Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
+
+# Remove any old initramfs root and prepare a new one.
+initramfs_root = os.path.join(self.workdir, 'initramfs')
+shutil.rmtree(initramfs_root, ignore_errors=True)
+root_paths = ['bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 
'mnt/tmpfs',
+'proc', 'sbin', 'sys', 'tmp', 'usr/bin', 'usr/sbin', 'var', 
'var/run']
+for p in root_paths:
+d = os.path.join(initramfs_root, p)
+os.makdirs(d, mode=0o755, exist_ok=True)
+
+# Copy the static busybox to the initramfs root.
+# TODO: we are assuming a static busybox, so we should check.
+shutil.copyfile(busybox_path, os.join.path(initramfs_root, 
'bin/busybox'))
+cmd = 'chroot %s /bin/busybox --install -s' % initramfs_root
+Execute(cmd, timeout=60, logfile=self.logfile)
+initscript_path = os.path.join(self.libdir, 'scripts/initramfs-init')
+shutil.copy(initscript_path, initramfs_root)
+
+# TODO: we are assuming a static kernel and so not copying in
+# any modules.  This is where we should copy in modules.
+
+# cpio-gzip the initramfs root to the iso boot dir
+initramfs_path = os.path.join(isoboot_dir, 'initramfs')
+cwd = os.getcwd()
+os.chdir(initramfs_root)
+cmd = 'find . | cpio -H newc -o | gzip -9 > %s' % initramfs_path
+Execute(cmd, timeout=600, logfile=self.logfile)
+os.chdir(cwd)
+
+
 def isoit(self, alt_name = None):
 # Create the ISO with the default name unless an alt_name is given.
 if alt_name:
 self.medium_name = '%s-%s%s%s.iso' % (alt_name, self.year, 
self.month, self.day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
-iso_path = os.path.join(self.workdir, 'iso')
-grub_path = os.path.join(iso_path, 'boot/grub')
-os.makedirs(grub_path, mode=0o755, exist_ok=False)
-#
+iso_dir = os.path.join(self.workdir, 'iso')
+isoboot_dir = os.path.join(iso_dir, 'boot')
+isogrub_dir = os.path.join(isoboot_dir, 'grub')
+os.makedirs(isogrub_dir, mode=0o755, exist_ok=False)
+
 # 1. build initramfs image and copy it in
-#locate a build script for the initramfs in self.libdir/scripts
-#locate a busybox config script in self.libdir/scripts
-#locate an init scripts in self.libdir/scripts
-#copy in any kernel modules(?)
-#find . | cpio -H newc -o | gzip -9 > iso/boot/initramfs.igz
-#
-# 2. make the squashfs image and copy it into the iso/boot
-squashfs_path = os.path.join(iso_path, 'rootfs')
+self.initramfs(isoboot_dir)
+
+# 2. Move the kernel image into the iso/boot directory.
+# TODO: we are assuming a static kernel
+kernelimage_dir  = os.path.join(self.portage_configroot, 'boot')
+kernelimage_path = os.path.join(kernelimage_dir, 'kernel')
+shutil.copy(kernelimage_path, isoboot_dir)
+shutil.rmtree(kernelimage_dir, ignore_errors=True)
+
+# 3. make the squashfs image and copy it into the iso/boot
+squashfs_path = os.path.join(iso_dir, 'rootfs')
 cmd = 'mksquashfs %s %s -xattrs -comp xz' % (self.portage_configroot, 
squashfs_path)
-Execute(cmd, timeout=None, logfile=self.logfile)
-#
-

[gentoo-commits] proj/grss:master commit in: grs/

2015-09-13 Thread Anthony G. Basile
commit: f94049b00db8ee54bb4d616570e372589efa5234
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Sep 14 00:33:54 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Sep 14 00:33:54 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=f94049b0

grs/ISOIt.py: fix various path issues.

 grs/ISOIt.py | 39 ---
 grs/Interpret.py |  2 +-
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index 2a0be81..7db86d3 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -17,6 +17,7 @@
 #along with this program.  If not, see .
 
 import os
+import shutil
 from datetime import datetime
 from grs.Constants import CONST
 from grs.Execute import Execute
@@ -25,10 +26,10 @@ from grs.HashIt import HashIt
 class ISOIt(HashIt):
 """ Create a bootable ISO of the system. """
 
-def __init__(self, name, libdir = CONST.LIBDIR, workdir = CONST.WORKDIR, \
+def __init__(self, name, libdir = CONST.LIBDIR, tmpdir = CONST.TMPDIR, \
 portage_configroot = CONST.PORTAGE_CONFIGROOT, logfile = 
CONST.LOGFILE):
 self.libdir = libdir
-self.workdir = workdir
+self.tmpdir = tmpdir
 self.portage_configroot = portage_configroot
 self.logfile = logfile
 # Prepare a year, month and day for a ISO name timestamp.
@@ -42,9 +43,10 @@ class ISOIt(HashIt):
 def initramfs(self, isoboot_dir):
 """ TODO """
 # Paths to where we'll build busybox and the initramfs.
-busybox_root = os.path.join(self.workdir, 'busybox')
+busybox_root = os.path.join(self.tmpdir, 'busybox')
 busybox_path = os.path.join(busybox_root, 'bin/busybox')
-savedconfig_path = os.path.join(busybox_root, 
'etc/portage/savedconfig/sys-apps/busybox')
+savedconfig_dir  = os.path.join(busybox_root, 
'etc/portage/savedconfig/sys-apps')
+savedconfig_path = os.path.join(savedconfig_dir, 'busybox')
 busybox_config   = os.path.join(self.libdir, 'scripts/busybox-config')
 
 # Remove any old busybox build directory and prepare new one.
@@ -53,26 +55,30 @@ class ISOIt(HashIt):
 shutil.copyfile(busybox_config, savedconfig_path)
 
 # Emerge busybox.
-cmd = 'emerge --nodeps -1 busybox'
+cmd = 'emerge --nodeps -1q busybox'
 emerge_env = { 'USE' : '-* savedconfig', 'ROOT' : busybox_root }
 Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
 
 # Remove any old initramfs root and prepare a new one.
-initramfs_root = os.path.join(self.workdir, 'initramfs')
+initramfs_root = os.path.join(self.tmpdir, 'initramfs')
 shutil.rmtree(initramfs_root, ignore_errors=True)
 root_paths = ['bin', 'dev', 'etc', 'mnt/cdrom', 'mnt/squashfs', 
'mnt/tmpfs',
 'proc', 'sbin', 'sys', 'tmp', 'usr/bin', 'usr/sbin', 'var', 
'var/run']
 for p in root_paths:
 d = os.path.join(initramfs_root, p)
-os.makdirs(d, mode=0o755, exist_ok=True)
+os.makedirs(d, mode=0o755, exist_ok=True)
 
 # Copy the static busybox to the initramfs root.
 # TODO: we are assuming a static busybox, so we should check.
-shutil.copyfile(busybox_path, os.join.path(initramfs_root, 
'bin/busybox'))
+busybox_initramfs_path = os.path.join(initramfs_root, 'bin/busybox')
+shutil.copyfile(busybox_path, busybox_initramfs_path)
+os.chmod(busybox_initramfs_path, 0o0755)
 cmd = 'chroot %s /bin/busybox --install -s' % initramfs_root
 Execute(cmd, timeout=60, logfile=self.logfile)
 initscript_path = os.path.join(self.libdir, 'scripts/initramfs-init')
-shutil.copy(initscript_path, initramfs_root)
+init_initramfs_path = os.path.join(initramfs_root, 'init')
+shutil.copy(initscript_path, init_initramfs_path)
+os.chmod(init_initramfs_path, 0o0755)
 
 # TODO: we are assuming a static kernel and so not copying in
 # any modules.  This is where we should copy in modules.
@@ -81,8 +87,9 @@ class ISOIt(HashIt):
 initramfs_path = os.path.join(isoboot_dir, 'initramfs')
 cwd = os.getcwd()
 os.chdir(initramfs_root)
-cmd = 'find . | cpio -H newc -o | gzip -9 > %s' % initramfs_path
-Execute(cmd, timeout=600, logfile=self.logfile)
+cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_path
+# Can't pipe commands, so we'll have to find another way
+#Execute(cmd, timeout=600, logfile=self.logfile)
 os.chdir(cwd)
 
 
@@ -91,9 +98,10 @@ class ISOIt(HashIt):
 if alt_name:
 self.medium_name = '%s-%s%s%s.iso' % (alt_name, self.year, 
self.month, self.day)
 self.digest_name = '%s.DIGESTS' % self.medium_name
-iso_dir = os.path.join(self.workdir, 'iso')
+iso_dir 

[gentoo-commits] proj/grss:master commit in: grs/

2015-09-13 Thread Anthony G. Basile
commit: efdd9595bd4af8e636b46f4eb10a7f75637d4b6e
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Sep 14 05:37:12 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Sep 14 05:37:12 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=efdd9595

grs/ISOIt.py: do not remove /boot from system root.

 grs/ISOIt.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index dcf05fe..ff63506 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -117,7 +117,8 @@ class ISOIt(HashIt):
 kernelimage_dir  = os.path.join(self.portage_configroot, 'boot')
 kernelimage_path = os.path.join(kernelimage_dir, 'kernel')
 shutil.copy(kernelimage_path, isoboot_dir)
-shutil.rmtree(kernelimage_dir, ignore_errors=True)
+# If this fails, we'll have to rebuild the kernel!
+#shutil.rmtree(kernelimage_dir, ignore_errors=True)
 
 # 3. make the squashfs image and copy it into the iso/boot
 squashfs_path = os.path.join(iso_dir, 'rootfs')



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-13 Thread Anthony G. Basile
commit: cd2eb679f30ce189d8951f8f8982538e3fa9eb1d
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Mon Sep 14 05:30:04 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Mon Sep 14 05:30:04 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=cd2eb679

grs/ISOIt.py: fix build of busybox.

 grs/ISOIt.py | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
index 7db86d3..dcf05fe 100644
--- a/grs/ISOIt.py
+++ b/grs/ISOIt.py
@@ -45,6 +45,7 @@ class ISOIt(HashIt):
 # Paths to where we'll build busybox and the initramfs.
 busybox_root = os.path.join(self.tmpdir, 'busybox')
 busybox_path = os.path.join(busybox_root, 'bin/busybox')
+makeprofile_path = os.path.join(busybox_root, 
'etc/portage/make.profile')
 savedconfig_dir  = os.path.join(busybox_root, 
'etc/portage/savedconfig/sys-apps')
 savedconfig_path = os.path.join(savedconfig_dir, 'busybox')
 busybox_config   = os.path.join(self.libdir, 'scripts/busybox-config')
@@ -52,11 +53,13 @@ class ISOIt(HashIt):
 # Remove any old busybox build directory and prepare new one.
 shutil.rmtree(busybox_root, ignore_errors=True)
 os.makedirs(savedconfig_dir, mode=0o755, exist_ok=True)
-shutil.copyfile(busybox_config, savedconfig_path)
+shutil.copy(busybox_config, savedconfig_path)
 
 # Emerge busybox.
+os.symlink('/usr/portage/profiles/hardened/linux/amd64', 
makeprofile_path)
 cmd = 'emerge --nodeps -1q busybox'
-emerge_env = { 'USE' : '-* savedconfig', 'ROOT' : busybox_root }
+emerge_env = { 'USE' : '-* savedconfig', 'ROOT' : busybox_root,
+'PORTAGE_CONFIGROOT' : busybox_root }
 Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
 
 # Remove any old initramfs root and prepare a new one.
@@ -71,10 +74,12 @@ class ISOIt(HashIt):
 # Copy the static busybox to the initramfs root.
 # TODO: we are assuming a static busybox, so we should check.
 busybox_initramfs_path = os.path.join(initramfs_root, 'bin/busybox')
-shutil.copyfile(busybox_path, busybox_initramfs_path)
+shutil.copy(busybox_path, busybox_initramfs_path)
 os.chmod(busybox_initramfs_path, 0o0755)
 cmd = 'chroot %s /bin/busybox --install -s' % initramfs_root
 Execute(cmd, timeout=60, logfile=self.logfile)
+
+# Copy the init script to the initramfs root.
 initscript_path = os.path.join(self.libdir, 'scripts/initramfs-init')
 init_initramfs_path = os.path.join(initramfs_root, 'init')
 shutil.copy(initscript_path, init_initramfs_path)
@@ -126,8 +131,8 @@ class ISOIt(HashIt):
 cmd = 'emerge --nodeps -1q grub:0'
 emerge_env = { 'USE' : '-* savedconfig', 'ROOT' : grub_root }
 Execute(cmd, timeout=600, extra_env=emerge_env, logfile=self.logfile)
-shutil.copyfile(eltorito_path, isogrub_dir)
-shutil.copyfile(menulst_path, isogrub_dir)
+shutil.copy(eltorito_path, isogrub_dir)
+shutil.copy(menulst_path, isogrub_dir)
 
 # 5. create the iso image
 args  = '-R '   # Rock Ridge protocol



[gentoo-commits] proj/grss:master commit in: grs/

2015-09-12 Thread Anthony G. Basile
commit: cd8a1249340c70ea0fce5fd9a1fb7f02a3dcf511
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Sep 12 18:17:49 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Sep 12 21:01:00 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=cd8a1249

grs/HashIt.py: make into inheritable class.

 grs/{TarIt.py => HashIt.py} | 46 +-
 grs/TarIt.py| 49 -
 grs/__init__.py |  3 ++-
 3 files changed, 20 insertions(+), 78 deletions(-)

diff --git a/grs/TarIt.py b/grs/HashIt.py
similarity index 51%
copy from grs/TarIt.py
copy to grs/HashIt.py
index b63258b..817364a 100644
--- a/grs/TarIt.py
+++ b/grs/HashIt.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-#TarIt.py: this file is part of the GRS suite
+#HashIt.py: this file is part of the GRS suite
 #Copyright (C) 2015  Anthony G. Basile
 #
 #This program is free software: you can redistribute it and/or modify
@@ -17,39 +17,13 @@
 #along with this program.  If not, see .
 
 import os
-from datetime import datetime
-from grs.Constants import CONST
 from grs.Execute import Execute
 
-class TarIt():
-""" Create a tarball of the system and generate the hash values. """
-
-def __init__(self, name, portage_configroot = CONST.PORTAGE_CONFIGROOT, 
logfile = CONST.LOGFILE):
-self.portage_configroot = portage_configroot
-self.logfile = logfile
-# Prepare a year, month and day for a tarball name timestamp.
-self.year = str(datetime.now().year).zfill(4)
-self.month = str(datetime.now().month).zfill(2)
-self.day = str(datetime.now().day).zfill(2)
-self.tarball_name = '%s-%s%s%s.tar.xz' % (name, self.year, self.month, 
self.day)
-self.digest_name = '%s.DIGESTS' % self.tarball_name
-
-
-def tarit(self, alt_name = None):
-# Create the tarball with the default name unless an alt_name is given.
-if alt_name:
-self.tarball_name = '%s-%s%s%s.tar.xz' % (alt_name, self.year, 
self.month, self.day)
-self.digest_name = '%s.DIGESTS' % self.tarball_name
-# We have to cd into the system's portage configroot and then out 
again.
-cwd = os.getcwd()
-os.chdir(self.portage_configroot)
-tarball_path = os.path.join('..', self.tarball_name)
-# TODO: This needs to be generalized for systems that don't support 
xattrs
-xattr_opts = '--xattrs --xattrs-include=security.capability 
--xattrs-include=user.pax.flags'
-cmd = 'tar %s -Jcf %s .' % (xattr_opts, tarball_path)
-Execute(cmd, timeout=None, logfile=self.logfile)
-os.chdir(cwd)
-
+class HashIt():
+""" Create a DIGEST file for certain tarballs, or ISOs.  This class must
+be inherited by a class which sets the medium_name and digest_name,
+else we'll get an AttributeError exception.
+"""
 
 def hashit(self):
 """ Generate various hash values.  We hijack the 'logfile' which will
@@ -64,22 +38,22 @@ class TarIt():
 # Note: this first cmd clobbers the contents
 cmd = 'echo "# MD5 HASH"'
 Execute(cmd, logfile=self.digest_name)
-cmd = 'md5sum %s' % self.tarball_name
+cmd = 'md5sum %s' % self.medium_name
 Execute(cmd, timeout=60, logfile=self.digest_name)
 
 cmd = 'echo "# SHA1 HASH"'
 Execute(cmd, logfile=self.digest_name)
-cmd = 'sha1sum %s' % self.tarball_name
+cmd = 'sha1sum %s' % self.medium_name
 Execute(cmd, timeout=60, logfile=self.digest_name)
 
 cmd = 'echo "# SHA512 HASH"'
 Execute(cmd, logfile=self.digest_name)
-cmd = 'sha512sum %s' % self.tarball_name
+cmd = 'sha512sum %s' % self.medium_name
 Execute(cmd, timeout=60, logfile=self.digest_name)
 
 cmd = 'echo "# WHIRLPOOL HASH"'
 Execute(cmd, logfile=self.digest_name)
-cmd = 'whirlpooldeep %s' % self.tarball_name
+cmd = 'whirlpooldeep %s' % self.medium_name
 Execute(cmd, timeout=60, logfile=self.digest_name)
 
 os.chdir(cwd)

diff --git a/grs/TarIt.py b/grs/TarIt.py
index b63258b..d421cf2 100644
--- a/grs/TarIt.py
+++ b/grs/TarIt.py
@@ -20,9 +20,10 @@ import os
 from datetime import datetime
 from grs.Constants import CONST
 from grs.Execute import Execute
+from grs.HashIt import HashIt
 
-class TarIt():
-""" Create a tarball of the system and generate the hash values. """
+class TarIt(HashIt):
+""" Create a tarball of the system. """
 
 def __init__(self, name, portage_configroot = CONST.PORTAGE_CONFIGROOT, 
logfile = CONST.LOGFILE):
 self.portage_configroot = portage_configroot
@@ -31,55 +32,21 @@ class TarIt():
 self.year = str(datetime.now().year).zfill(4)
 self.month = str(datetime.now().month).zfill(2)
 self.day = str(datetime.now().day).zfill(2)
-

[gentoo-commits] proj/grss:master commit in: grs/

2015-09-12 Thread Anthony G. Basile
commit: 25eb96b12eabb19cceab7205696fc5d7fa90933b
Author: Anthony G. Basile  gentoo  org>
AuthorDate: Sat Sep 12 20:14:53 2015 +
Commit: Anthony G. Basile  gentoo  org>
CommitDate: Sat Sep 12 21:01:00 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=25eb96b1

grs/ISOIt.py: initial commit of isoit directive.

 grs/ISOIt.py | 69 
 grs/Interpret.py | 25 ++--
 grs/__init__.py  |  1 +
 3 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/grs/ISOIt.py b/grs/ISOIt.py
new file mode 100644
index 000..9b3a920
--- /dev/null
+++ b/grs/ISOIt.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+#ISOIt.py: this file is part of the GRS suite
+#Copyright (C) 2015  Anthony G. Basile
+#
+#This program is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with this program.  If not, see .
+
+import os
+from datetime import datetime
+from grs.Constants import CONST
+from grs.Execute import Execute
+from grs.HashIt import HashIt
+
+class ISOIt(HashIt):
+""" Create a bootable ISO of the system. """
+
+def __init__(self, name, libdir = CONST.LIBDIR, workdir = CONST.WORKDIR, \
+portage_configroot = CONST.PORTAGE_CONFIGROOT, logfile = 
CONST.LOGFILE):
+self.libdir = libdir
+self.workdir = workdir
+self.portage_configroot = portage_configroot
+self.logfile = logfile
+# Prepare a year, month and day for a ISO name timestamp.
+self.year = str(datetime.now().year).zfill(4)
+self.month = str(datetime.now().month).zfill(2)
+self.day = str(datetime.now().day).zfill(2)
+self.medium_name = '%s-%s%s%s.iso' % (name, self.year, self.month, 
self.day)
+self.digest_name = '%s.DIGESTS' % self.medium_name
+
+
+def isoit(self, alt_name = None):
+# Create the ISO with the default name unless an alt_name is given.
+if alt_name:
+self.medium_name = '%s-%s%s%s.iso' % (alt_name, self.year, 
self.month, self.day)
+self.digest_name = '%s.DIGESTS' % self.medium_name
+iso_path = os.path.join(self.workdir, 'iso')
+grub_path = os.path.join(iso_path, 'boot/grub')
+os.makedirs(grub_path, mode=0o755, exist_ok=False)
+#
+# 1. build initramfs image and copy it in
+#locate a build script for the initramfs in self.libdir/scripts
+#locate a busybox config script in self.libdir/scripts
+#locate an init scripts in self.libdir/scripts
+#copy in any kernel modules(?)
+#find . | cpio -H newc -o | gzip -9 > iso/boot/initramfs.igz
+#
+# 2. make the squashfs image and copy it into the iso/boot
+squashfs_path = os.path.join(iso_path, 'rootfs')
+cmd = 'mksquashfs %s %s -xattrs -comp xz' % (self.portage_configroot, 
squashfs_path)
+Execute(cmd, timeout=None, logfile=self.logfile)
+#
+# 3. prepare the grub bootloader
+#copy in stage2_eltorito into iso/boot/grub
+#copy in menu.lst into iso/boot/grub
+#
+# 4. create the iso image
+#mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot 
-boot-load-size 4 \
+#-boot-info-table -o medium_pathname.iso iso

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 5f06fe9..4fdb31b 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -24,6 +24,7 @@ import time
 
 from grs.Constants import CONST
 from grs.Daemon import Daemon
+from grs.ISOIt import ISOIt
 from grs.Log import Log
 from grs.Kernel import Kernel
 from grs.MountDirectories import MountDirectories
@@ -130,6 +131,7 @@ class Interpret(Daemon):
 pc = PivotChroot(tmpdir, portage_configroot, logfile)
 ke = Kernel(libdir, portage_configroot, kernelroot, package, logfile)
 bi = TarIt(name, portage_configroot, logfile)
+io = ISOIt(name, libdir, workdir, portage_configroot, logfile)
 
 # Just in case /var/tmp/grs doesn't already exist.
 os.makedirs(tmpdir, mode=0o755, exist_ok=True)
@@ -193,7 +195,10 @@ class Interpret(Daemon):
 obj = None
 
 # This long concatenated if is where the semantics of the
-# build script are implemented.
+# build script are implemented.  Note: 'hashit' can only come
+# after 

[gentoo-commits] proj/grss:master commit in: grs/, conf/, tests/

2015-08-09 Thread Anthony G. Basile
commit: 5abaa600ab3fe65d18c15e228cc0e36ba4d690c7
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sun Aug  9 21:47:13 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sun Aug  9 21:47:13 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=5abaa600

Remove CONST.namervers[].  To be provided by grs repo.

 conf/systems.conf   |  4 
 grs/Constants.py|  7 +++
 grs/Interpret.py|  3 +--
 grs/Populate.py | 11 +--
 tests/test-constants.py |  1 -
 5 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/conf/systems.conf b/conf/systems.conf
index c2f0b51..e80b6b8 100644
--- a/conf/systems.conf
+++ b/conf/systems.conf
@@ -1,19 +1,15 @@
 [desktop-amd64-uclibc-hardened]
-nameserver : 8.8.8.8
 repo_uri : git://anongit.gentoo.org/proj/grs.git
 stage_uri : 
http://distfiles.gentoo.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-uclibc-hardened/stage3-amd64-uclibc-hardened-20150705.tar.bz2
 
 [desktop-amd64-musl-hardened]
-nameserver : 8.8.8.8
 repo_uri : git://anongit.gentoo.org/proj/grs.git
 stage_uri : 
http://distfiles.gentoo.org/experimental/amd64/musl/stage3-amd64-musl-hardened-20150609.tar.bz2
 
 [desktop-amd64-hardened]
-nameserver : 8.8.8.8
 repo_uri : git://anongit.gentoo.org/proj/grs.git
 stage_uri : 
http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-hardened+nomultilib/stage3-amd64-hardened+nomultilib-20150723.tar.bz2
 
 [stages-amd64-hardened]
-nameserver : 8.8.8.8
 repo_uri : git://anongit.gentoo.org/proj/grs.git
 stage_uri : 
http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-20150702.tar.bz2

diff --git a/grs/Constants.py b/grs/Constants.py
index 79551f9..0025eb4 100644
--- a/grs/Constants.py
+++ b/grs/Constants.py
@@ -26,7 +26,6 @@ class Constants():
  Read a global configuration file and set/override constants for
 each GRS spec.  These constants are exported in the form:
 
-CONST.nameservers[x] contains the namserver for the xth GRS spec
 CONST.repo_uris[x] contains the repo_uri for the xth GRS spec
 etc.
 
@@ -44,13 +43,14 @@ class Constants():
 kernelroot : /tmp/kernel_src_tree
 
 [my-cool-server]
-nameserver : 192.168.100.1
+package : /var/tmp/my-packages
 
 Then CONST.kernelroots[0] is '/tmp/kernel_src_tree' rather than the
 default value '/var/tmp/grs/my-cool-desktop/kernel'.  The remainder
 of the constants default as delineated in the space[] dictionary with
 %s replaced by 'my-cool-desktop'.  Similarly CONST.my-cool-servers[1]
-is 192.168.100.1 rather than 8.8.8.8.
+has package directory '/var/tmp/my-package' rather than the default
+value '/var/tmp/grs/my-cool-server/packages',
 
 Finally, the that class overrides __setattr__, __gettattr__ and
 __delattr__ so that you cannot add/change/delete constants in
@@ -75,7 +75,6 @@ class Constants():
 
 # This is the space of all possible constants for any given GRS 
namespace
 space = {
-'nameserver'  : '8.8.8.8',
 'repo_uri': 'git://anongit.gentoo.org/proj/grs.git',
 'stage_uri'   : default_stage_uri,
 'libdir'  : '/var/lib/grs/%s',

diff --git a/grs/Interpret.py b/grs/Interpret.py
index a7c0915..5f06fe9 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -106,7 +106,6 @@ class Interpret(Daemon):
 signal.signal(signal.SIGTERM, handler)
 
 # Grab all the GRS namespace variables
-nameserver  = CONST.nameservers[self.run_number]
 repo_uri= CONST.repo_uris[self.run_number]
 stage_uri   = CONST.stage_uris[self.run_number]
 
@@ -126,7 +125,7 @@ class Interpret(Daemon):
 sy = Synchronize(repo_uri, name, libdir, logfile)
 se = Seed(stage_uri, tmpdir, portage_configroot, package, logfile)
 md = MountDirectories(portage_configroot, package, logfile)
-po = Populate(nameserver, libdir, workdir, portage_configroot, logfile)
+po = Populate(libdir, workdir, portage_configroot, logfile)
 ru = RunScript(libdir, portage_configroot, logfile)
 pc = PivotChroot(tmpdir, portage_configroot, logfile)
 ke = Kernel(libdir, portage_configroot, kernelroot, package, logfile)

diff --git a/grs/Populate.py b/grs/Populate.py
index c24fd63..fc7e799 100644
--- a/grs/Populate.py
+++ b/grs/Populate.py
@@ -27,16 +27,12 @@ class Populate():
 for a particular cycle number.
 
 
-def __init__(self, nameserver, libdir = CONST.LIBDIR, workdir = 
CONST.WORKDIR, \
+def __init__(self, libdir = CONST.LIBDIR, workdir = CONST.WORKDIR, \
 portage_configroot = CONST.PORTAGE_CONFIGROOT, logfile = 
CONST.LOGFILE):
-self.nameserver = nameserver
 self.libdir = libdir
 

[gentoo-commits] proj/grss:master commit in: grs/

2015-08-09 Thread Anthony G. Basile
commit: a41100e5a1c3514bf316e5e5982c3f749e203892
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sun Aug  9 20:29:20 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sun Aug  9 20:29:20 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=a41100e5

grs/Kernel.py: don't rebuild/reinstall a kernel if its linux-image tarball 
exists.

 grs/Kernel.py | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index bb76b80..7f96d91 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -80,9 +80,16 @@ class Kernel():
 image_dir = os.path.join(self.kernelroot, gentoo_version)
 boot_dir  = os.path.join(image_dir, 'boot')
 modprobe_dir  = os.path.join(image_dir, 'etc/modprobe.d')
-# TODO: modules_dir really needs $(get_libdir), eg /lib64.
-# For example, this breaks on amd64 multilib.
 modules_dir   = os.path.join(image_dir, 'lib/modules')
+# Prepare tarball filename and path.  If the tarball already exists,
+# don't rebuild/reinstall it.  Note: It should have been installed to
+# the system's portage configroot when it was first built, so no need
+# to reinstall it.
+linux_images = os.path.join(self.package, 'linux-images')
+tarball_name = 'linux-image-%s.tar.xz' % gentoo_version
+tarball_path = os.path.join(linux_images, tarball_name)
+if os.path.isfile(tarball_path):
+return
 
 # Remove any old kernel image directory and create a boot directory.
 # Note genkernel assumes a boot directory is present.
@@ -126,15 +133,9 @@ class Kernel():
 Execute(cmd, timeout=60, logfile=self.logfile)
 
 # Tar up the kernel image and modules and place them in 
package/linux-images
-linux_images = os.path.join(self.package, 'linux-images')
 os.makedirs(linux_images, mode=0o755, exist_ok=True)
-tarball_name = 'linux-image-%s.tar.xz' % gentoo_version
-tarball_path = os.path.join(linux_images, tarball_name)
-
 cwd = os.getcwd()
 os.chdir(image_dir)
-if os.path.isfile(tarball_path):
-os.unlink(tarball_path)
 cmd = 'tar -Jcf %s .' % tarball_path
 Execute(cmd, timeout=600, logfile=self.logfile)
 os.chdir(cwd)



[gentoo-commits] proj/grss:master commit in: grs/

2015-08-08 Thread Anthony G. Basile
commit: 6a34bce8dbd3dd31caa62e2e44d7ae58dd609457
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sat Aug  8 17:54:37 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sat Aug  8 17:54:37 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=6a34bce8

grs/Worldconf.py: clear out managed directories before installing.

 grs/WorldConf.py | 36 +---
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index b102e7d..63daace 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -9,15 +9,28 @@ import re
 from grs.Constants import CONST
 
 class WorldConf():
- doc here
-more doc
-
+ Manage files in /etc/portage based on /etc/grs/world.conf 
+
+# TODO: This needs to be expanded.
+manageddirs = ['env', 'package.env', 'package.accept_keywords', \
+'package.use', 'package.mask', 'package.unmask']:
 
 @staticmethod
 def install():
- doc here
-more doc
+ Restore /etc/portage to a prestine stage (removing all files
+in manageddirs, and copy in all files specified in world.conf.
 
+# This is harsh, but we need to start from a clean slate because
+# world.conf can drop sections.  If it does, then those files are
+# orphaned and can inject flags/envvars which are problematic.
+for directory in WorldConf.manageddirs:
+dpath = os.path.join(CONST.PORTAGE_CONFIGDIR, directory)
+for f in os.listdir(dpath):
+fpath = os.path.join(dpath, f)
+if os.path.isfile(fpath):
+os.remove(fpath)
+
+# Now we can read world.conf and populate an empty /etc/portage.
 config = configparser.RawConfigParser(delimiters=':', 
allow_no_value=True, comment_prefixes=None)
 config.read(CONST.WORLD_CONFIG)
 for s in config.sections():
@@ -32,12 +45,14 @@ class WorldConf():
 
 @staticmethod
 def clean():
- doc here
-more doc
+ Remove any files from /etc/portage that are unnecessary, ie that
+do not correspond to installed pkgs.
 
+# We need to look at all portage provide pkgs and all installed pkgs.
 portdb = portage.db[portage.root][porttree].dbapi
 vardb  = portage.db[portage.root][vartree].dbapi
 
+# Remove all installed pkgs from the set of all portage packages.
 uninstalled = portdb.cp_all()
 for p in vardb.cp_all():
 try:
@@ -45,6 +60,7 @@ class WorldConf():
 except ValueError:
 print('%s installed on local system, but not in portage repo 
anymore.' % p)
 
+# Construct a list of canonical named files for uninstalled pkgs.
 slot_atoms = []
 for p in uninstalled:
 cpv = portdb.cp_list(p)[0]
@@ -56,12 +72,10 @@ class WorldConf():
 slot = slotvar
 slot_atoms.append(re.sub('[/:]', '_', '%s:%s' % (p, slot)))
 
+# Walk through all files in /etc/portage and remove any files for 
uninstalled pkgs.
 for dirpath, dirnames, filenames in os.walk(CONST.PORTAGE_CONFIGDIR):
 # Only look at select files and directories.
-# TODO: This needs to be expanded.
-if not os.path.basename(dirpath) in ['env', 'package.env', \
-'package.accept_keywords', 'package.use', \
-'package.mask', 'package.unmask']:
+if not os.path.basename(dirpath) in WorldConf.manageddirs:
 continue
 
 for f in filenames:



[gentoo-commits] proj/grss:master commit in: grs/

2015-08-08 Thread Anthony G. Basile
commit: eb55566218915335cbf9445b1c6176ce9023f025
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sat Aug  8 18:04:08 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sat Aug  8 18:04:08 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=eb555662

grs/WorldConf.py: don't delete from non-existing directories.

 grs/WorldConf.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index 63daace..c496e5f 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -13,7 +13,7 @@ class WorldConf():
 
 # TODO: This needs to be expanded.
 manageddirs = ['env', 'package.env', 'package.accept_keywords', \
-'package.use', 'package.mask', 'package.unmask']:
+'package.use', 'package.mask', 'package.unmask']
 
 @staticmethod
 def install():
@@ -25,6 +25,8 @@ class WorldConf():
 # orphaned and can inject flags/envvars which are problematic.
 for directory in WorldConf.manageddirs:
 dpath = os.path.join(CONST.PORTAGE_CONFIGDIR, directory)
+if not os.path.isdir(dpath):
+continue
 for f in os.listdir(dpath):
 fpath = os.path.join(dpath, f)
 if os.path.isfile(fpath):



[gentoo-commits] proj/grss:master commit in: grs/

2015-08-08 Thread Anthony G. Basile
commit: c74e72983b4c0f34bd56f0d9b16857339cdda8b6
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sat Aug  8 20:08:54 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sat Aug  8 20:08:54 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=c74e7298

grs/WorldConf.py: remove added files to managed dirs during clean.

 grs/WorldConf.py | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/grs/WorldConf.py b/grs/WorldConf.py
index c496e5f..b005f0e 100644
--- a/grs/WorldConf.py
+++ b/grs/WorldConf.py
@@ -74,13 +74,22 @@ class WorldConf():
 slot = slotvar
 slot_atoms.append(re.sub('[/:]', '_', '%s:%s' % (p, slot)))
 
+# Also let's get a list of all the possible canonical file names
+config = configparser.RawConfigParser(delimiters=':', 
allow_no_value=True, comment_prefixes=None)
+config.read(CONST.WORLD_CONFIG)
+canon = []
+for s in config.sections():
+p_slot_atom = re.sub('[/:]', '_', s)
+canon.append(p_slot_atom)
+
 # Walk through all files in /etc/portage and remove any files for 
uninstalled pkgs.
 for dirpath, dirnames, filenames in os.walk(CONST.PORTAGE_CONFIGDIR):
 # Only look at select files and directories.
 if not os.path.basename(dirpath) in WorldConf.manageddirs:
 continue
 
+# Remove all filenames that match uninstalled slot_atoms or are 
not in the canon
 for f in filenames:
 fpath = os.path.realpath(os.path.join(dirpath, f))
-if f in slot_atoms:
+if f in slot_atoms or not f in canon:
 os.remove(fpath)



[gentoo-commits] proj/grss:master commit in: grs/

2015-07-28 Thread Anthony G. Basile
commit: 832278b3f3e505f04508f7a2aaafdfb9b7ab4452
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Tue Jul 28 22:47:21 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Tue Jul 28 22:47:21 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=832278b3

Revert grs/Kernel.py: dereference lib - lib64, don't clobber it.

This reverts commit 75fd42a5a8d40e8ef124526f20989c5a4ee39ce7.

 grs/Kernel.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index 38b8644..c9a99d8 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -119,6 +119,6 @@ class Kernel():
 os.chdir(image_dir)
 if os.path.isfile(tarball_path):
 os.unlink(tarball_path)
-cmd = 'tar -Jchf %s .' % tarball_path
+cmd = 'tar -Jcf %s .' % tarball_path
 Execute(cmd, timeout=600, logfile=self.logfile)
 os.chdir(cwd)



[gentoo-commits] proj/grss:master commit in: grs/

2015-07-28 Thread Anthony G. Basile
commit: a1053d8418f8496d0cffec41f57f801708577455
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Wed Jul 29 00:23:14 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Wed Jul 29 00:23:14 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=a1053d84

grs/Kernel.py: rsync was clobbering lib - lib64, not tar.

 grs/Kernel.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index c9a99d8..cec4a5f 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -106,7 +106,7 @@ class Kernel():
 Execute(cmd)
 
 # Copy the newly compiled kernel image and modules to portage 
configroot
-cmd = 'rsync -a %s/ %s' % (image_dir, self.portage_configroot)
+cmd = 'rsync -aK %s/ %s' % (image_dir, self.portage_configroot)
 Execute(cmd, timeout=60, logfile=self.logfile)
 
 # Tar up the kernel image and modules and place them in 
package/linux-images



[gentoo-commits] proj/grss:master commit in: grs/

2015-07-27 Thread Anthony G. Basile
commit: 75fd42a5a8d40e8ef124526f20989c5a4ee39ce7
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Mon Jul 27 20:52:12 2015 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Mon Jul 27 20:52:12 2015 +
URL:https://gitweb.gentoo.org/proj/grss.git/commit/?id=75fd42a5

grs/Kernel.py: dereference lib - lib64, don't clobber it.

 grs/Kernel.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index c9a99d8..38b8644 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -119,6 +119,6 @@ class Kernel():
 os.chdir(image_dir)
 if os.path.isfile(tarball_path):
 os.unlink(tarball_path)
-cmd = 'tar -Jcf %s .' % tarball_path
+cmd = 'tar -Jchf %s .' % tarball_path
 Execute(cmd, timeout=600, logfile=self.logfile)
 os.chdir(cwd)



  1   2   >