prepare for overlay-image and new configs

This commit is contained in:
udeved 2014-12-14 03:48:14 +01:00
parent de424e48b5
commit e4c8ece0da
3 changed files with 456 additions and 370 deletions

View file

@ -41,6 +41,7 @@ LIBS = \
lib/util-mount.sh \
lib/util-msg.sh \
lib/util-pkg.sh \
lib/util-livecd.sh \
lib/util-iso.sh
CPIOHOOKS = \
@ -54,35 +55,35 @@ CPIOINST = \
inst/miso_pxe_nbd \
inst/miso_kms
LIVECD = \
livecd/disable-dpms \
livecd/km-tr.lng \
livecd/mhwd \
livecd/setup-0.8-tr.lng \
livecd/setup-tr.lng \
livecd/util-lng.sh \
livecd/ejectcd \
livecd/lg \
livecd/pulseaudio-ctl-normal \
livecd/setup-0.9 \
livecd/simple-welcome \
livecd/util-mount.sh \
livecd/kbd-model-map \
livecd/lg-en.lng \
livecd/setup \
livecd/setup-0.9-en.lng \
livecd/update-setup \
livecd/util.sh \
livecd/km \
livecd/lg-tr.lng \
livecd/setup-0.8 \
livecd/setup-0.9-tr.lng \
livecd/update-setup-files \
livecd/km-en.lng \
livecd/livecd \
livecd/setup-0.8-en.lng \
livecd/setup-en.lng \
livecd/util-inst.sh
# LIVECD = \
# livecd/disable-dpms \
# livecd/km-tr.lng \
# livecd/mhwd \
# livecd/setup-0.8-tr.lng \
# livecd/setup-tr.lng \
# livecd/util-lng.sh \
# livecd/ejectcd \
# livecd/lg \
# livecd/pulseaudio-ctl-normal \
# livecd/setup-0.9 \
# livecd/simple-welcome \
# livecd/util-mount.sh \
# livecd/kbd-model-map \
# livecd/lg-en.lng \
# livecd/setup \
# livecd/setup-0.9-en.lng \
# livecd/update-setup \
# livecd/util.sh \
# livecd/km \
# livecd/lg-tr.lng \
# livecd/setup-0.8 \
# livecd/setup-0.9-tr.lng \
# livecd/update-setup-files \
# livecd/km-en.lng \
# livecd/livecd \
# livecd/setup-0.8-en.lng \
# livecd/setup-en.lng \
# livecd/util-inst.sh
all: $(BINPROGS) #bin/bash_completion bin/zsh_completion
@ -99,7 +100,7 @@ edit = sed -e "s|@pkgdatadir[@]|$(DESTDIR)$(PREFIX)/share/manjaro-tools|g" \
@chmod +x "$@"
clean:
rm -f $(BINPROGS) bin/bash_completion bin/zsh_completion
rm -f $(BINPROGS) #bin/bash_completion bin/zsh_completion
install:
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools
@ -119,8 +120,8 @@ install:
install -dm0755 $(DESTDIR)$(PREFIX)/lib/initcpio/install
install -m0755 ${CPIOINST} $(DESTDIR)$(PREFIX)/lib/initcpio/install
install -dm0755 $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd
install -m0644 ${LIVECD} $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd
#install -dm0755 $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd
#install -m0644 ${LIVECD} $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd
#install -Dm0644 bin/bash_completion $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/manjaro_tools
#install -Dm0644 bin/zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_manjaro_tools
@ -141,7 +142,7 @@ uninstall:
for f in ${CPIOHOOKS}; do rm -f $(DESTDIR)$(PREFIX)/lib/initcpio/hooks/$$f; done
for f in ${CPIOINST}; do rm -f $(DESTDIR)$(PREFIX)/lib/initcpio/install/$$f; done
for f in ${LIVECD}; do rm -f $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd/$$f; done
#for f in ${LIVECD}; do rm -f $(DESTDIR)$(PREFIX)/share/manjaro-tools/livecd/$$f; done
#rm $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/manjaro_tools
#rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_manjaro_tools

View file

