configure hostname,user,password, accountservice,DM at build time

This commit is contained in:
udeved 2014-12-11 03:54:02 +01:00
parent c11e55a5ad
commit e6952b29c1
8 changed files with 131 additions and 167 deletions

View file

@ -36,7 +36,7 @@ display_settings(){
msg2 "pkg_dir: ${pkg_dir}"
msg2 "pacman_conf: ${pacman_conf}"
msg2 "makepkg_conf: ${makepkg_conf}"
msg2 "pm_conf: ${pm_conf}"
msg2 "mirrors_conf: ${mirrors_conf}"
msg "BLACKLIST:"
msg2 "blacklist_trigger: ${blacklist_trigger[*]}"
@ -154,9 +154,9 @@ pkg_dir="${pkg_dir}/${branch}/${arch}"
load_pacman_conf "@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
makepkg_conf="@pkgdatadir@/makepkg-${arch}.conf"
pm_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
mirrors_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${pm_conf})
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf})
mkchrootpkg_args+=(-r ${chrootdir})

View file

@ -191,8 +191,9 @@ fi
load_pacman_conf "${pacman_conf}"
load_pacman_conf "@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
mirrors_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
create_args+=(-v -a ${arch} -D ${install_dir} -C ${pacman_conf})
create_args+=(-v -a ${arch} -D ${install_dir} -C ${pacman_conf} -M ${mirrors_conf})
iso_args+=(-a ${arch} -D ${install_dir} -L ${iso_label} -c ${compression})
@ -200,6 +201,7 @@ iso_file="${target_dir}/${img_name}-${desktop}-${iso_version}-${arch}.iso"
iso_profile=${PWD##*/}
check_root "$0" "${orig_argv[@]}"
get_pkglist

View file

@ -58,9 +58,10 @@ fi
umask 0022
[[ -e $working_dir ]] && die "Working directory '%s' already exists" "$working_dir"
#[[ -e $working_dir ]] && die "Working directory '%s' already exists" "$working_dir"
mkdir -p "$working_dir"
#mkdir -p "$working_dir"
[[ ! -d $working_dir ]] && mkdir -p "$working_dir"
lock 9 "${working_dir}.lock" "Locking chroot"

View file

@ -51,8 +51,7 @@ usage ()
echo " Default $IMAGE_FOLDER"
echo " -d Create default user directory /home/manjaro"
echo " -v Enable verbose output"
echo " -b Set branch"
echo " Default ${BRANCH}"
echo " -M Pass pacman-morrors.conf"
echo " -h This message"
echo " commands:"
echo " create <dir>"
@ -65,7 +64,7 @@ usage ()
orig_argv=("$@")
while getopts 'p:C:L:P:A:a:c:b:D:i:dfvhx' arg; do
while getopts 'p:C:L:P:A:a:c:M:D:i:dfvhx' arg; do
case "${arg}" in
p) PKGLIST="${PKGLIST} ${OPTARG}" ;;
C) PACCONFIG="${OPTARG}" ;;
@ -80,7 +79,7 @@ while getopts 'p:C:L:P:A:a:c:b:D:i:dfvhx' arg; do
f) FORCE=true ;;
x) HIGHCOMP=" -b 256K -Xbcj x86" ;;
v) QUIET=false ;;
b) BRANCH="${OPTARG}" ;;
M) MIRRORS="${OPTARG}" ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
@ -121,68 +120,40 @@ fi
msg "${APPNAME} : Configuration Settings"
msg2 "working directory: ${work_dir}"
msg2 "image name: ${imgname}"
msg2 "pacman_mirrors: ${MIRRORS}"
# usage: _pacman <packages>...
# _pacman ()
# {
# local ret
# mkdir -p "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman"
# if "${QUIET}"; then
# # eventually replace it with mkchroot to get better mout handling
# setarch ${ARCH} basestrap -GMcd "${work_dir}/${IMAGE_FOLDER}" --config "$PACCONFIG" $* &> /dev/null
# # make the chroot compatible to use chroot-run
# echo "$version" > "${work_dir}/${IMAGE_FOLDER}/.manjaro-tools"
# ret=$?
# else
# # eventually replace it with mkchroot to get better mout handling
# setarch ${ARCH} basestrap -GMcd "${work_dir}/${IMAGE_FOLDER}" --config "$PACCONFIG" $*
# # make the chroot compatible to use chroot-run
# echo "$version" > "${work_dir}/${IMAGE_FOLDER}/.manjaro-tools"
# ret=$?
# fi
#
# if [ -e "${work_dir}/root-image/etc/locale.gen" ]; then
# cp ${work_dir}/root-image/etc/locale.gen ${work_dir}/root-image/etc/locale.gen.bak
# fi
#
# # Cleanup
# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
#
# if [ $ret -ne 0 ]; then
# exit 1
# fi
# }
#
# _mkchroot ()
# {
# local ret makepkg_conf="/usr/share/manjaro-tools/makepkg-${ARCH}.conf" \
# pm_conf="/usr/share/manjaro-tools/pacman-mirrors-${BRANCH}.conf"
# #mkdir -p "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman"
# if "${QUIET}"; then
# setarch "${ARCH}" \
# mkchroot -C ${PACCONFIG} \
# -M ${makepkg_conf} -S ${pm_conf} \
# "${work_dir}/${IMAGE_FOLDER}" $* &> /dev/null
# ret=$?
# else
# setarch "${ARCH}" \
# mkchroot -C ${PACCONFIG} \
# -M ${makepkg_conf} -S ${pm_conf} \
# "${work_dir}/${IMAGE_FOLDER}" $*
# ret=$?
# fi
#
# if [ -e "${work_dir}/root-image/etc/locale.gen" ]; then
# cp ${work_dir}/root-image/etc/locale.gen ${work_dir}/root-image/etc/locale.gen.bak
# fi
#
# # Cleanup
# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
#
# if [ $ret -ne 0 ]; then
# exit 1
# fi
# }
clean_up(){
# Cleanup
find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
msg2 "Cleaning up what we can"
if [ -d "${work_dir}/${IMAGE_FOLDER}/boot/" ]; then
# remove the initcpio images that were generated for the host system
find "${work_dir}/${IMAGE_FOLDER}/boot" -name '*.img' -delete
fi
if ${CREATE_DEFAULT}; then
if [ -d "${work_dir}/${IMAGE_FOLDER}/home/" ]; then
msg2 "Creating default home directory"
install -d -o1000 -g100 -m0755 "${work_dir}/${IMAGE_FOLDER}/home/${username}"
fi
fi
# Delete pacman database sync cache files (*.tar.gz)
find "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman" -maxdepth 1 -type f -delete >/dev/null
# Delete pacman database sync cache
find "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman/sync" -delete >/dev/null
# Delete pacman package cache
find "${work_dir}/${IMAGE_FOLDER}/var/cache/pacman/pkg" -type f -delete >/dev/null
# Delete all log files, keeps empty dirs.
find "${work_dir}/${IMAGE_FOLDER}/var/log" -type f -delete >/dev/null
# Delete all temporary files and dirs
find "${work_dir}/${IMAGE_FOLDER}/var/tmp" -mindepth 1 -delete >/dev/null
# Delete all temporary files and dirs
find "${work_dir}/${IMAGE_FOLDER}/tmp" -mindepth 1 -delete >/dev/null
}
command_create () {
msg "Creating working directory: ${work_dir}"
@ -191,57 +162,27 @@ command_create () {
if [ ! -z "${PKGLIST}" ]; then
msg2 "Installing packages to '${work_dir}/${IMAGE_FOLDER}/'"
local ret makepkg_conf="@pkgdatadir@/makepkg-${ARCH}.conf" \
pm_conf="@pkgdatadir@/pacman-mirrors-${BRANCH}.conf"
local ret
#mkdir -p "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman"
if "${QUIET}"; then
setarch "${ARCH}" \
mkchroot -C ${PACCONFIG} \
-M ${makepkg_conf} -S ${pm_conf} \
-S ${MIRRORS} \
"${work_dir}/${IMAGE_FOLDER}" ${PKGLIST} &> /dev/null
ret=$?
else
setarch "${ARCH}" \
mkchroot -C ${PACCONFIG} \
-M ${makepkg_conf} -S ${pm_conf} \
-S ${MIRRORS} \
"${work_dir}/${IMAGE_FOLDER}" ${PKGLIST}
ret=$?
fi
clean_up
if [ -e "${work_dir}/root-image/etc/locale.gen" ]; then
cp ${work_dir}/root-image/etc/locale.gen ${work_dir}/root-image/etc/locale.gen.bak
fi
# Cleanup
find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
msg2 "Cleaning up what we can"
if [ -d "${work_dir}/${IMAGE_FOLDER}/boot/" ]; then
# remove the initcpio images that were generated for the host system
find "${work_dir}/${IMAGE_FOLDER}/boot" -name '*.img' -delete
fi
if ${CREATE_DEFAULT}; then
if [ -d "${work_dir}/${IMAGE_FOLDER}/home/" ]; then
msg2 "Creating default home directory"
install -d -o1000 -g100 -m0755 "${work_dir}/${IMAGE_FOLDER}/home/${username}"
fi
fi
# Delete pacman database sync cache files (*.tar.gz)
find "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman" -maxdepth 1 -type f -delete >/dev/null
# Delete pacman database sync cache
find "${work_dir}/${IMAGE_FOLDER}/var/lib/pacman/sync" -delete >/dev/null
# Delete pacman package cache
find "${work_dir}/${IMAGE_FOLDER}/var/cache/pacman/pkg" -type f -delete >/dev/null
# Delete all log files, keeps empty dirs.
find "${work_dir}/${IMAGE_FOLDER}/var/log" -type f -delete >/dev/null
# Delete all temporary files and dirs
find "${work_dir}/${IMAGE_FOLDER}/var/tmp" -mindepth 1 -delete >/dev/null
# Delete all temporary files and dirs
find "${work_dir}/${IMAGE_FOLDER}/tmp" -mindepth 1 -delete >/dev/null
fi
}

View file

@ -61,9 +61,6 @@
# unset defaults to given value
# img_name=manjaro
# unset defaults to given value
# username="manjaro"
# unset defaults to given value
# install_dir=manjaro
@ -73,6 +70,16 @@
# unset defaults to given value
# compression=xz
# unset defaults to given value, currently unused
########### livecd setup #############
# unset defaults to given value
# hostname="manjaro"
# unset defaults to given value
# username="manjaro"
# unset defaults to given value
# password="manjaro"
# unset defaults to given values
# addgroups="video,audio,power,disk,storage,optical,network,lp,scanner"

View file

@ -255,6 +255,38 @@ set_dm(){
fi
}
set_accountservice(){
#echo "Icon=/var/lib/AccountsService/icons/${username}.png" >> $1/var/lib/AccountsService/users/${username}
if [ -d "$1/var/lib/AccountsService/users" ] ; then
echo "[User]" > $1/var/lib/AccountsService/users/${username}
if [ -e "/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> $1/var/lib/AccountsService/users/${username}
fi
if [ -e "/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
}
# Prepare /EFI
make_efi() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
@ -400,6 +432,10 @@ make_iso() {
msg "Done"
}
gen_pw(){
echo $(perl -e 'print crypt($ARGV[0], "password")' ${password})
}
# Base installation (root-image)
make_root_image() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
@ -408,6 +444,20 @@ make_root_image() {
mkiso ${create_args[*]} -p "${packages}" -i "root-image" create "${work_dir}"
pacman -Qr "${work_dir}/root-image" > "${work_dir}/root-image/root-image-pkgs.txt"
# set hostname
if [[ -f ${work_dir}/root-image/usr/bin/openrc ]];then
local _hostname='hostname="'${hostname}'"'
sed -i -e "s|^.*hostname=.*|${_hostname}|" ${work_dir}/root-image/etc/conf.d/hostname
else
echo ${hostname} > ${work_dir}/root-image/etc/hostname
fi
# set up user and password
local pass=$(gen_pw)
msg2 "Creating user ${username} and crypt password ${password}: ${pass} ..."
chroot-run ${work_dir}/root-image useradd -m -g users -G ${addgroups} -p ${pass} ${username}
cp ${work_dir}/root-image/etc/locale.gen.bak ${work_dir}/root-image/etc/locale.gen
if [ -e ${work_dir}/root-image/boot/grub/grub.cfg ] ; then
@ -434,25 +484,14 @@ make_root_image() {
fi
cp -LPr overlay/* ${work_dir}/root-image
set_accountservice "${work_dir}/root-image"
# Clean up GnuPG keys
rm -rf "${work_dir}/root-image/etc/pacman.d/gnupg"
# set hostname
if [[ -f ${work_dir}/root-image/usr/bin/openrc ]];then
local _hostname='hostname="'${hostname}'"'
sed -i -e "s|^.*hostname=.*|${_hostname}|" ${work_dir}/root-image/etc/conf.d/hostname
else
echo ${hostname} > ${work_dir}/root-image/etc/hostname
fi
msg2 "Creating user ${username} ..."
local addgroups="video,audio,power,disk,storage,optical,network,lp,scanner"
local pass=$(perl -e 'print crypt($ARGV[0], "password")' $username)
chroot-run ${work_dir}/root-image useradd -m -g users -G $addgroups -p $pass ${username}
# Change to given branch in options.conf
sed -i -e "s/stable/$branch/" ${work_dir}/root-image/etc/pacman.d/mirrorlist
sed -i -e "s/stable/$branch/" ${work_dir}/root-image/etc/pacman-mirrors.conf
#sed -i -e "s/stable/$branch/" ${work_dir}/root-image/etc/pacman.d/mirrorlist
#sed -i -e "s/stable/$branch/" ${work_dir}/root-image/etc/pacman-mirrors.conf
: > ${work_dir}/build.${FUNCNAME}
msg "Done"
@ -518,6 +557,9 @@ make_de_image() {
pacman -Qr "${work_dir}/${desktop}-image" > "${work_dir}/${desktop}-image/${desktop}-image-pkgs.txt"
cp "${work_dir}/${desktop}-image/${desktop}-image-pkgs.txt" ${target_dir}/${img_name}-${desktop}-${iso_version}-${arch}-pkgs.txt
# set DM
set_dm "${work_dir}/${desktop}-image"
if [ -e ${desktop}-overlay ] ; then
cp -LPr ${desktop}-overlay/* ${work_dir}/${desktop}-image
fi
@ -535,9 +577,6 @@ make_de_image() {
sed -i -e "s/^.*Theme=.*/Theme=$plymouth_theme/" ${work_dir}/${desktop}-image/etc/plymouth/plymouthd.conf
fi
# set DM
set_dm "${work_dir}/${desktop}-image"
umount -l ${work_dir}/${desktop}-image
rm -R ${work_dir}/${desktop}-image/.wh*

View file

@ -318,6 +318,18 @@ load_config(){
compression=xz
fi
if [[ -n ${password} ]];then
password=${password}
else
password="manjaro"
fi
if [[ -n ${addgroups} ]];then
addgroups=${addgroups}
else
addgroups="video,audio,power,disk,storage,optical,network,lp,scanner"
fi
return 0
}

View file

@ -73,47 +73,9 @@ fi
echo "configure user" >> /tmp/livecd.log
# do_makeuser
#addgroups="video,audio,power,disk,storage,optical,network,lp,scanner"
#useradd -m -p "" -g users -G $addgroups ${username}
#sed -i "s#${username}.*#${username}:\$1\$uYIrxnwJ\$a5wTa84YxxYmD.sKX/Lll1:14942:0:99999:7:::#" /etc/shadow
echo "Icon=/var/lib/AccountsService/icons/${username}.png" >> /var/lib/AccountsService/users/${username}
# do_configsforroot
cp -a /etc/skel/. /root/
echo "configure display managers" >> /tmp/livecd.log
#set_dm
echo "configure AccountsService" >> /tmp/livecd.log
if [ -d "/var/lib/AccountsService/users" ] ; then
echo "[User]" > /var/lib/AccountsService/users/manjaro
if [ -e "/usr/bin/startxfce4" ] ; then
echo "XSession=xfce" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/cinnamon-session" ] ; then
echo "XSession=cinnamon" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/mate-session" ] ; then
echo "XSession=mate" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/enlightenment_start" ] ; then
echo "XSession=enlightenment" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/openbox-session" ] ; then
echo "XSession=openbox" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/startlxde" ] ; then
echo "XSession=LXDE" >> /var/lib/AccountsService/users/manjaro
fi
if [ -e "/usr/bin/lxqt-session" ] ; then
echo "XSession=LXQt" >> /var/lib/AccountsService/users/manjaro
fi
echo "Icon=/var/lib/AccountsService/icons/manjaro.png" >> /var/lib/AccountsService/users/manjaro
fi
echo "configure sudoers" >> /tmp/livecd.log
# do_fix_perms