From dc7e66b46601c34d70945701f929135736ec1392 Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 31 Mar 2022 00:12:31 +0100 Subject: added install system script --- notes.txt | 118 --------------------------------------------------- scripts/install.sh | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 118 deletions(-) delete mode 100644 notes.txt create mode 100755 scripts/install.sh diff --git a/notes.txt b/notes.txt deleted file mode 100644 index db9a03e..0000000 --- a/notes.txt +++ /dev/null @@ -1,118 +0,0 @@ -/etc/xipkg.conf - for xipkg config - -in config define repo sources like this: - : - -eg: - davidovski: https://xi.davidovski.xyz/repo/ - - -then specify repos that should be loaded: - repos: core extra other - -/var/lib/xipkg - to contain all working files: - -/var/lib/xipkg/packages - "working dir" to keep xipkg files and xipkg.info - will look something like this: - packages/ - core/ - extra/ - - -/var/lib/xipkg/keychain -place to store publickeys for sources. - -/var/lib/xipkg/installed/ - /info - info about the package that has been installed to the system - /files - text file with all the files that it installed to the sysetm (for later removal purposes) - - -sync -------- - -go to each source and list packages in a repo -find the most popular package hashes - - -download all keys - -install -------- - -if a xipkg file is specified and there is a corresponding .info as well, it will install it directly -if its a url, then download the xipkg file and its .info - -if its a package name: - check if it exists, - if that package name exists in multiple repos, then prompt to ask which repo to take from - -to check a package is already installed, search for its name in /var/lib/xipkg/installed - -to install package need to: - - find the package in a place in /var/lib/xipkg/packages - - find all dependencies and subdependecies in a tree, and repeat install for any that are missing - - - aquire .xipkg from correct source (look for the xipkg.info.source) - - - verify that the hash of xipkg is right - - - check against every publickey in /var/lib/xipkg/keychain (maybe better ideas?) - - - untar the xipkg - - list all package's files in xipkg into /var/lib/xipkg/installed//files - - copy the pkginfo to /var/lib/xipkg/installed/ - ( do not use a symlink since later syncs can make the information inacurate) - - copy all the files into their place on the system - (actually install the package) - - - make an install reciept that contains: - * the source that the package was downloaded from - * the key that was used to validate the package - * the date the package was installed - * the user that installed the package - * if the package was installed as a dependency - * other info? - - - ?? run some post install scripts?? - - ?? clean up?? - -remove ------- - -find the package's installed files in /var/lib/xipkg/installed//files and remove them from the system -(? maybe check if other packages need them, and dont remove then?) - -remove all the info from /var/lib/xipkg/installed/ - -(? check ) - -upgrade -------- -do a sync -if a package is specified, only upgrade that one package - -packages need updates when the hash listed in the package sync is different to the installed - -create a dependency tree and try upgrade core packages first (shouldnt matter really, since upgrading shouldnt have any dependencies other than xipkg and its subdependencies) - -to upgrade a package find that package in the repo and compare its pkginfo with the installed's package info - -if the VERSION_HASH is different then upgrade (guessing newer) -if the CHECKSUM is different AND the date is newer then upgrade (a different checksum with an older date could be a mistake) - -(cant rely only on version hash, because the way that the package was built can be changed) - - -force-upgrade ------------- -(! needs a better name) - -just removes the package and then installs it again - -file ------- -searches for a file to install -(!!! REQUIRES SOME KIND OF FILE DATABASE) diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..f13495a --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,122 @@ +#!/bin/sh + +default_packages="base linux xipkg dracut grub" +additional_packages="sudo neofetch vim networkmanager" +default_key="davidovski https://xi.davidovski.xyz/keychain/xi.pub" + +XIPKG="/usr/bin/xi" +XIFLAGS="-yl" +TMPDIR=/tmp +SYSROOT=$1 + +[ ! -e $XIPKG ] && { + git clone https://xi.davidovski.xyz/git/xiutils.git $TMPDIR/xiutils + make && make install + + git clone https://xi.davidovski.xyz/git/xipkg.git $TMPDIR/xipkg + make && make install +} + +echo "Please make sure that you have correctly formatted any partitions and mounted them as desired under $SYSROOT" + +[ $# -eq 0 ] && echo "Please specify where you would like to instal the system" && exit 1 + +[ -e $SYSROOT ] && { + printf "Remove existing system at $SYSROOT? [Y/n] " + read response + [ "$response" != "n" ] && rm -rf $SYSROOT && echo "removed $SYSROOT" +} + +$XIPKG $XIFLAGS sync +$XIPKG $XIFLAGS -r $SYSROOT bootstrap $default_packages +$XIPKG $XIFLAGS -r $SYSROOT keyimport $default_key + +configuring_users () { + echo "Setting root password: " + xichroot $SYSROOT passwd + + echo + echo "Creating user" + read -p "Enter username: " username + xichroot $SYSROOT useradd -m $username + xichroot $SYSROOT passwd $username +} + +configuring_system () { + read -p "Enter system hostname: " hostname + + echo $hostname > $SYSROOT/etc/hostname + + cat > $SYSROOT/etc/hosts << EOF +127.0.0.1 localhost +::1 localhost +127.0.1.1 $hostname.local $hostname +EOF +} + +configuring_nameservers () { + echo "Configuring nameservers..." + + cat > $SYSROOT/etc/resolv.conf << EOF +nameserver 80.80.80.80 +EOF +} + +generating_fstab () { + echo "Generating fstab..." + xichroot $SYSCONFIG genfstab -U / > $SYSROOT/etc/fstab +} + +building_initramfs () { + echo "Building initramfs..." + kernel_version=$(ls $SYSROOT/usr/lib/modules | tail -1) + xichroot $SYSROOT dracut --kver $kernel_version 2>/dev/null > $TMPDIR/dracut.log +} + +installing_bootloader () { + read -p "Install Grub? [y]" r + [ "$r" != "n" ] && { + opts="--target=x86_64-efi" + + read -p "Enter efi partition: " efi_part + opts="$opts --efi-partition=$efi_part" + + read -p "Removable system? [y]" r + [ "$r" != "n" ] && { + opts="$opts --removable" + } + + xichroot $SYSROOT grub-install $opts + xichroot $SYSROOT grub-mkconfig -o /boot/grub/grub.cfg + } +} + +downloading_additional_packages () { + echo "Syncing repos..." + xichroot $SYSROOT xi sync + echo "Downloading additional packages..." + xichroot $SYSROOT xi $XIFLAGS install $additional_packages +} + +steps=" +generating_fstab +building_initramfs +configuring_system +installing_bootloader +configuring_users +configuring_nameservers +downloading_additional_packages +" + +len=$(echo "$steps" | wc -l) +i=0 + + +for step in $steps; do + i=$((i+1)) + clear + hbar -t -T "$(echo $step | sed "s/_/ /g")" $i $len + $step +done + +echo "Installation finished!" -- cgit v1.2.1