@ -15,38 +15,18 @@ copy_initcpio(){
cp mkinitcpio.conf ${work_dir}/boot-image/etc/mkinitcpio-${manjaroiso}.conf
}
# $1: source image
# $2: target image
copy_userconfig(){
msg2 "Copying $1/etc/skel/. $2/etc/skel"
cp -a $1/etc/skel/. $2/etc/skel
}
copy_manjaro_tools_conf(){
local livecd=$1
[[ ! -d ${livecd} ]] && mkdir ${livecd}
if [[ -f $USER_HOME/.config/manjaro-tools.conf ]]; then
msg2 "Copying $USER_HOME/.config/manjaro-tools.conf to ${livecd}/manjaro-tools.conf ..."
cp $USER_HOME/.config/manjaro-tools.conf ${livecd}/manjaro-tools.conf
else
msg2 "Copying ${manjaro_tools_conf} to ${livecd}/manjaro-tools.conf ..."
cp ${manjaro_tools_conf} ${livecd}/manjaro-tools.conf
fi
}
copy_livecd(){
msg2 "Copying $1 to ${work_dir}/overlay/opt ..."
[[ ! -d ${work_dir}/overlay/opt ]] && mkdir -p ${work_dir}/overlay/opt
cp -r $1 ${work_dir}/overlay/opt
msg2 "Fixing livecd script permissions ..."
chmod 755 ${work_dir}/overlay/opt/livecd/{livecd,mhwd,lg,km,ejectcd,disable-dpms,pulseaudio-ctl-normal,setup,setup-0.8,setup-0.9,update-setup}
chmod +x ${work_dir}/overlay/opt/livecd/{livecd,mhwd,lg,km,ejectcd,disable-dpms,pulseaudio-ctl-normal,setup,setup-0.8,setup-0.9,update-setup}
sed -i "s/^.*TITLE=.*/ TITLE=\"Manjaro Linux Installation Framework (v${iso_version})\"/g" ${work_dir}/overlay/opt/livecd/setup
}
# copy_livecd(){
#
# msg2 "Copying $1 to ${work_dir}/overlay/opt ..."
# [[ ! -d ${work_dir}/overlay/opt ]] && mkdir -p ${work_dir}/overlay/opt
# cp -r $1 ${work_dir}/overlay/opt
#
# msg2 "Fixing livecd script permissions ..."
# chmod 755 ${work_dir}/overlay/opt/livecd/{livecd,mhwd,lg,km,ejectcd,disable-dpms,pulseaudio-ctl-normal,setup,setup-0.8,setup-0.9,update-setup}
# chmod +x ${work_dir}/overlay/opt/livecd/{livecd,mhwd,lg,km,ejectcd,disable-dpms,pulseaudio-ctl-normal,setup,setup-0.8,setup-0.9,update-setup}
#
# sed -i "s/^.*TITLE=.*/ TITLE=\"Manjaro Linux Installation Framework (v${iso_version})\"/g" ${work_dir}/overlay/opt/livecd/setup
# }
copy_overlay(){
msg2 "Copying overlay to $1"
@ -58,303 +38,19 @@ copy_overlay_desktop(){
cp -a ${desktop}-overlay/* ${work_dir}/${desktop}-image
}
copy_livecd_init(){
if [[ -d overlay-livecd-openrc ]]; then
msg2 "Copying overlay-livecd-openrc/ to $1 ..."
cp -a overlay-livecd-openrc/* $1
fi
if [[ -d overlay-livecd-systemd ]]; then
msg2 "Copying overlay-livecd-systemd/ to $1 ..."
cp -a overlay-livecd-systemd/* $1
fi
}
copy_overlay_init(){
if [[ -d overlay-openrc ]]; then
msg2 "Copying overlay-openrc/ to $1 ..."
cp -a overlay-openrc/* $1
fi
if [[ -d overlay-systemd ]]; then
msg2 "Copying overlay-systemd/ to $1 ..."
cp -a overlay-systemd/* $1
fi
}
copy_overlay_livecd(){
msg2 "Copying overlay-livecd to $1 ..."
cp -a overlay-livecd/* $1
}
# $1: chroot
# configure_user(){
# # set up user and password
# local pass=$(gen_pw)
# msg2 "Creating user ${username} with password ${password} ..."
# chroot-run $1 useradd -m -g users -G ${addgroups} -p ${pass} ${username}
# }
# $1: chroot
configue_hostname(){
msg2 "Setting hostname ${hostname} ..."
if [[ -f $1/usr/bin/openrc ]];then
local _hostname='hostname="'${hostname}'"'
sed -i -e "s|^.*hostname=.*|${_hostname}|" $1/etc/conf.d/hostname
else
echo ${hostname} > $1/etc/hostname
fi
copy_config_loader(){
msg2 "Copying ${LIBDIR}/util.sh to $1/util-config.sh ..."
cp ${LIBDIR}/util.sh $1/util-config.sh
}
configure_plymouth(){
if [ -e $1/etc/plymouth/plymouthd.conf ] ; then
sed -i -e "s/^.*Theme=.*/Theme=$plymouth_theme/" $1/etc/plymouth/plymouthd.conf
fi
}
configure_services(){
if [[ -f ${work_dir}/root-image/usr/bin/openrc ]];then
msg2 "Congiguring OpenRC ...."
for svc in ${startservices_openrc[@]}; do
if [[ -f $1/etc/init.d/$svc ]]; then
msg2 "Setting $svc ..."
[[ ! -d $1/etc/runlevels/default ]] && mkdir -p $1/etc/runlevels/default
ln -sf /etc/init.d/$svc $1/etc/runlevels/default/$svc
fi
done
else
msg2 "Congiguring SystemD ...."
for svc in ${startservices_systemd[@]}; do
msg2 "Setting $svc ..."
if [[ -f $1/usr/lib/systemd/system/$svc ]];then
msg2 "Setting $svc ..."
chroot-run $1 systemctl enable $svc
fi
if [[ -f $1/etc/systemd/system/$svc ]];then
msg2 "Setting $svc ..."
chroot-run $1 systemctl enable $svc
fi
done
fi
}
# $1: chroot
configue_displaymanager(){
local _dm
msg2 "Configuring Displaymanager ..."
# do_setuplightdm
if [ -e "$1/usr/bin/lightdm" ] ; then
#mkdir -p /run/lightdm > /dev/null
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=xfce/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=cinnamon/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=mate/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=enlightenment/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=openbox/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=LXDE/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=lxqt/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/pekwm" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=pekwm/' $1/etc/lightdm/lightdm.conf
fi
sed -i -e "s/^.*autologin-user=.*/autologin-user=${username}/" $1/etc/lightdm/lightdm.conf
sed -i -e 's/^.*autologin-user-timeout=.*/autologin-user-timeout=0/' $1/etc/lightdm/lightdm.conf
# sed -i -e 's/^.*autologin-in-background=.*/autologin-in-background=true/' /etc/lightdm/lightdm.conf
chroot-run $1 groupadd autologin
chroot-run $1 gpasswd -a ${username} autologin &> /dev/null
chroot-run $1 chmod +r /etc/lightdm/lightdm.conf
# livecd fix
mkdir -p $1/var/lib/lightdm-data
if [[ -e /run/systemd ]]; then
chroot-run $1 systemd-tmpfiles --create /usr/lib/tmpfiles.d/lightdm.conf
chroot-run $1 systemd-tmpfiles --create --remove
fi
_dm='lightdm'
fi
# do_setupkdm
if [ -e "$1/usr/share/config/kdm/kdmrc" ] ; then
chroot-run $1 xdg-icon-resource forceupdate --theme hicolor &> /dev/null
if [ -e "$1/usr/bin/update-desktop-database" ] ; then
chroot-run $1 update-desktop-database -q
fi
sed -i -e "s/^.*AutoLoginUser=.*/AutoLoginUser=${username}/" $1/usr/share/config/kdm/kdmrc
sed -i -e "s/^.*AutoLoginPass=.*/AutoLoginPass=${username}/" $1/usr/share/config/kdm/kdmrc
_dm='kdm'
fi
# do_setupgdm
if [ -e "$1/usr/bin/gdm" ] ; then
if [ -d "$1/var/lib/AccountsService/users" ] ; then
echo "[User]" > $1/var/lib/AccountsService/users/gdm
if [ -e "$1/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
echo "XSession=LXQt" >> $1/var/lib/AccountsService/users/gdm
fi
echo "Icon=" >> $1/var/lib/AccountsService/users/gdm
fi
_dm='gdm'
fi
# do_setupmdm
if [ -e "$1/usr/bin/mdm" ] ; then
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i 's|default.desktop|xfce.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i 's|default.desktop|cinnamon.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i 's|default.desktop|openbox.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i 's|default.desktop|mate.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i 's|default.desktop|LXDE.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i 's|default.desktop|lxqt.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i 's|default.desktop|enlightenment.desktop|g' $1/etc/mdm/custom.conf
fi
_dm='mdm'
fi
# do_setupsddm
if [ -e "$1/usr/bin/sddm" ] ; then
sed -i -e "s|^User=.*|User=${username}|" $1/etc/sddm.conf
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's|^Session=.*|Session=xfce.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's|^Session=.*|Session=cinnamon.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's|^Session=.*|Session=openbox.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's|^Session=.*|Session=mate.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/lxsession" ] ; then
sed -i -e 's|^Session=.*|Session=LXDE.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's|^Session=.*|Session=lxqt.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's|^Session=.*|Session=enlightenment.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/startkde" ] ; then
sed -i -e 's|^Session=.*|Session=plasma.desktop|' $1/etc/sddm.conf
fi
_dm='sddm'
fi
# do_setuplxdm
if [ -e "$1/usr/bin/lxdm" ] ; then
sed -i -e "s/^.*autologin=.*/autologin=${username}/" $1/etc/lxdm/lxdm.conf
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/startxfce4|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/cinnamon-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/mate-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/enlightenment_start|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/openbox-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/lxsession|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/lxqt-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/pekwm" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/pekwm|' $1/etc/lxdm/lxdm.conf
fi
_dm='lxdm'
fi
if [[ -e $1/usr/bin/openrc ]];then
local _conf_xdm='DISPLAYMANAGER="'${_dm}'"'
sed -i -e "s|^.*DISPLAYMANAGER=.*|${_conf_xdm}|" $1/etc/conf.d/xdm
fi
}
# $1: chroot
configue_accountsservice(){
msg2 "Configuring AcooutsService ..."
if [ -d "$1/var/lib/AccountsService/users" ] ; then
echo "[User]" > $1/var/lib/AccountsService/users/${username}
if [ -e "$1/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
echo "XSession=LXQt" >> $1/var/lib/AccountsService/users/${username}
fi
echo "Icon=/var/lib/AccountsService/icons/${username}.png" >> $1/var/lib/AccountsService/users/${username}
fi
copy_setup_helpers(){
msg2 "Copying ${LIBDIR}/util.sh to $1/util-config.sh ..."
cp ${LIBDIR}/util-livecd.sh $1
}
configure_xorg_drivers(){
@ -633,12 +329,6 @@ make_root_image() {
fi
copy_overlay "${work_dir}/root-image"
copy_overlay_init "${work_dir}/root-image"
# set hostname
configue_hostname "${work_dir}/root-image"
${auto_svc_conf} && configure_services "${work_dir}/root-image"
# Clean up GnuPG keys
rm -rf "${work_dir}/root-image/etc/pacman.d/gnupg"
@ -673,15 +363,6 @@ make_de_image() {
if [ -e ${desktop}-overlay ] ; then
copy_overlay_desktop
fi
# set up auto start services
${auto_svc_conf} && configure_services "${work_dir}/${desktop}-image"
# configure DM & accountsservice
configue_displaymanager "${work_dir}/${desktop}-image"
configue_accountsservice "${work_dir}/${desktop}-image"
configure_plymouth "${work_dir}/${desktop}-image"
# Clean up GnuPG keys
rm -rf "${work_dir}/${desktop}-image/etc/pacman.d/gnupg"
@ -754,6 +435,80 @@ make_non_fee_overlay(){
msg "Done pkgs-nonfree-overlay"
}
# Prepare overlay-image
make_overlay_image() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
msg "Prepare overlay-image"
########################
# create overlay chroot
mkdir -p ${work_dir}/overlay-image
if [ ! -z "$(mount -l | grep overlay-image)" ]; then
umount -l ${work_dir}/overlay-image
fi
msg2 "mount root-image"
mount -t aufs -o br=${work_dir}/overlay-image:${work_dir}/root-image=ro none ${work_dir}/overlay-image
if [ ! -z "${desktop}" ] ; then
msg2 "mount ${desktop}-image"
mount -t aufs -o remount,append:${work_dir}/${desktop}-image=ro none ${work_dir}/overlay-image
fi
mkiso ${create_args[*]} -i "overlay-image" -p "${overlay_packages}" create "${work_dir}"
pacman -Qr "${work_dir}/overlay-image" > "${work_dir}/overlay-image/overlay-image-pkgs.txt"
configure_user "${work_dir}/overlay-image"
configue_displaymanager "${work_dir}/overlay-image"
configue_accountsservice "${work_dir}/overlay-image"
configure_plymouth "${work_dir}/overlay-image"
configue_hostname "${work_dir}/overlay-image"
${auto_svc_conf} && configure_services "${work_dir}/overlay-image"
####################
copy_overlay_livecd "${work_dir}/overlay"
#wget -O ${work_dir}/overlay/etc/pacman.d/mirrorlist http://git.manjaro.org/packages-sources/basis/blobs/raw/master/pacman-mirrorlist/mirrorlist
#copy_userconfig "${work_dir}/${desktop}-image" "${work_dir}/overlay"
# copy over manjaro-tools.conf
copy_manjaro_tools_conf "${work_dir}/overlay/opt/livecd"
# copy over the config loader lib to load manjaro-tools.conf vars
copy_util_sh "${work_dir}/overlay/opt/livecd"
# copy over setup helpers
#copy_util_sh "${work_dir}/overlay/opt/livecd"
cp ${work_dir}/root-image/etc/pacman.d/mirrorlist ${work_dir}/overlay/etc/pacman.d/mirrorlist
sed -i "s/#Server/Server/g" ${work_dir}/overlay/etc/pacman.d/mirrorlist
#########################
# Clean up GnuPG keys?
#rm -rf "${work_dir}/${desktop}-image/etc/pacman.d/gnupg"
umount -l ${work_dir}/overlay-image
rm -R ${work_dir}/overlay-image/.wh*
: > ${work_dir}/build.${FUNCNAME}
msg "Done overlay-image"
fi
}
make_pkgs_image() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
msg "Prepare pkgs-image"
@ -886,3 +641,33 @@ get_pkglist_overlay(){
overlay_packages=$(sed "s|#.*||g" "Packages-Overlay" | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>i686.*||g" | sed "s|>x86_64||g" | sed "s|KERNEL|$manjaro_kernel|g" | sed ':a;N;$!ba;s/\n/ /g')
fi
}
# # Prepare overlay-image
# make_overlay() {
# if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
# msg "Prepare overlay"
#
# copy_overlay_livecd "${work_dir}/overlay"
#
# #copy_livecd_init "${work_dir}/overlay"
#
# mkdir -p ${work_dir}/overlay/etc/pacman.d
#
# #copy_livecd "${PKGDATADIR}/livecd"
#
# #wget -O ${work_dir}/overlay/etc/pacman.d/mirrorlist http://git.manjaro.org/packages-sources/basis/blobs/raw/master/pacman-mirrorlist/mirrorlist
# #copy_userconfig "${work_dir}/${desktop}-image" "${work_dir}/overlay"
# # copy over manjaro-tools.conf
# copy_manjaro_tools_conf "${work_dir}/overlay/opt/livecd"
#
# # copy over the config loader lib to load manjaro-tools.conf vars
# copy_util_sh "${work_dir}/overlay/opt/livecd"
#
# cp ${work_dir}/root-image/etc/pacman.d/mirrorlist ${work_dir}/overlay/etc/pacman.d/mirrorlist
# sed -i "s/#Server/Server/g" ${work_dir}/overlay/etc/pacman.d/mirrorlist
#
# : > ${work_dir}/build.${FUNCNAME}
# msg "Done overlay"
# fi
# }

300
lib/util-livecd.sh Normal file
View file

@ -0,0 +1,300 @@
#!/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.
# $1: chroot
configure_user(){
# set up user and password
local pass=$(gen_pw)
msg2 "Creating user ${username} with password ${password} ..."
chroot-run $1 useradd -m -g users -G ${addgroups} -p ${pass} ${username}
}
# $1: chroot
configue_hostname(){
msg2 "Setting hostname ${hostname} ..."
if [[ -f $1/usr/bin/openrc ]];then
local _hostname='hostname="'${hostname}'"'
sed -i -e "s|^.*hostname=.*|${_hostname}|" $1/etc/conf.d/hostname
else
echo ${hostname} > $1/etc/hostname
fi
}
configure_plymouth(){
if [ -e $1/etc/plymouth/plymouthd.conf ] ; then
sed -i -e "s/^.*Theme=.*/Theme=$plymouth_theme/" $1/etc/plymouth/plymouthd.conf
fi
}
configure_services(){
if [[ -f ${work_dir}/root-image/usr/bin/openrc ]];then
msg2 "Congiguring OpenRC ...."
for svc in ${startservices_openrc[@]}; do
if [[ -f $1/etc/init.d/$svc ]]; then
msg2 "Setting $svc ..."
[[ ! -d $1/etc/runlevels/default ]] && mkdir -p $1/etc/runlevels/default
ln -sf /etc/init.d/$svc $1/etc/runlevels/default/$svc
fi
done
else
msg2 "Congiguring SystemD ...."
for svc in ${startservices_systemd[@]}; do
msg2 "Setting $svc ..."
if [[ -f $1/usr/lib/systemd/system/$svc ]];then
msg2 "Setting $svc ..."
chroot-run $1 systemctl enable $svc
fi
if [[ -f $1/etc/systemd/system/$svc ]];then
msg2 "Setting $svc ..."
chroot-run $1 systemctl enable $svc
fi
done
fi
}
# $1: chroot
configue_displaymanager(){
local _dm
msg2 "Configuring Displaymanager ..."
# do_setuplightdm
if [ -e "$1/usr/bin/lightdm" ] ; then
#mkdir -p /run/lightdm > /dev/null
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=xfce/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=cinnamon/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=mate/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=enlightenment/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=openbox/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=LXDE/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=lxqt/' $1/etc/lightdm/lightdm.conf
fi
if [ -e "$1/usr/bin/pekwm" ] ; then
sed -i -e 's/^.*user-session=.*/user-session=pekwm/' $1/etc/lightdm/lightdm.conf
fi
sed -i -e "s/^.*autologin-user=.*/autologin-user=${username}/" $1/etc/lightdm/lightdm.conf
sed -i -e 's/^.*autologin-user-timeout=.*/autologin-user-timeout=0/' $1/etc/lightdm/lightdm.conf
# sed -i -e 's/^.*autologin-in-background=.*/autologin-in-background=true/' /etc/lightdm/lightdm.conf
chroot-run $1 groupadd autologin
chroot-run $1 gpasswd -a ${username} autologin &> /dev/null
chroot-run $1 chmod +r /etc/lightdm/lightdm.conf
# livecd fix
mkdir -p $1/var/lib/lightdm-data
if [[ -e /run/systemd ]]; then
chroot-run $1 systemd-tmpfiles --create /usr/lib/tmpfiles.d/lightdm.conf
chroot-run $1 systemd-tmpfiles --create --remove
fi
_dm='lightdm'
fi
# do_setupkdm
if [ -e "$1/usr/share/config/kdm/kdmrc" ] ; then
chroot-run $1 xdg-icon-resource forceupdate --theme hicolor &> /dev/null
if [ -e "$1/usr/bin/update-desktop-database" ] ; then
chroot-run $1 update-desktop-database -q
fi
sed -i -e "s/^.*AutoLoginUser=.*/AutoLoginUser=${username}/" $1/usr/share/config/kdm/kdmrc
sed -i -e "s/^.*AutoLoginPass=.*/AutoLoginPass=${username}/" $1/usr/share/config/kdm/kdmrc
_dm='kdm'
fi
# do_setupgdm
if [ -e "$1/usr/bin/gdm" ] ; then
if [ -d "$1/var/lib/AccountsService/users" ] ; then
echo "[User]" > $1/var/lib/AccountsService/users/gdm
if [ -e "$1/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> $1/var/lib/AccountsService/users/gdm
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
echo "XSession=LXQt" >> $1/var/lib/AccountsService/users/gdm
fi
echo "Icon=" >> $1/var/lib/AccountsService/users/gdm
fi
_dm='gdm'
fi
# do_setupmdm
if [ -e "$1/usr/bin/mdm" ] ; then
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i 's|default.desktop|xfce.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i 's|default.desktop|cinnamon.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i 's|default.desktop|openbox.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i 's|default.desktop|mate.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i 's|default.desktop|LXDE.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i 's|default.desktop|lxqt.desktop|g' $1/etc/mdm/custom.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i 's|default.desktop|enlightenment.desktop|g' $1/etc/mdm/custom.conf
fi
_dm='mdm'
fi
# do_setupsddm
if [ -e "$1/usr/bin/sddm" ] ; then
sed -i -e "s|^User=.*|User=${username}|" $1/etc/sddm.conf
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's|^Session=.*|Session=xfce.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's|^Session=.*|Session=cinnamon.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's|^Session=.*|Session=openbox.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's|^Session=.*|Session=mate.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/lxsession" ] ; then
sed -i -e 's|^Session=.*|Session=LXDE.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's|^Session=.*|Session=lxqt.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's|^Session=.*|Session=enlightenment.desktop|' $1/etc/sddm.conf
fi
if [ -e "$1/usr/bin/startkde" ] ; then
sed -i -e 's|^Session=.*|Session=plasma.desktop|' $1/etc/sddm.conf
fi
_dm='sddm'
fi
# do_setuplxdm
if [ -e "$1/usr/bin/lxdm" ] ; then
sed -i -e "s/^.*autologin=.*/autologin=${username}/" $1/etc/lxdm/lxdm.conf
if [ -e "$1/usr/bin/startxfce4" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/startxfce4|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/cinnamon-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/mate-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/enlightenment_start|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/openbox-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/lxsession|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/lxqt-session|' $1/etc/lxdm/lxdm.conf
fi
if [ -e "$1/usr/bin/pekwm" ] ; then
sed -i -e 's|^.*session=.*|session=/usr/bin/pekwm|' $1/etc/lxdm/lxdm.conf
fi
_dm='lxdm'
fi
if [[ -e $1/usr/bin/openrc ]];then
local _conf_xdm='DISPLAYMANAGER="'${_dm}'"'
sed -i -e "s|^.*DISPLAYMANAGER=.*|${_conf_xdm}|" $1/etc/conf.d/xdm
fi
}
# $1: chroot
configue_accountsservice(){
msg2 "Configuring AcooutsService ..."
if [ -d "$1/var/lib/AccountsService/users" ] ; then
echo "[User]" > $1/var/lib/AccountsService/users/${username}
if [ -e "$1/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "$1/usr/bin/lxqt-session" ] ; then
echo "XSession=LXQt" >> $1/var/lib/AccountsService/users/${username}
fi
echo "Icon=/var/lib/AccountsService/icons/${username}.png" >> $1/var/lib/AccountsService/users/${username}
fi
}
# $1: source image
# $2: target image
copy_userconfig(){
msg2 "Copying $1/etc/skel/. $2/etc/skel"
cp -a $1/etc/skel/. $2/etc/skel
}
copy_manjaro_tools_conf(){
local livecd=$1
[[ ! -d ${livecd} ]] && mkdir ${livecd}
if [[ -f $USER_HOME/.config/manjaro-tools.conf ]]; then
msg2 "Copying $USER_HOME/.config/manjaro-tools.conf to ${livecd}/manjaro-tools.conf ..."
cp $USER_HOME/.config/manjaro-tools.conf ${livecd}/manjaro-tools.conf
else
msg2 "Copying ${manjaro_tools_conf} to ${livecd}/manjaro-tools.conf ..."
cp ${manjaro_tools_conf} ${livecd}/manjaro-tools.conf
fi
}