181 lines
5.9 KiB
Bash
Executable File
181 lines
5.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#set -e
|
|
|
|
# 获取脚本所在的目录
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
# 假设 archiso.md 和 archiso 目录在脚本目录的上一级
|
|
PROJECT_ROOT="$( dirname "$SCRIPT_DIR" )"
|
|
|
|
# 导出这些变量,以便脚本后续使用
|
|
export SCRIPT_DIR
|
|
export PROJECT_ROOT
|
|
|
|
|
|
if lsblk -f | grep btrfs > /dev/null 2>&1 ; then
|
|
echo
|
|
echo "################################################################## "
|
|
tput setaf 3
|
|
echo "Message"
|
|
echo "This script has been known to cause issues on a Btrfs filesystem"
|
|
echo "Make backups before continuing"
|
|
echo "Continu at your own risk"
|
|
tput sgr0
|
|
echo
|
|
read -p "Press Enter to continue... CTRL + C to stop"
|
|
fi
|
|
|
|
echo
|
|
echo "################################################################## "
|
|
tput setaf 2
|
|
echo "Phase 1 : "
|
|
echo "- Setting General parameters"
|
|
tput sgr0
|
|
echo "################################################################## "
|
|
echo
|
|
|
|
# setting of the general parameters
|
|
archisoRequiredVersion="archiso 83-1"
|
|
buildFolder=$HOME"/bbttms-build"
|
|
# outFolder=$HOME"/Bbttms-Iso-Out"
|
|
outFolder="/media/cinema/Bbttms-Iso-Out"
|
|
archisoVersion=$(sudo pacman -Q archiso)
|
|
|
|
echo "################################################################## "
|
|
#echo "Building the desktop : "$desktop
|
|
#echo "Building version : "$arcolinuxVersion
|
|
#echo "Iso label : "$isoLabel
|
|
echo "Do you have the right archiso version? : "$archisoVersion
|
|
echo "What is the required archiso version? : "$archisoRequiredVersion
|
|
echo "Build folder : "$buildFolder
|
|
echo "Out folder : "$outFolder
|
|
echo "################################################################## "
|
|
|
|
if [ "$archisoVersion" == "$archisoRequiredVersion" ]; then
|
|
tput setaf 2
|
|
echo "##################################################################"
|
|
echo "Archiso has the correct version. Continuing ..."
|
|
echo "##################################################################"
|
|
tput sgr0
|
|
else
|
|
tput setaf 1
|
|
echo "###################################################################################################"
|
|
echo "You need to install the correct version of Archiso"
|
|
echo "Use 'sudo downgrade archiso' to do that"
|
|
echo "or update your system"
|
|
echo "If a new archiso package comes in and you want to test if you can still build"
|
|
echo "the iso then change the version in line 37."
|
|
echo "###################################################################################################"
|
|
tput sgr0
|
|
fi
|
|
|
|
echo
|
|
echo "################################################################## "
|
|
tput setaf 2
|
|
echo "Phase 2 :"
|
|
echo "- Checking if archiso is installed"
|
|
echo "- Saving current archiso version to archiso.md"
|
|
echo "- Making mkarchiso verbose"
|
|
tput sgr0
|
|
echo "################################################################## "
|
|
echo
|
|
|
|
package="archiso"
|
|
|
|
#----------------------------------------------------------------------------------
|
|
|
|
#checking if application is already installed or else install with aur helpers
|
|
if pacman -Qi $package &> /dev/null; then
|
|
|
|
echo "Archiso is already installed"
|
|
|
|
else
|
|
|
|
#checking which helper is installed
|
|
if pacman -Qi yay &> /dev/null; then
|
|
|
|
echo "################################################################"
|
|
echo "######### Installing with yay"
|
|
echo "################################################################"
|
|
yay -S --noconfirm $package
|
|
|
|
elif pacman -Qi trizen &> /dev/null; then
|
|
|
|
echo "################################################################"
|
|
echo "######### Installing with trizen"
|
|
echo "################################################################"
|
|
trizen -S --noconfirm --needed --noedit $package
|
|
|
|
fi
|
|
|
|
# Just checking if installation was successful
|
|
if pacman -Qi $package &> /dev/null; then
|
|
|
|
echo "################################################################"
|
|
echo "######### "$package" has been installed"
|
|
echo "################################################################"
|
|
|
|
else
|
|
|
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
echo "!!!!!!!!! "$package" has NOT been installed"
|
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
exit 1
|
|
fi
|
|
|
|
fi
|
|
|
|
echo
|
|
echo "Saving current archiso version to archiso.md"
|
|
#sudo sed -i "s/\(^archiso-version=\).*/\1$archisoVersion/" ../archiso.md
|
|
sudo sed -i "s/\(^archiso-version=\).*/\1$archisoVersion/" "$PROJECT_ROOT/archiso.md"
|
|
echo
|
|
echo "Making mkarchiso verbose"
|
|
sudo sed -i 's/quiet="y"/quiet="n"/g' /usr/bin/mkarchiso
|
|
|
|
echo
|
|
echo "################################################################## "
|
|
tput setaf 2
|
|
echo "Phase 3 :"
|
|
echo "- Deleting the build folder if one exists"
|
|
echo "- Copying the Archiso folder to build folder"
|
|
tput sgr0
|
|
echo "################################################################## "
|
|
echo
|
|
|
|
echo "Deleting the build folder if one exists - takes some time"
|
|
[ -d $buildFolder ] && sudo rm -rf $buildFolder
|
|
echo
|
|
echo "Copying the Archiso folder to build work"
|
|
echo
|
|
mkdir $buildFolder
|
|
#cp -r ../archiso $buildFolder/archiso
|
|
cp -r "$PROJECT_ROOT/archiso" "$buildFolder/archiso"
|
|
|
|
|
|
echo
|
|
echo "################################################################## "
|
|
tput setaf 2
|
|
echo "Phase 7 :"
|
|
echo "- Building the iso - this can take a while - be patient"
|
|
tput sgr0
|
|
echo "################################################################## "
|
|
echo
|
|
|
|
[ -d $outFolder ] || mkdir $outFolder
|
|
cd $buildFolder/archiso/
|
|
sudo mkarchiso -v -w $buildFolder -o $outFolder $buildFolder/archiso/
|
|
|
|
echo "Moving pkglist.x86_64.txt"
|
|
echo "########################"
|
|
rename=$(date +%Y-%m-%d)
|
|
cp $buildFolder/iso/BBTTMS/pkglist.x86_64.txt $outFolder/BBTTMS-$rename-pkglist.txt
|
|
|
|
echo
|
|
echo "##################################################################"
|
|
tput setaf 2
|
|
echo "DONE"
|
|
echo "- Check your out folder :"$outFolder
|
|
tput sgr0
|
|
echo "################################################################## "
|
|
echo
|