Base package list, --shell flag
This commit is contained in:
@@ -28,6 +28,12 @@ parser.add_argument(
|
|||||||
dest='release',
|
dest='release',
|
||||||
action='store',
|
action='store',
|
||||||
required=True)
|
required=True)
|
||||||
|
parser.add_argument(
|
||||||
|
'--shell',
|
||||||
|
dest='shell',
|
||||||
|
action='store',
|
||||||
|
type=bool,
|
||||||
|
default=False)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--source-iso',
|
'--source-iso',
|
||||||
dest='source_iso',
|
dest='source_iso',
|
||||||
@@ -38,6 +44,21 @@ FLAGS = parser.parse_args()
|
|||||||
|
|
||||||
class ImageBuilder(object):
|
class ImageBuilder(object):
|
||||||
|
|
||||||
|
_BASE_PACKAGES = [
|
||||||
|
'debconf',
|
||||||
|
'devscripts',
|
||||||
|
'dialog',
|
||||||
|
'gnupg',
|
||||||
|
'isc-dhcp-client',
|
||||||
|
'locales',
|
||||||
|
'nano',
|
||||||
|
'net-tools',
|
||||||
|
'iputils-ping',
|
||||||
|
'sudo',
|
||||||
|
'user-setup',
|
||||||
|
'wget',
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, source_iso, dest_iso, archive, arch, release):
|
def __init__(self, source_iso, dest_iso, archive, arch, release):
|
||||||
self._source_iso = source_iso
|
self._source_iso = source_iso
|
||||||
self._dest_iso = dest_iso
|
self._dest_iso = dest_iso
|
||||||
@@ -51,6 +72,9 @@ class ImageBuilder(object):
|
|||||||
print('+', args)
|
print('+', args)
|
||||||
subprocess.check_call(args)
|
subprocess.check_call(args)
|
||||||
|
|
||||||
|
def _ExecChroot(self, chroot_path, *args):
|
||||||
|
self._Exec('chroot', chroot_path, *args)
|
||||||
|
|
||||||
def _Debootstrap(self, root):
|
def _Debootstrap(self, root):
|
||||||
path = os.path.join(root, 'chroot')
|
path = os.path.join(root, 'chroot')
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
@@ -100,6 +124,18 @@ class ImageBuilder(object):
|
|||||||
|
|
||||||
return union_path
|
return union_path
|
||||||
|
|
||||||
|
def _InstallPackages(self, chroot_path):
|
||||||
|
self._ExecChroot(
|
||||||
|
chroot_path,
|
||||||
|
'apt-get',
|
||||||
|
'install',
|
||||||
|
'--assume-yes',
|
||||||
|
*self._BASE_PACKAGES)
|
||||||
|
self._ExecChroot(
|
||||||
|
chroot_path,
|
||||||
|
'apt-get',
|
||||||
|
'clean')
|
||||||
|
|
||||||
def _Squash(self, chroot_path, union_path):
|
def _Squash(self, chroot_path, union_path):
|
||||||
self._Exec(
|
self._Exec(
|
||||||
'mksquashfs',
|
'mksquashfs',
|
||||||
@@ -122,6 +158,9 @@ class ImageBuilder(object):
|
|||||||
|
|
||||||
chroot_path = self._Debootstrap(root)
|
chroot_path = self._Debootstrap(root)
|
||||||
union_path = self._CreateUnion(root)
|
union_path = self._CreateUnion(root)
|
||||||
|
self._InstallPackages(chroot_path)
|
||||||
|
if FLAGS.shell:
|
||||||
|
self._Exec('bash')
|
||||||
self._Squash(chroot_path, union_path)
|
self._Squash(chroot_path, union_path)
|
||||||
self._CreateISO(union_path)
|
self._CreateISO(union_path)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user