Kaydet (Commit) 71e7b2b2 authored tarafından Ali Rıza KESKİN's avatar Ali Rıza KESKİN

rewrite sulinstrapt. Now not required inary installation

üst 16ef8eb7
#!/bin/bash #!/bin/bash
#sulinstrapt betiği ile sulinos chroot oluşturabilirsiniz veya diskinize kurulum yapabilirsiniz set -e
if [[ "$1" == "" || "$1" == "-*" ]] umask 022
then curdir=$(pwd)
packages=(baselayout bash bzip2 ca-certificates \
coreutils cracklib curl expat gdbm \
gettext glib2 glibc gmp libcap libffi \
libgcc libgomp libidn2 libpcre libssh2 \
libunistring libxml2 ncurses openssl \
pam python3 python3-psutil sed busybox \
python3-pycurl readline run-parts libpsl \
sqlite timezone unzip xz zlib acl attr)
repo="https://osdn.net/frs/redir.php?m=dotsrc&f=storage/g/s/su/sulinos/SulinRepository/inary-index.xml.xz"
help_msg(){
echo "Usage: sulinstrapt [options] destdir"
echo " -r : repository url"
echo " -b : install boot packages"
echo " -x : install x11 packages"
echo " -d : install devel packages"
echo " -n : install network packages"
echo " -a : install additional packages"
exit $1
}
get_path(){
name=$1
grep "${name:0:0}\/$name/$name-[0-9][0-9.]*[a-f,-\.]" "$sulin/tmp/repo" | sed "s/.*<PackageURI>//g" | sed "s/<\/.*//g" | sort -V | head -n 1
}
clean_tmp(){
rm -rf "$sulin"/tmp/install.tar.*
rm -rf "$sulin"/tmp/*.xml
rm -rf "$sulin"/tmp/*.py
rm -rf "$sulin"/tmp/scom
}
if [[ "$1" == "" || "$1" == "-*" ]] ; then
echo "Usage: sulinstrapt [directory]" echo "Usage: sulinstrapt [directory]"
exit 0 exit 0
fi elif [[ $UID -ne 0 ]] ; then
sulin="$1"
if [[ $UID -ne 0 ]]
then
echo "You must be root!" echo "You must be root!"
exit 1 exit 1
fi fi
if [[ -d "$sulin" ]] if [[ -d "$sulin" ]] ; then
then
echo "$sulin already exist" echo "$sulin already exist"
fi exit 1
if [[ -f "$sulin" ]] elif [[ -f "$sulin" ]] ; then
then
echo "$sulin is a file. You must delete or move." echo "$sulin is a file. You must delete or move."
exit 1 exit 1
fi fi
inary ar sulin "https://osdn.net/frs/redir.php?m=dotsrc&f=storage/g/s/su/sulinos/SulinRepository/inary-index.xml.xz" -y -D$sulin || true
inary ur -y -D$sulin || true while getopts -- ':r' OPTION; do
inary it baselayout --ignore-dep --ignore-safety --ignore-configure -y -D$sulin if [[ "$OPTION" == "r" ]] ; then
inary it -c system.base curl -y --ignore-configure -D$sulin repo="${OPTARG[@]}"
if echo "$2" | grep "^-" &>/dev/null ; then fi
echo $2 | grep "b" && inary it -c system.boot toybox btrfs-progs linux linux-firmware -y --ignore-configure -D$sulin done
echo $2 | grep "x" && inary it -c x11 -y --ignore-configure -D$sulin sulin=$(realpath "$1")
echo $2 | grep "d" && inary it -c system.devel -y --ignore-configure -D$sulin mkdir -p "$sulin/tmp"
echo $2 | grep "n" && inary it NetworkManager -y --ignore-configure -D$sulin if [[ ! -f "$sulin/tmp/repo" ]] ; then
echo $2 | grep "a" && inary it nano wget vim strace ntfsprogs tree dialog pfork scom htop -y --ignore-configure -D$sulin wget -c "$repo" -O "$sulin/tmp/repo"
if LANG=C file "$sulin/tmp/repo" | grep "XZ" &>/dev/null ; then
mv "$sulin/tmp/repo" "$sulin/tmp/repo.xz"
xz -d "$sulin/tmp/repo.xz"
fi
fi fi
for i in /dev /sys /proc /run i=0
do total=${#packages[@]}
mkdir -p $sulin/$i &>/dev/null cd $sulin/
umount -lf -R $sulin/$i || true for pkg in ${packages[@]} ; do
mount --bind $i $sulin/$i URI=$(dirname "$repo")/$(get_path $pkg)
echo -e "\033[32;1m[$i/$total] Install: \033[0m$pkg"
if [[ ! -f "$sulin/tmp/$pkg.zip" ]] ; then
wget -c "$URI" -O "$sulin/tmp/$pkg.zip"
cd tmp ; unzip -o $sulin/tmp/$pkg.zip >/dev/null ; cd ..
tar --overwrite -xf tmp/install.tar.*
clean_tmp
fi
i=$(($i+1))
done done
echo -e "\033[32;1m[$i/$total] Install: \033[0minary-develop"
if [[ ! -f "$sulin/tmp/inary-develop.zip" ]] ; then
wget https://gitlab.com/sulinos/devel/inary/-/archive/develop/inary-develop.zip -O "$sulin/tmp/inary-develop.zip"
cd tmp ; unzip -o $sulin/tmp/inary-develop.zip >/dev/null
mkdir -p "$sulin/usr/lib/sulin/inary"
cp -prf inary-develop/inary/* "$sulin/usr/lib/sulin/inary"
cp -pf inary-develop/inary-cli "$sulin/usr/bin/inary-cli"
ln -s inary-cli "$sulin/usr/bin/inary"
rm -rf inary-develop
clean_tmp
fi
for i in $(chroot "$sulin" busybox --list)
do
if chroot "$sulin" busybox which $i &>/dev/null ; then
true
else
chroot "$sulin" ln -s $(chroot "$sulin" busybox which busybox) /usr/bin/$i
fi
done
for dir in dev sys proc run ; do
[[ -d "$sulin/$dir" ]] || mkdir -p "$sulin/$dir"
while umount -f "$sulin/dev" 2>/dev/null ; do true; done
mount --bind /run "$sulin/$dir"
done
cat /etc/resolv.conf > "$sulin/etc/resolv.conf"
chroot "$sulin" update-ca-certificates --fresh >/dev/null
chroot "$sulin" inary ar sulin "$repo" || true
chroot "$sulin" inary ur sulin -y
chroot "$sulin" inary it baselayout --ignore-dep --ignore-safety -y --ignore-configure
chroot "$sulin" inary it -c system.base -y --ignore-configure
chroot $sulin inary cp busybox chroot $sulin inary cp busybox
chroot $sulin inary cp baselayout chroot $sulin inary cp baselayout
chroot $sulin inary cp chroot $sulin inary cp
if echo "$2" | grep "^-" &>/dev/null ; then
echo $2 | grep "b" && chroot "$sulin" inary it -c system.boot toybox btrfs-progs linux linux-firmware -y --ignore-configure
echo $2 | grep "x" && chroot "$sulin" inary it -c x11 -y --ignore-configure
echo $2 | grep "d" && chroot "$sulin" inary it -c system.devel -y --ignore-configure
echo $2 | grep "n" && chroot "$sulin" inary it NetworkManager -y --ignore-configure
echo $2 | grep "a" && chroot "$sulin" inary it nano wget vim strace ntfsprogs tree dialog pfork scom htop -y --ignore-configure
fi
rm -rf "$sulin"/tmp*
for dir in dev sys proc run ; do
while umount -f "$sulin/$dir" 2>/dev/null ; do true; done
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment