2015-01-28 21:05:18 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
gen_pw(){
|
2015-02-13 15:17:00 +01:00
|
|
|
echo $(perl -e 'print crypt($ARGV[0], "password")' ${password})
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: chroot
|
|
|
|
configure_user(){
|
2015-02-13 15:17:00 +01:00
|
|
|
# set up user and password
|
|
|
|
msg2 "Creating user: ${username} password: ${password} ..."
|
|
|
|
chroot $1 useradd -m -g users -G ${addgroups} -p $(gen_pw) ${username}
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: chroot
|
|
|
|
configure_hostname(){
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Setting hostname: ${hostname} ..."
|
|
|
|
if [[ ${initsys} == 'openrc' ]];then
|
|
|
|
local _hostname='hostname="'${hostname}'"'
|
|
|
|
sed -i -e "s|^.*hostname=.*|${_hostname}|" $1/etc/conf.d/hostname
|
|
|
|
else
|
|
|
|
echo ${hostname} > $1/etc/hostname
|
|
|
|
fi
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 00:40:44 +01:00
|
|
|
# $1: chroot
|
|
|
|
configure_hosts(){
|
|
|
|
sed -e "s|localhost.localdomain|localhost.localdomain ${hostname}|" -i $1/etc/hosts
|
|
|
|
}
|
|
|
|
|
2015-01-28 21:05:18 +01:00
|
|
|
# $1: chroot
|
|
|
|
configure_plymouth(){
|
2015-06-22 14:47:06 +02:00
|
|
|
if ${plymouth_boot};then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Setting plymouth $plymouth_theme ...."
|
|
|
|
sed -i -e "s/^.*Theme=.*/Theme=$plymouth_theme/" $1/etc/plymouth/plymouthd.conf
|
|
|
|
fi
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
configure_services_live(){
|
2015-03-04 18:09:27 +01:00
|
|
|
case ${initsys} in
|
|
|
|
'openrc')
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Configuring [${initsys}] ...."
|
2015-03-04 18:09:27 +01:00
|
|
|
for svc in ${start_openrc_live[@]}; do
|
|
|
|
msg2 "Setting $svc ..."
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 rc-update add $svc default &> /dev/null
|
2015-03-04 18:09:27 +01:00
|
|
|
done
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Done configuring [${initsys}]"
|
2015-03-04 18:09:27 +01:00
|
|
|
;;
|
|
|
|
'systemd')
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Configuring [${initsys}] ...."
|
2015-03-04 18:09:27 +01:00
|
|
|
for svc in ${start_systemd_live[@]}; do
|
|
|
|
msg2 "Setting $svc ..."
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 systemctl enable $svc &> /dev/null
|
2015-03-04 18:09:27 +01:00
|
|
|
done
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Done configuring [${initsys}]"
|
2015-03-04 18:09:27 +01:00
|
|
|
;;
|
|
|
|
*)
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Unsupported: [${initsys}]!"
|
2015-03-04 18:09:27 +01:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-11 15:02:54 +01:00
|
|
|
# $1: chroot
|
2015-02-19 16:57:08 +01:00
|
|
|
configure_lsb(){
|
|
|
|
[[ -f $1/boot/grub/grub.cfg ]] && rm $1/boot/grub/grub.cfg
|
|
|
|
if [ -e $1/etc/lsb-release ] ; then
|
2015-06-17 00:19:42 +02:00
|
|
|
msg2 "Configuring lsb-release"
|
2015-03-05 10:54:09 +01:00
|
|
|
sed -i -e "s/^.*DISTRIB_RELEASE.*/DISTRIB_RELEASE=${dist_release}/" $1/etc/lsb-release
|
|
|
|
sed -i -e "s/^.*DISTRIB_CODENAME.*/DISTRIB_CODENAME=${dist_codename}/" $1/etc/lsb-release
|
2015-02-19 16:57:08 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-03-04 10:41:32 +01:00
|
|
|
# configure_dbus(){
|
|
|
|
# msg2 "Configuring dbus ...."
|
|
|
|
# # set unique machine-id
|
|
|
|
# # dbus-uuidgen --ensure=/etc/machine-id
|
|
|
|
# # ln -sf /etc/machine-id /var/lib/dbus/machine-id
|
|
|
|
# chroot $1 dbus-uuidgen --ensure=/var/lib/dbus/machine-id
|
|
|
|
# }
|
2015-02-19 16:57:08 +01:00
|
|
|
|
2015-01-28 21:05:18 +01:00
|
|
|
configure_services(){
|
2015-03-04 18:09:27 +01:00
|
|
|
case ${initsys} in
|
|
|
|
'openrc')
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Congiguring [${initsys}] ...."
|
2015-03-04 18:09:27 +01:00
|
|
|
for svc in ${start_openrc[@]}; do
|
|
|
|
msg2 "Setting $svc ..."
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 rc-update add $svc default &> /dev/null
|
2015-03-04 18:09:27 +01:00
|
|
|
done
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Done configuring [${initsys}]"
|
2015-03-04 18:09:27 +01:00
|
|
|
;;
|
|
|
|
'systemd')
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Congiguring [${initsys}] ...."
|
2015-03-04 18:09:27 +01:00
|
|
|
for svc in ${start_systemd[@]}; do
|
|
|
|
msg2 "Setting $svc ..."
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 systemctl enable $svc &> /dev/null
|
2015-03-04 18:09:27 +01:00
|
|
|
done
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Done configuring [${initsys}]"
|
2015-03-04 18:09:27 +01:00
|
|
|
;;
|
|
|
|
*)
|
2015-03-05 16:06:08 +01:00
|
|
|
msg3 "Unsupported: [${initsys}]!"
|
2015-03-04 18:09:27 +01:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-11 15:02:54 +01:00
|
|
|
# $1: chroot
|
|
|
|
configure_environment(){
|
|
|
|
case ${custom} in
|
2015-06-28 10:27:02 +02:00
|
|
|
cinnamon|enlightenment|gnome|i3|lxde|mate|netbook|openbox|pantheon|xfce|xfce-minimal|xfce-openrc)
|
2015-03-11 15:02:54 +01:00
|
|
|
echo "QT_STYLE_OVERRIDE=gtk" >> $1/etc/environment
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2015-01-28 21:05:18 +01:00
|
|
|
# $1: chroot
|
|
|
|
# $2: user
|
|
|
|
configure_accountsservice(){
|
2015-02-13 22:37:20 +01:00
|
|
|
msg2 "Configuring AccountsService ..."
|
2015-02-13 15:17:00 +01:00
|
|
|
local path=$1/var/lib/AccountsService/users
|
|
|
|
if [ -d "${path}" ] ; then
|
|
|
|
echo "[User]" > ${path}/$2
|
2015-05-31 01:26:28 +02:00
|
|
|
echo "XSession=${default_desktop_file}" >> ${path}/$2
|
2015-02-13 15:17:00 +01:00
|
|
|
echo "Icon=/var/lib/AccountsService/icons/$2.png" >> ${path}/$2
|
2015-01-28 21:05:18 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-10 02:46:14 +02:00
|
|
|
detect_desktop_env(){
|
2015-05-31 01:26:28 +02:00
|
|
|
if [[ "${default_desktop_executable}" == "none" ]] || [[ ${default_desktop_file} == "none" ]]; then
|
|
|
|
msg2 "No default desktop environment set, trying to detect it."
|
|
|
|
if [ -e "$1/usr/bin/startkde" ] && [ -e "$1/usr/share/xsessions/plasma.desktop" ]; then
|
|
|
|
default_desktop_executable="startkde"
|
|
|
|
default_desktop_file="plasma"
|
|
|
|
msg2 "Detected Plasma 5 desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/startkde" ] && [ -e "$1/usr/share/xsessions/kde-plasma.desktop" ]; then
|
|
|
|
default_desktop_executable="startkde"
|
|
|
|
default_desktop_file="kde-plasma"
|
|
|
|
msg2 "Detected KDE Plasma 4 desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/gnome-session" ] && [ -e "$1/usr/share/xsessions/gnome.desktop" ]; then
|
|
|
|
default_desktop_executable="gnome-session"
|
|
|
|
default_desktop_file="gnome"
|
|
|
|
msg2 "Detected Gnome desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/startxfce4" ] && [ -e "$1/usr/share/xsessions/xfce.desktop" ]; then
|
|
|
|
default_desktop_executable="startxfce4"
|
|
|
|
default_desktop_file="xfce"
|
|
|
|
msg2 "Detected Xfce desktop environment"
|
2015-06-18 06:56:54 +02:00
|
|
|
elif [ -e "$1/usr/bin/cinnamon-session-cinnamon" ] && [ -e "$1/usr/share/xsessions/cinnamon.desktop" ]; then
|
|
|
|
default_desktop_executable="cinnamon-session-cinnamon"
|
2015-06-18 08:56:30 +02:00
|
|
|
default_desktop_file="cinnamon"
|
2015-05-31 01:26:28 +02:00
|
|
|
msg2 "Detected Cinnamon desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/mate-session" ] && [ -e "$1/usr/share/xsessions/mate.desktop" ]; then
|
|
|
|
default_desktop_executable="mate-session"
|
|
|
|
default_desktop_file="mate"
|
|
|
|
msg2 "Detected Mate desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/enlightenment_start" ] && [ -e "$1/usr/share/xsessions/enlightenment.desktop" ]; then
|
|
|
|
default_desktop_executable="enlightenment_start"
|
|
|
|
default_desktop_file="enlightenment"
|
|
|
|
msg2 "Detected Enlightenment desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/lxsession" ] && [ -e "$1/usr/share/xsessions/LXDE.desktop" ]; then
|
|
|
|
default_desktop_executable="lxsession"
|
|
|
|
default_desktop_file="LXDE"
|
|
|
|
msg2 "Detected LXDE desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/startlxde" ] && [ -e "$1/usr/share/xsessions/LXDE.desktop" ]; then
|
|
|
|
default_desktop_executable="startlxde"
|
|
|
|
default_desktop_file="LXDE"
|
|
|
|
msg2 "Detected LXDE desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/lxqt-session" ] && [ -e "$1/usr/share/xsessions/lxqt.desktop" ]; then
|
|
|
|
default_desktop_executable="lxqt-session"
|
|
|
|
default_desktop_file="lxqt"
|
|
|
|
msg2 "Detected LXQt desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/pekwm" ] && [ -e "$1/usr/share/xsessions/pekwm.desktop" ]; then
|
|
|
|
default_desktop_executable="pekwm"
|
|
|
|
default_desktop_file="pekwm"
|
|
|
|
msg2 "Detected PekWM desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/pantheon-session" ] && [ -e "$1/usr/share/xsessions/pantheon.desktop" ]; then
|
|
|
|
default_desktop_executable="pantheon-session"
|
|
|
|
default_desktop_file="pantheon"
|
|
|
|
msg2 "Detected Pantheon desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/budgie-session" ] && [ -e "$1/usr/share/xsessions/budgie-session.desktop" ]; then
|
|
|
|
default_desktop_executable="budgie-session"
|
|
|
|
default_desktop_file="budgie-session"
|
|
|
|
msg2 "Detected Budgie desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/i3" ] && [ -e "$1/usr/share/xsessions/i3.desktop" ]; then
|
|
|
|
default_desktop_executable="i3"
|
|
|
|
default_desktop_file="i3"
|
|
|
|
msg2 "Detected i3 desktop environment"
|
|
|
|
elif [ -e "$1/usr/bin/openbox-session" ] && [ -e "$1/usr/share/xsessions/openbox.desktop" ]; then
|
|
|
|
default_desktop_executable="openbox-session"
|
|
|
|
default_desktop_file="openbox"
|
|
|
|
msg2 "Detected Openbox desktop environment"
|
|
|
|
else
|
|
|
|
default_desktop_executable="none"
|
|
|
|
default_desktop_file="none"
|
|
|
|
msg2 "No desktop environment detected"
|
|
|
|
fi
|
|
|
|
fi
|
2015-06-10 02:46:14 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:56:04 +02:00
|
|
|
configure_mhwd(){
|
|
|
|
if [[ ${arch} == "x86_64" ]];then
|
2015-06-10 17:15:37 +02:00
|
|
|
if ! ${multilib};then
|
2015-06-17 00:19:42 +02:00
|
|
|
msg2 "Disable mhwd lib32 support"
|
2015-06-10 17:15:37 +02:00
|
|
|
echo 'MHWD64_IS_LIB32="false"' > $1/etc/mhwd-x86_64.conf
|
|
|
|
fi
|
2015-06-10 16:56:04 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-10 02:46:14 +02:00
|
|
|
# $1: chroot
|
|
|
|
configure_displaymanager(){
|
|
|
|
msg2 "Configuring Displaymanager ..."
|
|
|
|
# Try to detect desktop environment
|
|
|
|
detect_desktop_env "$1"
|
2015-05-31 01:26:28 +02:00
|
|
|
# Configure display manager
|
2015-02-13 15:17:00 +01:00
|
|
|
case ${displaymanager} in
|
|
|
|
'lightdm')
|
|
|
|
chroot $1 groupadd -r autologin
|
|
|
|
local conf=$1/etc/lightdm/lightdm.conf
|
2015-05-31 01:26:28 +02:00
|
|
|
if [[ ${default_desktop_executable} != "none" ]] && [[ ${default_desktop_file} != "none" ]]; then
|
|
|
|
sed -i -e "s/^.*user-session=.*/user-session=$default_desktop_file/" ${conf}
|
2015-04-17 15:13:55 +02:00
|
|
|
fi
|
2015-02-13 15:17:00 +01:00
|
|
|
if [[ ${initsys} == 'openrc' ]];then
|
|
|
|
sed -i -e 's/^.*minimum-vt=.*/minimum-vt=7/' ${conf}
|
2015-06-16 22:50:16 +02:00
|
|
|
sed -i -e 's/pam_systemd.so/pam_ck_connector.so nox11/' $1/etc/pam.d/lightdm-greeter
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
|
|
|
local greeters=$(ls $1/etc/lightdm/*greeter.conf)
|
|
|
|
for g in ${greeters[@]};do
|
|
|
|
case ${g##*/} in
|
|
|
|
'lxqt-lightdm-greeter.conf')
|
|
|
|
sed -i -e "s/^.*greeter-session=.*/greeter-session=lxqt-lightdm-greeter/" ${conf}
|
|
|
|
;;
|
|
|
|
'lightdm-kde-greeter.conf')
|
|
|
|
sed -i -e "s/^.*greeter-session=.*/greeter-session=lightdm-kde-greeter/" ${conf}
|
|
|
|
;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
'gdm')
|
|
|
|
configure_accountsservice $1 "gdm"
|
|
|
|
;;
|
|
|
|
'mdm')
|
|
|
|
local conf=$1/etc/mdm/custom.conf
|
2015-05-31 01:26:28 +02:00
|
|
|
if [[ ${default_desktop_executable} != "none" ]] && [[ ${default_desktop_file} != "none" ]]; then
|
|
|
|
sed -i "s|default.desktop|$default_desktop_file.desktop|g" ${conf}
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'sddm')
|
|
|
|
local conf=$1/etc/sddm.conf
|
2015-05-31 01:26:28 +02:00
|
|
|
if [[ ${default_desktop_executable} != "none" ]] && [[ ${default_desktop_file} != "none" ]]; then
|
|
|
|
sed -i -e "s|^Session=.*|Session=$default_desktop_file.desktop|" ${conf}
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'lxdm')
|
|
|
|
local conf=$1/etc/lxdm/lxdm.conf
|
2015-05-31 01:26:28 +02:00
|
|
|
if [[ ${default_desktop_executable} != "none" ]] && [[ ${default_desktop_file} != "none" ]]; then
|
|
|
|
sed -i -e "s|^.*session=.*|session=/usr/bin/$default_desktop_executable|" ${conf}
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
2015-03-03 19:39:03 +01:00
|
|
|
if [[ ${displaymanager} != "none" ]];then
|
|
|
|
if [[ ${initsys} == 'openrc' ]];then
|
|
|
|
local conf='DISPLAYMANAGER="'${displaymanager}'"'
|
|
|
|
sed -i -e "s|^.*DISPLAYMANAGER=.*|${conf}|" $1/etc/conf.d/xdm
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 rc-update add xdm default &> /dev/null
|
2015-03-03 19:39:03 +01:00
|
|
|
else
|
|
|
|
local service=${displaymanager}
|
|
|
|
if [[ -f $1/etc/plymouth/plymouthd.conf && \
|
|
|
|
-f $1/usr/lib/systemd/system/${displaymanager}-plymouth.service ]]; then
|
|
|
|
service=${displaymanager}-plymouth
|
|
|
|
fi
|
2015-05-22 13:09:28 +02:00
|
|
|
chroot $1 systemctl enable ${service} &> /dev/null
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2015-01-28 21:05:18 +01:00
|
|
|
fi
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Configured: ${displaymanager}"
|
2015-01-28 21:05:18 +01:00
|
|
|
}
|
2015-01-29 00:17:15 +01:00
|
|
|
|
2015-03-11 15:02:54 +01:00
|
|
|
# $1: chroot
|
2015-07-04 10:54:56 +02:00
|
|
|
configure_mhwd_drivers(){
|
2015-01-29 00:17:15 +01:00
|
|
|
# Disable Catalyst if not present
|
|
|
|
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep catalyst-utils 2> /dev/null)" ]; then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Disabling Catalyst driver"
|
|
|
|
mkdir -p $1/var/lib/mhwd/db/pci/graphic_drivers/catalyst/
|
|
|
|
touch $1/var/lib/mhwd/db/pci/graphic_drivers/catalyst/MHWDCONFIG
|
2015-01-29 00:17:15 +01:00
|
|
|
fi
|
|
|
|
# Disable Nvidia if not present
|
|
|
|
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep nvidia-utils 2> /dev/null)" ]; then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Disabling Nvidia driver"
|
|
|
|
mkdir -p $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia/
|
|
|
|
touch $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia/MHWDCONFIG
|
2015-01-29 00:17:15 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep nvidia-utils 2> /dev/null)" ]; then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Disabling Nvidia Bumblebee driver"
|
|
|
|
mkdir -p $1/var/lib/mhwd/db/pci/graphic_drivers/hybrid-intel-nvidia-bumblebee/
|
|
|
|
touch $1/var/lib/mhwd/db/pci/graphic_drivers/hybrid-intel-nvidia-bumblebee/MHWDCONFIG
|
2015-01-29 00:17:15 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep nvidia-304xx-utils 2> /dev/null)" ]; then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Disabling Nvidia 304xx driver"
|
|
|
|
mkdir -p $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia-304xx/
|
|
|
|
touch $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia-304xx/MHWDCONFIG
|
2015-01-29 00:17:15 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep nvidia-340xx-utils 2> /dev/null)" ]; then
|
2015-02-13 15:17:00 +01:00
|
|
|
msg2 "Disabling Nvidia 340xx driver"
|
|
|
|
mkdir -p $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia-340xx/
|
|
|
|
touch $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia-340xx/MHWDCONFIG
|
2015-01-29 00:17:15 +01:00
|
|
|
fi
|
|
|
|
}
|
2015-05-21 19:54:29 +02:00
|
|
|
|
2015-06-04 15:20:04 +02:00
|
|
|
chroot_clean(){
|
2015-05-21 19:54:29 +02:00
|
|
|
msg "Cleaning up ..."
|
|
|
|
for image in "$1"/*-image; do
|
|
|
|
[[ -d ${image} ]] || continue
|
2015-07-04 20:30:52 +02:00
|
|
|
if [[ $(basename "${image}") != "mhwd-image" ]];then
|
2015-05-21 19:54:29 +02:00
|
|
|
msg2 "Deleting chroot '$(basename "${image}")'..."
|
|
|
|
lock 9 "${image}.lock" "Locking chroot '${image}'"
|
|
|
|
if [[ "$(stat -f -c %T "${image}")" == btrfs ]]; then
|
2015-05-22 13:09:28 +02:00
|
|
|
{ type -P btrfs && btrfs subvolume delete "${image}"; } &> /dev/null
|
2015-05-21 19:54:29 +02:00
|
|
|
fi
|
|
|
|
rm -rf --one-file-system "${image}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exec 9>&-
|
|
|
|
rm -rf --one-file-system "$1"
|
|
|
|
}
|
|
|
|
|
2015-06-17 00:19:42 +02:00
|
|
|
configure_sysctl(){
|
2015-06-17 00:22:26 +02:00
|
|
|
if [[ ${initsys} == 'openrc' ]];then
|
2015-06-17 00:19:42 +02:00
|
|
|
msg2 "Configuring sysctl for openrc"
|
|
|
|
touch $1/etc/sysctl.conf
|
|
|
|
local conf=$1/etc/sysctl.d/100-manjaro.conf
|
|
|
|
echo '# Virtual memory setting (swap file or partition)' > ${conf}
|
|
|
|
echo 'vm.swappiness = 30' >> ${conf}
|
|
|
|
echo '# Enable the SysRq key' >> ${conf}
|
|
|
|
echo 'kernel.sysrq = 1' >> ${conf}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-25 02:25:05 +02:00
|
|
|
# Remove pamac auto-update when the network is up, it causes problems when booting in the livecd
|
|
|
|
# $1: chroot
|
|
|
|
configure_pamac_live() {
|
|
|
|
rm -f $1/etc/NetworkManager/dispatcher.d/99_update_pamac_tray
|
|
|
|
}
|
|
|
|
|
2015-06-17 00:19:42 +02:00
|
|
|
configure_root_image(){
|
|
|
|
msg "Configuring [root-image]"
|
|
|
|
configure_lsb "$1"
|
|
|
|
configure_mhwd "$1"
|
|
|
|
configure_sysctl "$1"
|
|
|
|
msg "Done configuring [root-image]"
|
|
|
|
}
|
|
|
|
|
2015-05-21 19:54:29 +02:00
|
|
|
configure_custom_image(){
|
|
|
|
msg "Configuring [${custom}-image]"
|
|
|
|
configure_plymouth "$1"
|
|
|
|
configure_displaymanager "$1"
|
|
|
|
configure_services "$1"
|
|
|
|
configure_environment "$1"
|
|
|
|
msg "Done configuring [${custom}-image]"
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_livecd_image(){
|
|
|
|
msg "Configuring [livecd-image]"
|
|
|
|
configure_hostname "$1"
|
|
|
|
configure_hosts "$1"
|
|
|
|
configure_accountsservice "$1" "${username}"
|
|
|
|
configure_user "$1"
|
|
|
|
configure_services_live "$1"
|
|
|
|
configure_calamares "$1"
|
|
|
|
configure_thus "$1"
|
2015-06-25 02:25:05 +02:00
|
|
|
configure_pamac_live "$1"
|
2015-05-21 19:54:29 +02:00
|
|
|
msg "Done configuring [livecd-image]"
|
|
|
|
}
|
|
|
|
|
|
|
|
make_repo(){
|
2015-07-04 20:30:52 +02:00
|
|
|
repo-add ${work_dir}/mhwd-image/opt/livecd/pkgs/gfx-pkgs.db.tar.gz ${work_dir}/mhwd-image/opt/livecd/pkgs/*pkg*z
|
2015-05-21 19:54:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: work dir
|
2015-06-08 21:21:46 +02:00
|
|
|
# $2: pkglist
|
2015-05-21 19:54:29 +02:00
|
|
|
download_to_cache(){
|
2015-06-08 21:21:46 +02:00
|
|
|
chroot-run \
|
|
|
|
-r "${mountargs_ro}" \
|
|
|
|
-w "${mountargs_rw}" \
|
|
|
|
-B "${build_mirror}/${branch}" \
|
|
|
|
"$1" \
|
2015-07-03 23:28:13 +02:00
|
|
|
pacman -v -Syw $2 --noconfirm || return 1
|
2015-06-08 21:21:46 +02:00
|
|
|
chroot-run \
|
|
|
|
-r "${mountargs_ro}" \
|
|
|
|
-w "${mountargs_rw}" \
|
|
|
|
-B "${build_mirror}/${branch}" \
|
|
|
|
"$1" \
|
2015-06-08 21:35:18 +02:00
|
|
|
pacman -v -Sp $2 --noconfirm > "$1"/cache-packages.txt
|
2015-06-08 21:21:46 +02:00
|
|
|
sed -ni '/.pkg.tar.xz/p' "$1"/cache-packages.txt
|
|
|
|
sed -i "s/.*\///" "$1"/cache-packages.txt
|
2015-05-21 19:54:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: image path
|
|
|
|
# $2: packages
|
2015-06-04 15:20:04 +02:00
|
|
|
chroot_create(){
|
2015-05-21 19:54:29 +02:00
|
|
|
[[ "$1" == "${work_dir}/root-image" ]] && local flag="-L"
|
|
|
|
setarch "${arch}" \
|
2015-06-29 04:08:45 +02:00
|
|
|
mkchroot ${mkchroot_args[*]} ${flag} $@
|
2015-05-21 19:54:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: image path
|
|
|
|
clean_up_image(){
|
2015-05-22 15:03:10 +02:00
|
|
|
msg2 "Cleaning up [${1##*/}]"
|
2015-05-22 13:09:28 +02:00
|
|
|
[[ -d "$1/boot/" ]] && find "$1/boot" -name 'initramfs*.img' -delete &> /dev/null
|
2015-05-21 19:54:29 +02:00
|
|
|
[[ -f "$1/etc/locale.gen.bak" ]] && mv "$1/etc/locale.gen.bak" "$1/etc/locale.gen"
|
|
|
|
[[ -f "$1/etc/locale.conf.bak" ]] && mv "$1/etc/locale.conf.bak" "$1/etc/locale.conf"
|
|
|
|
|
2015-05-22 13:09:28 +02:00
|
|
|
find "$1/var/lib/pacman" -maxdepth 1 -type f -delete &> /dev/null
|
|
|
|
find "$1/var/lib/pacman/sync" -type f -delete &> /dev/null
|
|
|
|
find "$1/var/cache/pacman/pkg" -type f -delete &> /dev/null
|
|
|
|
find "$1/var/log" -type f -delete &> /dev/null
|
|
|
|
find "$1/var/tmp" -mindepth 1 -delete &> /dev/null
|
|
|
|
find "$1/tmp" -mindepth 1 -delete &> /dev/null
|
2015-05-21 19:54:29 +02:00
|
|
|
|
|
|
|
# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
|
|
|
|
}
|