#!/bin/sh
#240120 sfs
#d=",040-de-ovs-u22-sf*.pfs"
[ "$1" = q ] && d=",../optional/030-qt5-*.pfs$d" && shift
[ "$1" = d ] && d=",../optional/DEVX-*.pfs$d" && shift
[ "$1" ] && d="$d,$1" 
p="`ls pkg-*.pfs`" ; [ "$p" ] && d="$d,$p"
[ -d a ] && a=",a"
#chroot2pfs --mlist 001-u22-sf*.pfs,025-mesa-22.2.5-u22-sf*.pfs$d,089-upd-u22-sf*.pfs,pkg-*,../pkg-list --command bash ||
#chroot2pfs --mlist 001-u22-sf*.pfs$d,089-upd-u22-sf*.pfs,pkg-*,../pkg-list --command bash ||

#chroot2pfs --mlist 001-*-sf*.pfs$d,089-upd-*-sf*.pfs,../pkg-list$a,ice*.pfs,lx*.pfs --command bash ||
#a=",010.pfs"
#a=",010.pfs,030-gtk3.pfs"
#a=",030-*.pfs,010-*.pfs"
#a=",010-*.pfs"
#chroot2pfs --mlist 001-*.pfs$a$d,089-upd-*-sf*.pfs,../pkg-list --command bash ||
#    pfs delaufs $(basename `ls /mnt/aufs*.lock |tail -1` .lock |sed 's/[a-z]//g')

echo "\
#!/bin/sh -vx
#apt-get update
#bash -c 'TERM=xterm LANG=ru_RU.UTF-8 mc'
#bash -c 'TERM=xterm-256color LANG=ru_RU.UTF-8 mc'
bash
#sleep 5
" >tmp.sh
#chroot2pfs -o 090-save.pfs --mlist $1 --script tmp.sh && rm tmp.sh
#chroot2pfs --mlist 001-*-sf*.pfs$d,089-upd-*-sf*.pfs,../pkg-list --script tmp.sh && rm tmp.sh || pfs delaufs $(basename `ls /mnt/aufs*.lock |tail -1` .lock |sed 's/[a-z]//g')
#defaultterminal -e "chroot2pfs --mlist 001-*-sf*.pfs$a$d,089-upd-*-sf*.pfs,../pkg-list --script tmp.sh  || pfs delaufs $(basename `ls /mnt/aufs*.lock |tail -1` .lock |sed 's/[a-z]//g')"
chroot2pfs --mlist 001-*-sf*.pfs$a$d,089-upd-*-sf*.pfs,../pkg-list --script tmp.sh  
rm tmp.sh
