diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2015-07-09 10:49:23 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-07-09 10:49:23 -0400 |
commit | c59ed6dad57d443a0fef14f9b120f5e6b026abc9 (patch) | |
tree | 1817f8761f41918f8d249718d5b8157d45f520c7 /grs/PivotChroot.py | |
parent | grs/RunScript.py: check if the script exists before trying to unlink it. (diff) | |
download | grss-c59ed6dad57d443a0fef14f9b120f5e6b026abc9.tar.gz grss-c59ed6dad57d443a0fef14f9b120f5e6b026abc9.tar.bz2 grss-c59ed6dad57d443a0fef14f9b120f5e6b026abc9.zip |
grs/Rotator.py: consolidate common rotation code.
Diffstat (limited to 'grs/PivotChroot.py')
-rw-r--r-- | grs/PivotChroot.py | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/grs/PivotChroot.py b/grs/PivotChroot.py index 6eec3a0..8ec0fc6 100644 --- a/grs/PivotChroot.py +++ b/grs/PivotChroot.py @@ -9,7 +9,7 @@ from grs.Constants import CONST from grs.MountDirectories import MountDirectories -class PivotChroot(): +class PivotChroot(Rotator): """ doc here more doc """ @@ -32,25 +32,9 @@ class PivotChroot(): if some_mounted: md.umount_all() - # TODO: we need to generalize this code into its own class - # and inherit it here, in Log.py and Seed.py. - # Rotate any previous portage_configroots out of the way - dirs = glob.glob('%s.*' % self.portage_configroot) - indexed_dir = {} - for d in dirs: - m = re.search('^.+\.(\d+)$', d) - indexed_dir[int(m.group(1))] = d - count = list(indexed_dir.keys()) - count.sort() - count.reverse() - for c in count: - current_dir = indexed_dir[c] - m = re.search('^(.+)\.\d+$', current_dir) - next_dir = '%s.%d' % (m.group(1), c+1) - shutil.move(current_dir, next_dir) - - # Assume portage_configroot exists and out of the way to system.0, + # Move portage_configroot out of the way to system.0, # then pivot out the inner chroot to system. + self.rotate(self.portage_configroot) shutil.move(self.portage_configroot, '%s.0' % self.portage_configroot) inner_chroot = os.path.join('%s.0' % self.portage_configroot, subchroot) shutil.move(inner_chroot, os.path.join(self.tmpdir, 'system')) |