Add packages argument to argparse
This commit is contained in:
parent
eb2eef08e5
commit
9423959ea1
1 changed files with 21 additions and 8 deletions
29
akshara
29
akshara
|
@ -208,6 +208,10 @@ def update_system():
|
||||||
|
|
||||||
|
|
||||||
def handle_system_packages(install):
|
def handle_system_packages(install):
|
||||||
|
if len(args.pkgs) == 0:
|
||||||
|
error('no packages specified')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
if is_running():
|
if is_running():
|
||||||
error('already running')
|
error('already running')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -222,10 +226,14 @@ def handle_system_packages(install):
|
||||||
for old_overlay in os.listdir('/mnt'):
|
for old_overlay in os.listdir('/mnt'):
|
||||||
if old_overlay.startswith('.blend-tmp-overlay-'):
|
if old_overlay.startswith('.blend-tmp-overlay-'):
|
||||||
exec('rm', '-rf', f'/mnt/{old_overlay}')
|
exec('rm', '-rf', f'/mnt/{old_overlay}')
|
||||||
usr_overlay = subprocess.run(['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
usr_overlay = subprocess.run(
|
||||||
usr_overlay_workdir = subprocess.run(['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
||||||
varlibpacman_overlay = subprocess.run(['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
usr_overlay_workdir = subprocess.run(
|
||||||
varlibpacman_overlay_workdir = subprocess.run(['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
||||||
|
varlibpacman_overlay = subprocess.run(
|
||||||
|
['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
||||||
|
varlibpacman_overlay_workdir = subprocess.run(
|
||||||
|
['mktemp', '-d', '/mnt/.blend-tmp-overlay-XXXXXXXXXXXXX'], stdout=subprocess.PIPE).stdout.decode().strip()
|
||||||
if '' in (usr_overlay, usr_overlay_workdir, varlibpacman_overlay, varlibpacman_overlay_workdir):
|
if '' in (usr_overlay, usr_overlay_workdir, varlibpacman_overlay, varlibpacman_overlay_workdir):
|
||||||
for old_overlay in os.listdir('/mnt'):
|
for old_overlay in os.listdir('/mnt'):
|
||||||
if old_overlay.startswith('.blend-tmp-overlay-'):
|
if old_overlay.startswith('.blend-tmp-overlay-'):
|
||||||
|
@ -233,9 +241,12 @@ def handle_system_packages(install):
|
||||||
error('error during overlay creation')
|
error('error during overlay creation')
|
||||||
exit(1)
|
exit(1)
|
||||||
exec('mkdir', '-p', '/.blendrw')
|
exec('mkdir', '-p', '/.blendrw')
|
||||||
exec('mount', subprocess.run(['findmnt', '-n', '-o', 'SOURCE', '/'], stdout=subprocess.PIPE).stdout.decode().strip(), '/.blendrw')
|
exec('mount', subprocess.run(['findmnt', '-n', '-o', 'SOURCE', '/'],
|
||||||
exec('mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/usr,upperdir={usr_overlay},workdir={usr_overlay_workdir}', '/.blendrw/usr')
|
stdout=subprocess.PIPE).stdout.decode().strip(), '/.blendrw')
|
||||||
exec('mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/var/lib/pacman,upperdir={varlibpacman_overlay},workdir={varlibpacman_overlay_workdir}', '/.blendrw/var/lib/pacman')
|
exec('mount', '-t', 'overlay', 'overlay', '-o',
|
||||||
|
f'lowerdir=/usr,upperdir={usr_overlay},workdir={usr_overlay_workdir}', '/.blendrw/usr')
|
||||||
|
exec('mount', '-t', 'overlay', 'overlay', '-o',
|
||||||
|
f'lowerdir=/var/lib/pacman,upperdir={varlibpacman_overlay},workdir={varlibpacman_overlay_workdir}', '/.blendrw/var/lib/pacman')
|
||||||
|
|
||||||
if install == 'install':
|
if install == 'install':
|
||||||
operation = ['-Sy']
|
operation = ['-Sy']
|
||||||
|
@ -325,6 +336,8 @@ command_map = {'help': 'help',
|
||||||
'daemon': daemon}
|
'daemon': daemon}
|
||||||
parser.add_argument('command', choices=command_map.keys(),
|
parser.add_argument('command', choices=command_map.keys(),
|
||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
|
parser.add_argument('pkg', action='store', type=str,
|
||||||
|
nargs='*', help=argparse.SUPPRESS)
|
||||||
parser.add_argument('-y', '--noconfirm',
|
parser.add_argument('-y', '--noconfirm',
|
||||||
action='store_true', help=argparse.SUPPRESS)
|
action='store_true', help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--headless',
|
parser.add_argument('--headless',
|
||||||
|
@ -354,4 +367,4 @@ try:
|
||||||
else:
|
else:
|
||||||
command()
|
command()
|
||||||
except:
|
except:
|
||||||
error('aborting')
|
error('aborting')
|
||||||
|
|
Loading…
Reference in a new issue