175 lines
6.1 KiB
Bash
Executable File
175 lines
6.1 KiB
Bash
Executable File
#!/bin/bash
|
||
#set -e
|
||
|
||
# 获取当前脚本的绝对路径所在的目录
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||
# 定义同目录下的 mkarchiso 可执行文件的路径
|
||
MKARCHISO_PATH="$SCRIPT_DIR/mkarchiso"
|
||
|
||
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"
|
||
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
|
||
echo
|
||
echo "Making mkarchiso verbose"
|
||
# 注意:这里修改的是系统安装的 mkarchiso 脚本,如果你希望修改的是同目录下的 mkarchiso,则需要调整路径
|
||
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" # 加上双引号以防路径中含空格
|
||
|
||
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 -p "$outFolder" # 加上双引号并使用 -p
|
||
cd "$buildFolder/archiso/" # 加上双引号
|
||
# 使用 $MKARCHISO_PATH 确保调用的是同目录下的 mkarchiso
|
||
sudo "$MKARCHISO_PATH" -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
|