Commit 8efaed63 authored by Bernhard Landauer's avatar Bernhard Landauer
Browse files

[util-base.sh] code formatting

parent 39b7b93f
......@@ -12,76 +12,76 @@
setup_profiles() {
# setup profiles with either git
PROFILES="$DATADIR/profiles"
clear
# install git if not already installed
inst_needed git
# download manjaro-tools.-isoprofiles git repo
if [[ -e $PROFILES ]]; then
#git -C $PROFILES pull 2>$ERR
profile-validate -r 2>$ERR
check_for_error "pull profiles repo" $?
else
profile-validate -r 2>$ERR
#git clone -b manjaro-architect --depth 1 https://gitlab.manjaro.org/profiles-and-settings/iso-profiles.git $PROFILES 2>$ERR
check_for_error "clone profiles repo" $?
fi
PROFILES="$DATADIR/profiles"
clear
# install git if not already installed
inst_needed git
# download manjaro-tools.-isoprofiles git repo
if [[ -e $PROFILES ]]; then
#git -C $PROFILES pull 2>$ERR
profile-validate -r 2>$ERR
check_for_error "pull profiles repo" $?
else
profile-validate -r 2>$ERR
#git clone -b manjaro-architect --depth 1 https://gitlab.manjaro.org/profiles-and-settings/iso-profiles.git $PROFILES 2>$ERR
check_for_error "clone profiles repo" $?
fi
}
enable_services() {
# Enable services in the chosen profile
echo "Enabling services"
eval $(grep -e "enable_systemd=" $profile | sed 's/# //g')
echo "${^enable_systemd[@]}" | xargs -n1 > /tmp/.services
echo /mnt/usr/lib/systemd/system/* | xargs -n1 | cut -d/ -f7 | sed 's/.service//g' > /tmp/.available_services
grep -f /tmp/.available_services /tmp/.services > /tmp/.fix && mv /tmp/.fix /tmp/.services
arch_chroot "systemctl enable $(cat /tmp/.services)" 2>$ERR
for service in $(cat /tmp/.services); do
if [[ -e /mnt/usr/lib/systemd/system/$service ]]; then
arch_chroot "systemctl enable $service" 2>$ERR && echo "enabled service $service"
fi
done
check_for_error "enable $(cat /tmp/.services | tr '\n' ' ')" $?
arch_chroot "systemctl disable pacman-init" 2>$ERR
check_for_error "disable pacman-init" $?
# enable display manager for systemd
if [[ "$(cat /tmp/.display-manager)" == lightdm ]]; then
if arch_chroot "pacman -Qq lightdm" > /dev/null; then
set_lightdm_greeter
arch_chroot "systemctl enable lightdm" 2>$ERR
check_for_error "enable lightdm" "$?"
else
echo "lightdm was listed but not actually installed. No display-manager was enabled"
fi
elif [[ "$(cat /tmp/.display-manager)" == sddm ]]; then
arch_chroot "systemctl enable sddm" 2>$ERR
check_for_error "enable sddm" "$?"
elif [[ "$(cat /tmp/.display-manager)" == gdm ]]; then
arch_chroot "systemctl enable gdm" 2>$ERR
check_for_error "enable gdm" "$?"
else
check_for_error "no DM installed."
echo "no display manager was installed"
sleep 2
fi
# Enable services in the chosen profile
echo "Enabling services"
eval $(grep -e "enable_systemd=" $profile | sed 's/# //g')
echo "${^enable_systemd[@]}" | xargs -n1 > /tmp/.services
echo /mnt/usr/lib/systemd/system/* | xargs -n1 | cut -d/ -f7 | sed 's/.service//g' > /tmp/.available_services
grep -f /tmp/.available_services /tmp/.services > /tmp/.fix && mv /tmp/.fix /tmp/.services
arch_chroot "systemctl enable $(cat /tmp/.services)" 2>$ERR
for service in $(cat /tmp/.services); do
if [[ -e /mnt/usr/lib/systemd/system/$service ]]; then
arch_chroot "systemctl enable $service" 2>$ERR && echo "enabled service $service"
fi
done
check_for_error "enable $(cat /tmp/.services | tr '\n' ' ')" $?
arch_chroot "systemctl disable pacman-init" 2>$ERR
check_for_error "disable pacman-init" $?
# enable display manager for systemd
if [[ "$(cat /tmp/.display-manager)" == lightdm ]]; then
if arch_chroot "pacman -Qq lightdm" > /dev/null; then
set_lightdm_greeter
arch_chroot "systemctl enable lightdm" 2>$ERR
check_for_error "enable lightdm" "$?"
else
echo "lightdm was listed but not actually installed. No display-manager was enabled"
fi
elif [[ "$(cat /tmp/.display-manager)" == sddm ]]; then
arch_chroot "systemctl enable sddm" 2>$ERR
check_for_error "enable sddm" "$?"
elif [[ "$(cat /tmp/.display-manager)" == gdm ]]; then
arch_chroot "systemctl enable gdm" 2>$ERR
check_for_error "enable gdm" "$?"
else
check_for_error "no DM installed."
echo "no display manager was installed"
sleep 2
fi
# if we are using a zfs we should enable the zfs services
if [ $ZFS == 1 ]; then
arch_chroot "systemctl enable zfs.target" 2>$ERR
check_for_error "enable zfs.target" "$?"
arch_chroot "systemctl enable zfs-import-cache" 2>$ERR
check_for_error "enable zfs-import-cache" "$?"
arch_chroot "systemctl enable zfs-mount" 2>$ERR
check_for_error "enable zfs-mount" "$?"
arch_chroot "systemctl enable zfs-import.target" 2>$ERR
check_for_error "enable zfs-import.target" "$?"
# we also need create the cachefile
zpool set cachefile=/etc/zfs/zpool.cache $(findmnt ${MOUNTPOINT} -lno SOURCE | awk -F / '{print $1}') 2>$ERR
check_for_error "create zpool cache" "$?"
cp /etc/zfs/zpool.cache ${MOUNTPOINT}/etc/zfs/zpool.cache 2>$ERR
check_for_error "copy cache file" "$?"
fi
# if we are using a zfs we should enable the zfs services
if [ $ZFS == 1 ]; then
arch_chroot "systemctl enable zfs.target" 2>$ERR
check_for_error "enable zfs.target" "$?"
arch_chroot "systemctl enable zfs-import-cache" 2>$ERR
check_for_error "enable zfs-import-cache" "$?"
arch_chroot "systemctl enable zfs-mount" 2>$ERR
check_for_error "enable zfs-mount" "$?"
arch_chroot "systemctl enable zfs-import.target" 2>$ERR
check_for_error "enable zfs-import.target" "$?"
# we also need create the cachefile
zpool set cachefile=/etc/zfs/zpool.cache $(findmnt ${MOUNTPOINT} -lno SOURCE | awk -F / '{print $1}') 2>$ERR
check_for_error "create zpool cache" "$?"
cp /etc/zfs/zpool.cache ${MOUNTPOINT}/etc/zfs/zpool.cache 2>$ERR
check_for_error "copy cache file" "$?"
fi
}
install_extra() {
......@@ -104,92 +104,92 @@ install_extra() {
}
filter_packages() {
DIALOG " $_PkgList " --infobox "\n$_PlsWaitBody\n " 0 0
# Parse package list based on user input and remove parts that don't belong to pacman
# If desktop is selected, add those packages to packages to be installed.
if [[ -e /mnt/.desktop ]]; then
cat "$pkgs_src" /mnt/.desktop >> $pkgs_target 2>$ERR
check_for_error "$FUNCNAME" $?
else
cat "$pkgs_src" >> $pkgs_target 2>$ERR
check_for_error "$FUNCNAME" $?
fi
# Remove any packages tagged with >openrc and remove >systemd tags
sed -i '/>openrc/d' $pkgs_target
sed -i 's/>systemd //g' $pkgs_target
if [[ "$(uname -m)" == "x86_64" ]]; then
# Remove any packages tagged with >i686 and remove >x86_64 tags
sed -i '/>i686/d' $pkgs_target
sed -i '/>nonfree_i686/d' $pkgs_target
sed -i 's/>x86_64 //g' $pkgs_target
else
# Remove any packages tagged with >x86_64 and remove >i686 tags
sed -i '/>x86_64/d' $pkgs_target
sed -i '/>nonfree_x86_64/d' $pkgs_target
sed -i 's/>i686 //g' $pkgs_target
fi
# If multilib repo is enabled, install multilib packages
if grep -q "^[multilib]" /etc/pacman.conf; then
# Remove >multilib tags
sed -i 's/>multilib //g' $pkgs_target
sed -i 's/>nonfree_multilib //g' $pkgs_target
else
# Remove lines with >multilib tag
sed -i '/>multilib/d' $pkgs_target
sed -i '/>nonfree_multilib/d' $pkgs_target
fi
DIALOG " $_PkgList " --infobox "\n$_PlsWaitBody\n " 0 0
# Parse package list based on user input and remove parts that don't belong to pacman
# If desktop is selected, add those packages to packages to be installed.
if [[ -e /mnt/.desktop ]]; then
cat "$pkgs_src" /mnt/.desktop >> $pkgs_target 2>$ERR
check_for_error "$FUNCNAME" $?
else
cat "$pkgs_src" >> $pkgs_target 2>$ERR
check_for_error "$FUNCNAME" $?
fi
# Remove any packages tagged with >openrc and remove >systemd tags
sed -i '/>openrc/d' $pkgs_target
sed -i 's/>systemd //g' $pkgs_target
if [[ "$(uname -m)" == "x86_64" ]]; then
# Remove any packages tagged with >i686 and remove >x86_64 tags
sed -i '/>i686/d' $pkgs_target
sed -i '/>nonfree_i686/d' $pkgs_target
sed -i 's/>x86_64 //g' $pkgs_target
else
# Remove any packages tagged with >x86_64 and remove >i686 tags
sed -i '/>x86_64/d' $pkgs_target
sed -i '/>nonfree_x86_64/d' $pkgs_target
sed -i 's/>i686 //g' $pkgs_target
fi
if grep -q ">extra" $pkgs_target; then
# User to select base|extra profile
DIALOG " $_ExtraTitle " --no-cancel --menu "\n$_ExtraBody\n " 0 0 2 \
"1" "full" \
"2" "minimal" 2>/tmp/.version
# If multilib repo is enabled, install multilib packages
if grep -q "^[multilib]" /etc/pacman.conf; then
# Remove >multilib tags
sed -i 's/>multilib //g' $pkgs_target
sed -i 's/>nonfree_multilib //g' $pkgs_target
else
# Remove lines with >multilib tag
sed -i '/>multilib/d' $pkgs_target
sed -i '/>nonfree_multilib/d' $pkgs_target
fi
if [[ $(cat /tmp/.version) -eq 2 ]]; then
check_for_error "selected 'minimal' profile"
touch /tmp/.minimal
else
check_for_error "selected 'full' profile"
[[ -e /tmp/.minimal ]] && rm /tmp/.minimal
fi
fi
if grep -q ">extra" $pkgs_target; then
# User to select base|extra profile
DIALOG " $_ExtraTitle " --no-cancel --menu "\n$_ExtraBody\n " 0 0 2 \
"1" "full" \
"2" "minimal" 2>/tmp/.version
if [[ -e /tmp/.minimal ]]; then
# Remove >extra tags
sed -i 's/>basic //g' $pkgs_target
sed -i '/>extra/d' $pkgs_target
if [[ $(cat /tmp/.version) -eq 2 ]]; then
check_for_error "selected 'minimal' profile"
touch /tmp/.minimal
else
# Remove >basic tags
sed -i 's/>extra //g' $pkgs_target
sed -i '/>basic/d' $pkgs_target
check_for_error "selected 'full' profile"
[[ -e /tmp/.minimal ]] && rm /tmp/.minimal
fi
# remove >manjaro flags and >sonar flags+pkgs until we support it properly
sed -i '/>sonar/d' $pkgs_target
sed -i 's/>manjaro //g' $pkgs_target
# Does the system have a battery?
if [[ -z "$(echo /sys/class/power_supply/BAT*)" ]]; then
# No battery was detected. Remove TLP
sed -i '/tlp/d' $pkgs_target
fi
# Remove commented lines
# remove everything except the first word of every lines
sed -i 's/\s.*$//' $pkgs_target
# Remove lines with #
sed -i '/#/d' $pkgs_target
# remove KERNEL variable
sed -i '/KERNEL/d' $pkgs_target
# Remove empty lines
sed -i '/^\s*$/d' $pkgs_target
# Remove packages that have been dropped from repos
pacman -Ssq > /tmp/.available_packages
pacman -Sgq >> /tmp/.available_packages
grep -f /tmp/.available_packages $pkgs_target > /tmp/.tmp
mv /tmp/.tmp $pkgs_target
fi
if [[ -e /tmp/.minimal ]]; then
# Remove >extra tags
sed -i 's/>basic //g' $pkgs_target
sed -i '/>extra/d' $pkgs_target
else
# Remove >basic tags
sed -i 's/>extra //g' $pkgs_target
sed -i '/>basic/d' $pkgs_target
fi
# remove >manjaro flags and >sonar flags+pkgs until we support it properly
sed -i '/>sonar/d' $pkgs_target
sed -i 's/>manjaro //g' $pkgs_target
# Does the system have a battery?
if [[ -z "$(echo /sys/class/power_supply/BAT*)" ]]; then
# No battery was detected. Remove TLP
sed -i '/tlp/d' $pkgs_target
fi
# Remove commented lines
# remove everything except the first word of every lines
sed -i 's/\s.*$//' $pkgs_target
# Remove lines with #
sed -i '/#/d' $pkgs_target
# remove KERNEL variable
sed -i '/KERNEL/d' $pkgs_target
# Remove empty lines
sed -i '/^\s*$/d' $pkgs_target
# Remove packages that have been dropped from repos
pacman -Ssq > /tmp/.available_packages
pacman -Sgq >> /tmp/.available_packages
grep -f /tmp/.available_packages $pkgs_target > /tmp/.tmp
mv /tmp/.tmp $pkgs_target
}
install_base() {
......@@ -567,8 +567,7 @@ pacman -S --noconfirm grub-theme-manjaro" > ${MOUNTPOINT}/usr/bin/grub_installer
}
install_refind()
{
install_refind() {
DIALOG " $_InstUefiBtTitle " --yesno "\n$_InstRefindBody\n " 0 0 || return 0
clear
inst_needed refind-efi
......@@ -647,8 +646,7 @@ install_refind()
#Initramfs is on the root partition
sed -i "s|\"$| initrd=/boot/${UCODE}.img initrd=/boot/initramfs-%v.img\"|g" /mnt/boot/refind_linux.conf
fi
fi
fi
basestrap ${MOUNTPOINT} refind-theme-maia
DIALOG " $_InstUefiBtTitle " --infobox "\n$_RefindReady\n " 0 0
......@@ -953,7 +951,6 @@ set_locale() {
check_for_error "$FUNCNAME" "$?"
ini linux.locale "$LOCALE"
}
# Set Zone and Sub-Zone
......
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