This file is indexed.

postinst is in mini-buildd 1.0.33.

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/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.
# 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/spool          ${MINI_BUILDD_HOME}/var/spool          none  rw,bind 0  0
${MINI_BUILDD_HOME}/var/chroots-libdir ${MINI_BUILDD_HOME}/var/chroots-libdir 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_systemd_enable/11ubuntu1
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'mini-buildd.service' >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled 'mini-buildd.service'; then
	# Enables the unit on first installation, creates new
	# symlinks on upgrades if the unit file has changed.
	deb-systemd-helper enable 'mini-buildd.service' >/dev/null || true
else
	# Update the statefile to add new symlinks (if any), which need to be
	# cleaned up on purge. Also remove old symlinks.
	deb-systemd-helper update-state 'mini-buildd.service' >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit/11ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/mini-buildd" ]; then
		update-rc.d mini-buildd defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d mini-buildd $_dh_action || exit $?
	fi
fi
# End automatically added section
# Automatically added by dh_installdeb/11ubuntu1
dpkg-maintscript-helper rm_conffile /etc/bash_completion.d/mini-buildd.bash-completion -- "$@"
# End automatically added section


exit 0