This file is indexed.

postinst is in mini-buildd 1.0.0~rc.5.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#!/bin/sh -e

. /usr/share/debconf/confmodule

DEFAULT_FILE="/etc/default/mini-buildd"

# Generate default file if it does not exist (it usually should, as we ship it)
if [ ! -e "${DEFAULT_FILE}" ]; then
	touch "${DEFAULT_FILE}"
fi

_update_file()
{
	local db_id="${1}"
	local sh_id="${2}"
	local default="${3}"

	# Get value (RET) from db
	db_get ${db_id}

	# Replace existing line or add new
	if grep -Eq "^ *${sh_id}=" "${DEFAULT_FILE}"; then
		# Existing config; remove the config line if the new value is the default.
		if [ "${default}" = "${RET}" ]; then
			sed -i "/^ *${sh_id}=.*/d" "${DEFAULT_FILE}"
		else
			sed -i "s|^ *${sh_id}=.*|${sh_id}=\"${RET}\"|" "${DEFAULT_FILE}"
		fi
	else
		# New config line; only do it if this is not the default, so
		# we don't get unnecessarily changed default file.
		if [ "${default}" != "${RET}" ]; then
			printf "${sh_id}='${RET}'\n" >>"${DEFAULT_FILE}"
		fi
	fi
}

# Default values values must by synced in *.postinst, *.templates and *.init.
_update_file mini-buildd/options MINI_BUILDD_OPTIONS "--verbose"

#
# 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 --system mini-buildd
	usermod --gid=mini-buildd mini-buildd

	# Fix HOME if needed
	usermod --home="${MINI_BUILDD_HOME}" --comment="${MINI_BUILDD_FULL_NAME}" --move-home mini-buildd
fi

# Always (re-)add to group sbuild
addgroup mini-buildd sbuild

# Always (re-)write mini-buildd's fstab to use with schroot. We
# need mini-buildd's ~/var (dependent on HOME) always
# bind-mounted for the way we call sbuild (at least 'spool/' (to
# setup build chroots) and 'chroots/' (for optional %LIBDIR%
# support) is needed).
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  ${MINI_BUILDD_HOME}/var  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
	printf "Setting admin password..."
	su mini-buildd -c "/usr/sbin/mini-buildd --set-admin-password='${MINI_BUILDD_ADMIN_PASSWORD}'"
	db_set mini-buildd/admin_password ""
	printf "done.\n"
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/mini-buildd" ] || [ -e "/etc/init/mini-buildd.conf" ]; then
	if [ ! -e "/etc/init/mini-buildd.conf" ]; then
		update-rc.d mini-buildd defaults >/dev/null
	fi
	invoke-rc.d mini-buildd start || exit $?
fi
# End automatically added section


exit 0