checking in, adding python and perl to deps
This commit is contained in:
parent
972a0d34b5
commit
b47259f86e
14
TODO
14
TODO
@ -24,6 +24,20 @@ need to write docs
|
|||||||
need to double-check aif.xsd spec for the packaging command- can i specify a single element?
|
need to double-check aif.xsd spec for the packaging command- can i specify a single element?
|
||||||
finish up software/packages section
|
finish up software/packages section
|
||||||
|
|
||||||
|
can i install packages the way pacstrap does, without a chroot? i still need to do it, unfortunately, for setting up efibootmgr etc. but..:
|
||||||
|
pacman -r /mnt/aif -Sy base --cachedir=/mnt/aif/var/cache/pacman/pkg --noconfirm
|
||||||
|
/dev/sda2 on /mnt/aif type ext4 (rw,relatime,data=ordered)
|
||||||
|
/dev/sda1 on /mnt/aif/boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
|
||||||
|
proc on /mnt/aif/proc type proc (rw,nosuid,nodev,noexec,relatime)
|
||||||
|
sys on /mnt/aif/sys type sysfs (ro,nosuid,nodev,noexec,relatime)
|
||||||
|
efivarfs on /mnt/aif/sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
|
||||||
|
udev on /mnt/aif/dev type devtmpfs (rw,nosuid,relatime,size=2012384k,nr_inodes=503096,mode=755)
|
||||||
|
devpts on /mnt/aif/dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
|
||||||
|
shm on /mnt/aif/dev/shm type tmpfs (rw,nosuid,nodev,relatime)
|
||||||
|
run on /mnt/aif/run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
|
||||||
|
tmp on /mnt/aif/tmp type tmpfs (rw,nosuid,nodev)
|
||||||
|
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
http://lxml.de/parsing.html
|
http://lxml.de/parsing.html
|
||||||
https://www.w3.org/2001/XMLSchema.xsd
|
https://www.w3.org/2001/XMLSchema.xsd
|
||||||
|
2
aif.xml
2
aif.xml
@ -50,6 +50,8 @@
|
|||||||
</mirrorlist>
|
</mirrorlist>
|
||||||
<software>
|
<software>
|
||||||
<package name="sed" repo="core" />
|
<package name="sed" repo="core" />
|
||||||
|
<package name="python" />
|
||||||
|
<package name="perl" />
|
||||||
</software>
|
</software>
|
||||||
</pacman>
|
</pacman>
|
||||||
<bootloader type="grub" target="/boot" efi="true" />
|
<bootloader type="grub" target="/boot" efi="true" />
|
||||||
|
89
aifclient.py
89
aifclient.py
@ -304,8 +304,13 @@ class aif(object):
|
|||||||
for x in xmlobj.findall('pacman/mirrorlist'):
|
for x in xmlobj.findall('pacman/mirrorlist'):
|
||||||
for i in x:
|
for i in x:
|
||||||
aifdict['software']['mirrors'].append(i.text)
|
aifdict['software']['mirrors'].append(i.text)
|
||||||
|
# Then the command
|
||||||
|
if xmlobj.find('pacman/command') is None:
|
||||||
|
aifdict['software']['command'] = False
|
||||||
|
else:
|
||||||
|
aifdict['software']['command'] = xmlobj.find('pacman/command').text
|
||||||
# And then the repo list.
|
# And then the repo list.
|
||||||
for x in xmlobj.find('pacman/repos'):
|
for x in xmlobj.findall('pacman/repos/repo'):
|
||||||
repo = x.attrib['name']
|
repo = x.attrib['name']
|
||||||
aifdict['software']['repos'][repo] = {}
|
aifdict['software']['repos'][repo] = {}
|
||||||
aifdict['software']['repos'][repo]['enabled'] = x.attrib['enabled'].lower() in ('true', '1')
|
aifdict['software']['repos'][repo]['enabled'] = x.attrib['enabled'].lower() in ('true', '1')
|
||||||
@ -326,15 +331,6 @@ class aif(object):
|
|||||||
for x in xmlobj.find('bootloader').attrib:
|
for x in xmlobj.find('bootloader').attrib:
|
||||||
aifdict['system']['bootloader'][x] = xmlobj.find('bootloader').attrib[x]
|
aifdict['system']['bootloader'][x] = xmlobj.find('bootloader').attrib[x]
|
||||||
# The script setup...
|
# The script setup...
|
||||||
# We do this later on.
|
|
||||||
# for x in xmlobj.find('scripts'):
|
|
||||||
# if x.attrib['bootstrap'].lower() in ('true', '1'):
|
|
||||||
# scripttype = 'pre'
|
|
||||||
# else:
|
|
||||||
# scripttype = 'post'
|
|
||||||
# if not aifdict['scripts'][scripttype]:
|
|
||||||
# aifdict['scripts'][scripttype] = {}
|
|
||||||
# aifdict['scripts'][scripttype][int(x.attrib['order'])] = {}
|
|
||||||
if xmlobj.find('scripts') is not None:
|
if xmlobj.find('scripts') is not None:
|
||||||
aifdict['scripts']['pre'] = []
|
aifdict['scripts']['pre'] = []
|
||||||
aifdict['scripts']['post'] = []
|
aifdict['scripts']['post'] = []
|
||||||
@ -448,7 +444,7 @@ class archInstall(object):
|
|||||||
usermntidx.sort() # We want to make sure we do this in order.
|
usermntidx.sort() # We want to make sure we do this in order.
|
||||||
for k in usermntidx:
|
for k in usermntidx:
|
||||||
if self.mount[k]['mountpt'] == 'swap':
|
if self.mount[k]['mountpt'] == 'swap':
|
||||||
subprocess.call(['swapon', '-e', self.mount[k]['device']], stdout = log, stderr = subprocess.STDOUT)
|
subprocess.call(['swapon', self.mount[k]['device']], stdout = log, stderr = subprocess.STDOUT)
|
||||||
else:
|
else:
|
||||||
os.makedirs(self.mount[k]['mountpt'], exist_ok = True)
|
os.makedirs(self.mount[k]['mountpt'], exist_ok = True)
|
||||||
os.chown(self.mount[k]['mountpt'], 0, 0)
|
os.chown(self.mount[k]['mountpt'], 0, 0)
|
||||||
@ -675,11 +671,12 @@ class archInstall(object):
|
|||||||
if resolvers:
|
if resolvers:
|
||||||
netprofile += 'DNS=(\'{0}\')\n'.format('\' \''.join(resolvers))
|
netprofile += 'DNS=(\'{0}\')\n'.format('\' \''.join(resolvers))
|
||||||
filename = '{0}/etc/netctl/{1}'.format(self.system['chrootpath'], ifacedev)
|
filename = '{0}/etc/netctl/{1}'.format(self.system['chrootpath'], ifacedev)
|
||||||
|
sysdfile = '{0}/etc/systemd/system/netctl@{1}.service'.format(self.system['chrootpath'], ifacedev)
|
||||||
# The good news is since it's a clean install, we only have to account for our own data, not pre-existing.
|
# The good news is since it's a clean install, we only have to account for our own data, not pre-existing.
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
f.write('# Generated by AIF-NG.\n')
|
f.write('# Generated by AIF-NG.\n')
|
||||||
f.write(netprofile)
|
f.write(netprofile)
|
||||||
with open('{0}/etc/systemd/system/netctl@{1}.service'.format(self.system['chrootpath'], ifacedev)) as f:
|
with open(sysdfile, 'w') as f:
|
||||||
f.write('# Generated by AIF-NG.\n')
|
f.write('# Generated by AIF-NG.\n')
|
||||||
f.write(('.include /usr/lib/systemd/system/netctl@.service\n\n[Unit]\n' +
|
f.write(('.include /usr/lib/systemd/system/netctl@.service\n\n[Unit]\n' +
|
||||||
'Description=A basic {0} ethernet connection\n' +
|
'Description=A basic {0} ethernet connection\n' +
|
||||||
@ -747,13 +744,14 @@ class archInstall(object):
|
|||||||
chrootpath = self.system['chrootpath']
|
chrootpath = self.system['chrootpath']
|
||||||
bttarget = self.system['bootloader']['target']
|
bttarget = self.system['bootloader']['target']
|
||||||
if btldr == 'grub':
|
if btldr == 'grub':
|
||||||
|
bootcmds.append(['pacman', '--needed', '--noconfirm', '-S', 'grub', 'efibootmgr'])
|
||||||
bootcmds.append(['grub-install'])
|
bootcmds.append(['grub-install'])
|
||||||
if self.system['bootloader']['efi']:
|
if self.system['bootloader']['efi']:
|
||||||
bootcmds[0].extend(['--target=x86_64-efi', '--efi-directory={0}'.format(bttarget), '--bootloader-id="Arch Linux"'])
|
bootcmds[1].extend(['--target=x86_64-efi', '--efi-directory={0}'.format(bttarget), '--bootloader-id=Arch'])
|
||||||
else:
|
else:
|
||||||
bootcmds[0].extend(['--target=i386-pc', bttarget])
|
bootcmds[1].extend(['--target=i386-pc', bttarget])
|
||||||
bootcmds.append(['grub-mkconfig', '-o', '/{0}/grub/grub.cfg'.format(chrootpath, bttarget)])
|
bootcmds.append(['grub-mkconfig', '-o', '{0}/grub/grub.cfg'.format(bttarget)])
|
||||||
if btldr == 'systemd':
|
elif btldr == 'systemd':
|
||||||
if self.system['bootloader']['target'] != '/boot':
|
if self.system['bootloader']['target'] != '/boot':
|
||||||
shutil.copy2('{0}/boot/vmlinuz-linux'.format(chrootpath),
|
shutil.copy2('{0}/boot/vmlinuz-linux'.format(chrootpath),
|
||||||
'{0}/{1}/vmlinuz-linux'.format(chrootpath, bttarget))
|
'{0}/{1}/vmlinuz-linux'.format(chrootpath, bttarget))
|
||||||
@ -787,10 +785,7 @@ class archInstall(object):
|
|||||||
t = scripttype
|
t = scripttype
|
||||||
if t in self.scripts.keys():
|
if t in self.scripts.keys():
|
||||||
for i, s in enumerate(self.scripts[t]):
|
for i, s in enumerate(self.scripts[t]):
|
||||||
if t == 'post':
|
dirpath = '/root/scripts/{0}'.format(t)
|
||||||
dirpath = '{0}/scripts/{1}'.format(self.system['chrootpath'], t)
|
|
||||||
else:
|
|
||||||
dirpath = '/root/scripts/{0}'.format(t)
|
|
||||||
os.makedirs(dirpath, exist_ok = True)
|
os.makedirs(dirpath, exist_ok = True)
|
||||||
filepath = '{0}/{1}'.format(dirpath, i)
|
filepath = '{0}/{1}'.format(dirpath, i)
|
||||||
with open(filepath, 'w') as f:
|
with open(filepath, 'w') as f:
|
||||||
@ -807,15 +802,44 @@ class archInstall(object):
|
|||||||
return()
|
return()
|
||||||
|
|
||||||
def packagecmds(self):
|
def packagecmds(self):
|
||||||
pass
|
pkgcmds = []
|
||||||
|
# This should be run in the chroot, unless we find a way to pacstrap
|
||||||
|
# packages separate from chrooting
|
||||||
|
if self.software['command']:
|
||||||
|
pkgr = self.software['command']
|
||||||
|
else:
|
||||||
|
pkgr = 'pacman'
|
||||||
|
pkgropts = ['--needed', '--noconfirm']
|
||||||
|
if pkgr == 'apacman':
|
||||||
|
pkgropts.extend(['--noedit', '--skipinteg'])
|
||||||
|
if self.software['mirrors']:
|
||||||
|
# TODO: file vs. server?
|
||||||
|
with open('/etc/pacman.d/mirrorlist', 'w') as f:
|
||||||
|
for m in self.software['mirrors']:
|
||||||
|
f.write('Server = {0}\n'.format(m))
|
||||||
|
if self.software['packages']:
|
||||||
|
for p in self.software['packages'].keys():
|
||||||
|
if self.software['packages'][p]['repo']:
|
||||||
|
pkgname = '{0}/{1}'.format(self.software['packages'][p]['repo'],
|
||||||
|
self.software['packages'][p])
|
||||||
|
else:
|
||||||
|
pkgname = p
|
||||||
|
cmd = [pkgr]
|
||||||
|
for o in pkgropts:
|
||||||
|
cmd.append(o)
|
||||||
|
cmd.extend(['-S', pkgname])
|
||||||
|
pkgcmds.append(cmd)
|
||||||
|
return(pkgcmds)
|
||||||
|
|
||||||
def chroot(self, chrootcmds = False, bootcmds = False, scriptcmds = False):
|
def chroot(self, chrootcmds = False, bootcmds = False, scriptcmds = False, pkgcmds = False):
|
||||||
if not chrootcmds:
|
if not chrootcmds:
|
||||||
chrootcmds = self.setup()
|
chrootcmds = self.setup()
|
||||||
if not bootcmds:
|
if not bootcmds:
|
||||||
bootcmds = self.bootloader()
|
bootcmds = self.bootloader()
|
||||||
if not scriptcmds:
|
if not scriptcmds:
|
||||||
scriptcmds = self.scripts
|
scripts = self.scripts
|
||||||
|
if not pkgcmds:
|
||||||
|
pkgcmds = self.packagecmds()
|
||||||
# We don't need this currently, but we might down the road.
|
# We don't need this currently, but we might down the road.
|
||||||
#chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n'
|
#chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n'
|
||||||
#with open('{0}/root/aif.sh'.format(self.system['chrootpath']), 'w') as f:
|
#with open('{0}/root/aif.sh'.format(self.system['chrootpath']), 'w') as f:
|
||||||
@ -827,32 +851,37 @@ class archInstall(object):
|
|||||||
with open(logfile, 'a') as log:
|
with open(logfile, 'a') as log:
|
||||||
for c in chrootcmds:
|
for c in chrootcmds:
|
||||||
subprocess.call(c, stdout = log, stderr = subprocess.STDOUT)
|
subprocess.call(c, stdout = log, stderr = subprocess.STDOUT)
|
||||||
|
for p in pkgcmds:
|
||||||
|
subprocess.call(p, stdout = log, stderr = subprocess.STDOUT)
|
||||||
for b in bootcmds:
|
for b in bootcmds:
|
||||||
subprocess.call(b, stdout = log, stderr = subprocess.STDOUT)
|
subprocess.call(b, stdout = log, stderr = subprocess.STDOUT)
|
||||||
if scriptcmds['post']:
|
if scripts['post']:
|
||||||
for i, s in enumerate(scriptcmds['post']):
|
self.scriptcmds('post')
|
||||||
|
for i, s in enumerate(scripts['post']):
|
||||||
subprocess.call('/root/scripts/post/{0}'.format(i),
|
subprocess.call('/root/scripts/post/{0}'.format(i),
|
||||||
stdout = log,
|
stdout = log,
|
||||||
stderr = subproces.STDOUT)
|
stderr = subprocess.STDOUT)
|
||||||
#os.system('{0}/root/aif-pre.sh'.format(self.system['chrootpath']))
|
#os.system('{0}/root/aif-pre.sh'.format(self.system['chrootpath']))
|
||||||
#os.system('{0}/root/aif-post.sh'.format(self.system['chrootpath']))
|
#os.system('{0}/root/aif-post.sh'.format(self.system['chrootpath']))
|
||||||
os.fchdir(real_root)
|
os.fchdir(real_root)
|
||||||
os.chroot('.')
|
os.chroot('.')
|
||||||
os.close(real_root)
|
os.close(real_root)
|
||||||
if not os.path.isfile('{0}/sbin/init'.format(chrootdir)):
|
if not os.path.isfile('{0}/sbin/init'.format(self.system['chrootpath'])):
|
||||||
os.symlink('../lib/systemd/systemd', '{0}/sbin/init'.format(chrootdir))
|
os.symlink('../lib/systemd/systemd', '{0}/sbin/init'.format(self.system['chrootpath']))
|
||||||
|
return()
|
||||||
|
|
||||||
def unmount(self):
|
def unmount(self):
|
||||||
with open(logfile, 'a') as log:
|
with open(logfile, 'a') as log:
|
||||||
subprocess.call(['unmount', '-lR', self.system['chrootpath']], stdout = log, stderr = subprocess.STDOUT)
|
subprocess.call(['umount', '-lR', self.system['chrootpath']], stdout = log, stderr = subprocess.STDOUT)
|
||||||
|
return()
|
||||||
|
|
||||||
def runInstall(confdict):
|
def runInstall(confdict):
|
||||||
install = archInstall(confdict)
|
install = archInstall(confdict)
|
||||||
install.scriptcmds('pre')
|
install.scriptcmds('pre')
|
||||||
install.format()
|
install.format()
|
||||||
install.chroot()
|
install.chroot()
|
||||||
install.scriptcmds('post')
|
|
||||||
install.unmount()
|
install.unmount()
|
||||||
|
return()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user