1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
#
# Handle default file
#
DEFAULT_FILE="/etc/default/mini-buildd"
if [ ! -e "${DEFAULT_FILE}" ]; then
touch "${DEFAULT_FILE}"
fi
# Replaces existing line or adds new
_to_default_file() # <debconf_var> <default_var>
{
db_get "${1}"
if grep -Eq "^ *${2}=" "${DEFAULT_FILE}"; then
sed -i "s|^ *${2}=.*|${2}=\"${RET}\"|" "${DEFAULT_FILE}"
else
printf "${2}=\"${RET}\"\n" >>"${DEFAULT_FILE}"
fi
}
_to_default_file "mini-buildd/options" "MINI_BUILDD_OPTIONS"
_to_default_file "mini-buildd/pythonwarnings" "PYTHONWARNINGS"
#
# Handle mini-buildd user
#
db_get mini-buildd/home
MINI_BUILDD_HOME="${RET}"
# Some code may actually choke (and break builds) if the passwd geco field is empty, so we set it
MINI_BUILDD_FULL_NAME="Custom Debian buildd"
if ! getent passwd mini-buildd >/dev/null; then
# Fresh install: Add a new system user/group: mini-buildd/mini-buildd
adduser --system --group --shell /bin/bash --home "${MINI_BUILDD_HOME}" --gecos "${MINI_BUILDD_FULL_NAME}" mini-buildd
else
# Existing user
# Compat (<0.9.6): Always fix old-style user/group: mini-buildd/sbuild to mini-buildd/mini-buildd
addgroup --quiet --system mini-buildd
usermod --gid=mini-buildd mini-buildd >/dev/null
# Fix HOME if needed
usermod --home="${MINI_BUILDD_HOME}" --comment="${MINI_BUILDD_FULL_NAME}" --move-home mini-buildd >/dev/null
fi
# Always (re-)add to group sbuild
adduser --quiet mini-buildd sbuild
# Always (re-)write mini-buildd's fstab to use with schroot.
# For sbuild to work the way we call it, we need
# ~/var/spool/ : Build log, ...
# ~/var/chroots-libdir: For optional %LIBDIR% support (ccache, ...).
FSTAB_FILE="/etc/schroot/mini-buildd/fstab"
cat <<EOF >${FSTAB_FILE}
# Generated by ${0} on $(date).
# Please don't edit this file; you may customize fstab-generic if needed.
#
${MINI_BUILDD_HOME}/var/shared ${MINI_BUILDD_HOME}/var/shared none rw,bind 0 0
#
EOF
cat ${FSTAB_FILE}-generic >>${FSTAB_FILE}
#
# Handle password
#
db_get mini-buildd/admin_password
MINI_BUILDD_ADMIN_PASSWORD="${RET}"
if [ -n "${MINI_BUILDD_ADMIN_PASSWORD}" ]; then
su mini-buildd -c "/usr/sbin/mini-buildd --set-admin-password='${MINI_BUILDD_ADMIN_PASSWORD}'"
db_set mini-buildd/admin_password ""
fi
#DEBHELPER#
exit 0
|