openstack-pkg-tools-8/0000755000000000000000000000000012220513746012017 5ustar openstack-pkg-tools-8/debian/0000755000000000000000000000000012220513746013241 5ustar openstack-pkg-tools-8/debian/compat0000644000000000000000000000000212220513746014437 0ustar 9 openstack-pkg-tools-8/debian/control0000644000000000000000000000160612220513746014647 0ustar Source: openstack-pkg-tools Section: devel Priority: extra Maintainer: PKG OpenStack Uploaders: Julien Danjou , Thomas Goirand , Ghe Rivero , Mehdi Abaakouk Build-Depends: debhelper (>= 9) Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/openstack-pkg-tools.git;a=summary Vcs-Git: git://anonscm.debian.org/openstack/openstack-pkg-tools.git Package: openstack-pkg-tools Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends} Description: Tools and scripts for building Openstack packages in Debian This package contains some useful shell scripts and helpers for building the Openstack packages in Debian, including shared code for maintainer scripts, and probably more in the future. openstack-pkg-tools-8/debian/openstack-pkg-tools.install0000644000000000000000000000021012220513746020526 0ustar pkgos.make /usr/share/openstack-pkg-tools pkgos_func /usr/share/openstack-pkg-tools pkgos_insert_include /usr/share/openstack-pkg-tools openstack-pkg-tools-8/debian/source/0000755000000000000000000000000012220513746014541 5ustar openstack-pkg-tools-8/debian/source/format0000644000000000000000000000001512220513746015750 0ustar 3.0 (native) openstack-pkg-tools-8/debian/gbp.conf0000644000000000000000000000013212220513746014654 0ustar [DEFAULT] debian-branch = debian/unstable [git-buildpackage] export-dir = ../build-area/ openstack-pkg-tools-8/debian/changelog0000644000000000000000000000537612220513746015126 0ustar openstack-pkg-tools (8) unstable; urgency=low * Allow the upstart thing to also work with package.daemon.upstart.in (replaced the cut -d by a sed s/.upstart.in//). * Adds a git show in the gen-orig-xz, to check if the tag exists before creating the orig.tar.xz. * Added functions to automatically configure rabbit_* directives. -- Thomas Goirand Fri, 28 Jun 2013 16:18:55 +0800 openstack-pkg-tools (7) unstable; urgency=low * Adds a pkgos_safesed function which doesn't put the (eventual) passwords visible using "ps", which makes it safe to use sed for passwords. Then pkgos_inifile uses that function now. * Added a function to remove a [SECTION] in a config file. -- Thomas Goirand Tue, 11 Jun 2013 11:58:32 +0800 openstack-pkg-tools (6) unstable; urgency=low * Removed the -R flag when doing chown -R /var/lib/. * Extracted the adduser / addgroup function from pkgos_var_user_group as a separate (callable) function. * Bumped standard-version to 3.9.4. -- Thomas Goirand Thu, 30 May 2013 23:52:11 +0800 openstack-pkg-tools (5) unstable; urgency=low * Uploading to SID. * Split the get-vcs-source: into 3 targets: - fetch-upstream-remote: - gen-orig-xz: - +get-master-branch: -- Thomas Goirand Fri, 10 May 2013 18:14:51 +0800 openstack-pkg-tools (4) experimental; urgency=low * Clean-ups of function parameter calling order. * Rewrite of the pkgos_* functions for parsing ini files. -- Thomas Goirand Tue, 12 Mar 2013 00:43:02 +0800 openstack-pkg-tools (3) experimental; urgency=low [ Thomas Goirand ] * Don't attempt to read anything from the config file if it isn't installed in /etc (in the pkgos_read_admin_creds pkgos.make target). [ James Page ] * Fixup handling of d/*.upstart.in to fix build failures downstream in Ubuntu. -- Thomas Goirand Sat, 02 Feb 2013 11:30:43 +0000 openstack-pkg-tools (2) experimental; urgency=low * Now copying the orig.tar.xz in the build-area after creating it. * Now using the debian branch name defined in debian/gbp.conf for get-vcs-source. * Added code to handle auth_url instead of auth_host / auth_port / auth_proto. * Added a workround the fact that DPKG_MAINTSCRIPT_PACKAGE isn't always set (bug in debconf?) * Added a gen-author-list: target. * Sets various debconf questions with priority medium instead of high. * Added gen-upstream-changelog to generate a debian/CHANGELOG from upstream git log. -- Thomas Goirand Thu, 20 Dec 2012 09:50:58 +0000 openstack-pkg-tools (1) experimental; urgency=low * Initial release. -- Thomas Goirand Fri, 16 Nov 2012 14:29:41 +0000 openstack-pkg-tools-8/debian/copyright0000644000000000000000000000170312220513746015175 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: openstack-pkg-tools Source: git://anonscm.debian.org/openstack/openstack-pkg-tools.git Files: * Copyright: 2012, Thomas Goirand 2012, Roland Mas License: Apache-2 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. . On Debian-based systems the full text of the Apache version 2.0 license can be found in `/usr/share/common-licenses/Apache-2.0'. openstack-pkg-tools-8/debian/rules0000755000000000000000000000074012220513746014322 0ustar #!/usr/bin/make -f build-arch: build build-indep: build build: clean: dh_testdir dh_clean install: dh_testdir dh_testroot dh_prep binary-indep: install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_install dh_compress dh_fixperms dh_installdeb dh_gencontrol dh_md5sums dh_builddeb get-vcs-source: echo "Nothing to do here..." binary-arch: install binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install openstack-pkg-tools-8/pkgos_func0000644000000000000000000005605712220513746014115 0ustar #!/bin/sh # -*- mode: shell-script -*- pkgos_gen_pass () { i=$(dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum) echo ${i% *} } # This function removes a section, because we need that in the case # of an upgrade from one version to the next. It is for example # needed for keystone to upgrade from Grizzly to Havana. # Params: # $1 Init file path # $2 Section to remove pkgos_remove_section () { local REMOVESEC_INIFILE REMOVESEC_SEARCH_SECTION REMOVESEC_INIFILE_CNT REMOVESEC_LINE REMOVESEC_FOUND_SECTION REMOVESEC_START_LINE REMOVESEC_END_LINE REMOVESEC_INIFILE=${1} REMOVESEC_SEARCH_SECTION=${2} if [ ! -r ${REMOVESEC_INIFILE} ] ; then return ; fi # Iterate through all lines of the file to search for section start/end line number REMOVESEC_INIFILE_CNT=0 REMOVESEC_FOUND_SECTION="" REMOVESEC_START_LINE="" REMOVESEC_END_LINE="" while read REMOVESEC_LINE ; do REMOVESEC_INIFILE_CNT=$((${REMOVESEC_INIFILE_CNT} + 1 )) if echo ${REMOVESEC_LINE} | grep -q '^[ \t]*\[.*\][ \t]*$' ; then REMOVESEC_FOUND_SECTION=`echo ${REMOVESEC_LINE} | sed -e 's/\[//' | sed -e 's/\]//'` echo "Found section: ${REMOVESEC_FOUND_SECTION}" if [ "${REMOVESEC_FOUND_SECTION}" = "${REMOVESEC_SEARCH_SECTION}" ] ; then REMOVESEC_START_LINE=$(( ${REMOVESEC_INIFILE_CNT} - 1 )) else if [ -n "${REMOVESEC_START_LINE}" ] && [ -z "${REMOVESEC_END_LINE}" ] ; then REMOVESEC_END_LINE=$(( ${REMOVESEC_INIFILE_CNT} -1 )) fi fi fi done < ${REMOVESEC_INIFILE} # Case where the section is last in the file if [ -n "${REMOVESEC_START_LINE}" ] && [ -z "${REMOVESEC_END_LINE}" ] ; then REMOVESEC_END_LINE=${REMOVESEC_INIFILE_CNT} fi # Section found, remove it! if [ -n "${REMOVESEC_START_LINE}" ] && [ -n "${REMOVESEC_END_LINE}" ] ; then REMOVESEC_CONF_LINES_NUM=`wc -l ${REMOVESEC_INIFILE} | cut -d" " -f1` REMOVESEC_CUT_END=$((${REMOVESEC_CONF_LINES_NUM} - ${REMOVESEC_END_LINE} )) REMOVESEC_TMPFILE=`mktemp -t pkgos_removesec.XXXXXX` head -n ${REMOVESEC_START_LINE} ${REMOVESEC_INIFILE} >${REMOVESEC_TMPFILE} tail -n ${REMOVESEC_CUT_END} ${REMOVESEC_INIFILE} >>${REMOVESEC_TMPFILE} cat <${REMOVESEC_TMPFILE} >${REMOVESEC_INIFILE} rm ${REMOVESEC_TMPFILE} fi } # Using sed to set passwords with arguments on the command line makes # it possible to see the new passwords using ps. This function creates # a temp file which is used as a script for sed (using the -f option). # This is safe because what's put in the file is done with echo, which # is a built-in shell command, so it will not appear in /proc. # Params: # $1 Sed script to replace values in a config file # $2 Config file to change pkgos_safesed () { local SAFESED_SCRIPT SAFESED_CONFIG_FILENAME SAFESED_TMPFILE SAFESED_SCRIPT=${1} SAFESED_CONFIG_FILENAME=${2} SAFESED_TMPFILE=`mktemp -t pkgos_safe_sed.XXXXXX` echo "${SAFESED_SCRIPT}" >${SAFESED_TMPFILE} sed -i -f ${SAFESED_TMPFILE} ${SAFESED_CONFIG_FILENAME} rm ${SAFESED_TMPFILE} } # Params: $1 = set or get (set means read mode and return a directive value, get means write a new value in it) # $2 = config file path (example: /etc/nova/nova.conf) # $3 = .ini file section (example: DEFAULT) # $4 = directive name (example: sql_connection) # $5 = only present in "set" mode: new value to replace in the .ini file # Note that if $3 = NO_SECTION, then get or set mode will not manage sections at all, # and will totally ignore the sections in the .ini file. # # Example (get the value of keystone hostname in your Nova box): # parse_ini_file /etc/nova/api-paste.ini filter:authtoken auth_host # # Returns: $RET: either NOT_FOUND, or the (previous, in the case of set) value of the searched directive pkgos_inifile () { local INIFILE_SHELL_INCLUDE INIFILE_ACCESS_MODE INIFILE_MYCONFIG INIFILE_SEARCH_SECTION SEARCH_DIRECTIVE INIFILE_CNT INIFILE_DIRECTIVE INIFILE_VALUE INIFILE_SECTION INIFILE_LINE DIRECTIVE_TYPE INIFILE_NEW_VALUE if [ "${1}" = "-shinc" ] ; then INIFILE_SHELL_INCLUDE=yes shift else INIFILE_SHELL_INCLUDE=no fi INIFILE_ACCESS_MODE=${1} ; INIFILE_MYCONFIG=${2} ; INIFILE_SEARCH_SECTION=${3} ; SEARCH_DIRECTIVE=${4} if [ "x${INIFILE_ACCESS_MODE}" = "xset" ] ; then INIFILE_NEW_VALUE=${5} ; else INIFILE_NEW_VALUE="pkgos_inifile_function_called_with_wrong_access_mode" ; fi INIFILE_CNT=0 RET=NOT_FOUND if [ ! -r ${INIFILE_MYCONFIG} ] ; then return ; fi # Iterate through all lines of the file while read INIFILE_LINE ; do INIFILE_CNT=$((${INIFILE_CNT} + 1 )) # This is a section block: [DEFAULT] if echo ${INIFILE_LINE} | grep -q '^[ \t]*\[.*\][ \t]*$' ; then if [ ! "${INIFILE_SEARCH_SECTION}" = "NO_SECTION" ] ; then INIFILE_SECTION=`echo ${INIFILE_LINE} | sed -e 's/\[//' | sed -e 's/\]//'` #echo "===> $INIFILE_SECTION" fi # This is a directive: auth_host = 127.0.0.1 elif echo ${INIFILE_LINE} | grep -q '^[;#]*[ \t]*[\._\/a-zA-Z0-9]*[ \t]*[=\:][ \t]*' ; then # This is a commented out directive, let's remove the comment # if there's no such active directive in the file if grep -q '^[#;][ \t]*[\._\/a-zA-Z0-9]*[ \t]*[=\:][ \t]*' ${INIFILE_MYCONFIG} ; then if echo ${INIFILE_LINE} | grep -q '^[#;][ \t]*'${SEARCH_DIRECTIVE}'[ \t]*[=\:][ \t]*' ; then INIFILE_LINE=`echo ${INIFILE_LINE} | sed -e 's/^#//'` fi fi # This is a directive which uses the equal sign (directive = value) if echo ${INIFILE_LINE} | grep -q '^[ \t]*[\._\/a-zA-Z0-9]*[ \t]*=[ \t]*' ; then INIFILE_DIRECTIVE=`echo ${INIFILE_LINE} | cut -d= -f1 | awk '{print $1}'` DIRECTIVE_TYPE="equal" INIFILE_VALUE=`echo ${INIFILE_LINE} | cut -d= -f2 | sed -e 's/^[ \t]//'` #echo ${INIFILE_DIRECTIVE}=${INIFILE_VALUE} # This one uses the semi-column sign (/directive: value) else INIFILE_DIRECTIVE=`echo ${INIFILE_LINE} | cut -d':' -f1 | awk '{print $1}'` DIRECTIVE_TYPE="dots" INIFILE_VALUE=`echo ${INIFILE_LINE} | cut -d':' -f2 | sed -e 's/^[ \t]//'` #echo ${INIFILE_DIRECTIVE}: ${INIFILE_VALUE} fi if [ "${INIFILE_SECTION}" = "${INIFILE_SEARCH_SECTION}" ] && [ "${INIFILE_DIRECTIVE}" = "${SEARCH_DIRECTIVE}" ] ; then RET=${INIFILE_VALUE} if [ "x${INIFILE_ACCESS_MODE}" = "xset" ] ; then if [ "${DIRECTIVE_TYPE}" = "equal" ] ; then if [ "${INIFILE_SHELL_INCLUDE}" = "yes" ] ; then pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}'='${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} else pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}' = '${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} fi else pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}': '${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} fi fi return fi # This is a comment block elif echo $INIFILE_LINE | grep -q '^[ \t]*#.*$' ; then echo -n "" fi done < ${INIFILE_MYCONFIG} } # Read the value of a directive in a config file, # then prompt the user about it. # Example (options in this order please...): # pkgos_read_config -p medium /etc/keystone/keystone.conf auth_token keystone/auth-token DEFAULT # To be used in: config pkgos_read_config () { local READ_CONFIG_DIRECTIVE CONF_PATH READ_CONFIG_DEBCONF_NAME READ_CONFIG_SECTION FSET_SEEN READ_CONFIG_MY_PRIORITY if [ "${1}" = "-p" ] ; then READ_CONFIG_MY_PRIORITY=${2} shift shift else READ_CONFIG_MY_PRIORITY=high fi CONF_PATH=${1} READ_CONFIG_SECTION=${2} READ_CONFIG_DIRECTIVE=${3} READ_CONFIG_DEBCONF_NAME=${4} pkgos_inifile get ${CONF_PATH} ${READ_CONFIG_SECTION} ${READ_CONFIG_DIRECTIVE} if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then db_set ${READ_CONFIG_DEBCONF_NAME} ${RET} fi db_input ${READ_CONFIG_MY_PRIORITY} ${READ_CONFIG_DEBCONF_NAME} || true db_go db_get ${READ_CONFIG_DEBCONF_NAME} } # Read the current configuration for rabbitMQ and sets that into debconf # Params: $1 Path to config file # $2 Section in the config file # $3 prefix for the debconf template (eg: if we have nova/rabbit_host, then use "nova") # To be used in: config # Example call: pkgos_rabbit_read_conf /etc/nova/nova.conf DEFAULT nova pkgos_rabbit_read_conf () { local RB_CONF_PATH RB_SECTION RB_DEBCONF_PREFIX RB_CONF_PATH=${1} RB_SECTION=${2} RB_DEBCONF_PREFIX=${3} pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_host ${RB_DEBCONF_PREFIX}/rabbit_host pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_userid ${RB_DEBCONF_PREFIX}/rabbit_userid pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_password ${RB_DEBCONF_PREFIX}/rabbit_password } # Write the configuration for rabbitMQ # Params: $1 Path to config file # $2 Section in the config file # $3 prefix for the debconf template (eg: if we have nova/rabbit_host, then use "nova") # To be used in: postinst # Example call: pkgos_rabbit_write_conf /etc/nova/nova.conf DEFAULT nova pkgos_rabbit_write_conf () { local RB_CONF_PATH RB_SECTION RB_DEBCONF_PREFIX RB_CONF_PATH=${1} RB_SECTION=${2} RB_DEBCONF_PREFIX=${3} db_get ${RB_DEBCONF_PREFIX}/rabbit_host pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_host ${RET} db_get ${RB_DEBCONF_PREFIX}/rabbit_userid pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_userid ${RET} db_get ${RB_DEBCONF_PREFIX}/rabbit_password pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_password ${RET} } # Read the connection directive from a config file # and fills the dbc_* variable accordingly, # then call dbconfig to do the actual configuration. # To be used in: config # Example call: pkgos_dbc_read_conf -pkg glance-common /etc/glance/glance-registry.conf glance DEFAULT sql_connection $@ pkgos_dbc_read_conf () { local ADDR BEFORE_AT AFTER_AT SERVER_PORT CONN_STRING PKG_NAME CONF_PATH PARSED_DB_TYPE PARSED_USER PARSED_PASS PARSED_DB_NAME PARSED_SERVER PARSED_PORT # This works around a bug in either dpkg, apt or debconf: in fact, # likely in debconf, the variable DPKG_MAINTSCRIPT_PACKAGE isn't # always set as it should. if [ "${1}" = "-pkg" ] ; then if [ -z "${DPKG_MAINTSCRIPT_PACKAGE}" ] ; then DPKG_MAINTSCRIPT_PACKAGE=$2 fi shift shift fi CONF_PATH=${1} CONN_SECTION=${2} CONN_DIRECTIVE=${3} PKG_NAME=${4} # Do not remove what's bellow. # We need to shift, because we're using $@ in the dbc_go call later shift shift shift shift db_input high ${PKG_NAME}/configure_db || true db_go || true db_get ${PKG_NAME}/configure_db DEFAULT_DBNAME=$(echo ${PKG_NAME}db | sed s/-//g) if [ "$RET" = "true" ] && [ -f /usr/share/dbconfig-common/dpkg/config ] ; then . /usr/share/dbconfig-common/dpkg/config if [ -e "${CONF_PATH}" ] ; then pkgos_inifile get ${CONF_PATH} ${CONN_SECTION} ${CONN_DIRECTIVE} if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then CONN_STRING=${RET} fi else CONN_STRING="" fi PARSED_DB_TYPE=${CONN_STRING%%:*} # If we have an undefined SQL type, we go back to a more sane default (eg: SQLite) case "${PARSED_DB_TYPE}" in sqlite|mysql|pgsql) ;; postgresql*) PARSED_DB_TYPE=pgsql ;; *) CONN_STRING="sqlite:///var/lib/${PKG_NAME}/${DEFAULT_DBNAME}" PARSED_DB_TYPE="sqlite" ;; esac if [ "${PARSED_DB_TYPE}" = "sqlite" ] ; then if [ "${CONN_STRING}" = "sqlite:///${PKG_NAME}.db" ] ; then CONN_STRING="sqlite:///var/lib/${PKG_NAME}/${DEFAULT_DBNAME}" fi PARSED_DB_PATH=${CONN_STRING#sqlite://} if [ -z "${PARSED_DB_PATH}" ] ; then PARSED_DB_PATH=/var/lib/${PKG_NAME}/${DEFAULT_DBNAME} fi dbc_basepath=`dirname "${PARSED_DB_PATH}"` dbc_dbname=`basename "${PARSED_DB_PATH}"` dbc_dbtypes="sqlite3, mysql, pgsql" else ADDR=${CONN_STRING#*sql://} BEFORE_AT=${ADDR%%@*} AFTER_AT=${ADDR#*@} SERVER_PORT=${AFTER_AT%%/*} PARSED_USER=${BEFORE_AT%%:*} PARSED_PASS=${BEFORE_AT#*:} PARSED_DB_NAME=${AFTER_AT#*/} PARSED_SERVER=${SERVER_PORT%%:*} case "${SERVER_PORT}" in *:*) PARSED_PORT=${SERVER_PORT#*:} ;; *) PARSED_PORT="" ;; esac if [ -n "${PARSED_USER}" ] && [ -n "${PARSED_PASS}" ] && [ -n "${PARSED_SERVER}" ] && [ -n "${PARSED_DB_NAME}" ] ; then dbc_dbuser=${PARSED_USER} dbc_dbpass=${PARSED_PASS} dbc_dbserver=${PARSED_SERVER} dbc_dbport=${PARSED_PORT} dbc_dbname=${PARSED_DB_NAME} fi if [ "${PARSED_DB_TYPE}" = "mysql" ] ; then dbc_dbtypes="mysql, pgsql, sqlite3" else dbc_dbtypes="pgsql, mysql, sqlite3" fi dbc_authmethod_user="password" fi echo "PKG-Openstack now calling: dbc_go "${DPKG_MAINTSCRIPT_PACKAGE} $@ dbc_go "${DPKG_MAINTSCRIPT_PACKAGE}" $@ fi } # Read values configured by dbconfig-common, # and set a connection directive accordingly # in a configuration file # # Caller should use something like this: # pkgos_dbc_postinst /etc/keystone/keystone.conf keystone connection $@ # since dbc_go expect $@ as well. pkgos_dbc_postinst () { local DBC_POST_CONF_PATH CONF_DIR DBC_POST_CONF_FNAME PKG_NAME SUITE if [ "${1}" = "--suite" ] ; then SUITE=${2} shift shift else SUITE=${4} fi DBC_POST_CONF_PATH=${1} CONN_SECTION=${2} CONN_DIRECTIVE=${3} PKG_NAME=${4} shift shift shift shift CONF_DIR=`dirname ${DBC_POST_CONF_PATH}` DBC_POST_CONF_FNAME=`basename ${DBC_POST_CONF_PATH}` # Create config files if they don't exist if [ ! -d ${CONF_DIR} ] ; then mkdir -p ${CONF_DIR} fi chmod 0770 ${CONF_DIR} chown ${SUITE}:${SUITE} ${CONF_DIR} if [ ! -e ${DBC_POST_CONF_PATH} ] ; then install -D -m 0660 -o ${SUITE} -g ${SUITE} /usr/share/${DPKG_MAINTSCRIPT_PACKAGE}/${DBC_POST_CONF_FNAME} ${DBC_POST_CONF_PATH} fi db_get ${PKG_NAME}/configure_db if [ "$RET" = "true" ] && [ -r /usr/share/dbconfig-common/dpkg/postinst ] ; then . /usr/share/dbconfig-common/dpkg/postinst dbc_dbfile_owner="${SUITE}:${SUITE}" dbc_go "${DPKG_MAINTSCRIPT_PACKAGE}" $@ if [ "$dbc_install" = "true" ] ; then case "$dbc_dbtype" in mysql) if [ -n "$dbc_dbport" ] ; then dbport=:$dbc_dbport fi SQL_CONNECTION="mysql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname" ;; postgresql*|pgsql) if [ -n "$dbc_dbport" ] ; then dbport=:$dbc_dbport fi SQL_CONNECTION="postgresql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname" ;; *) SQL_CONNECTION="sqlite:///$dbc_basepath/$dbc_dbname" ;; esac pkgos_inifile set ${DBC_POST_CONF_PATH} ${CONN_SECTION} ${CONN_DIRECTIVE} ${SQL_CONNECTION} fi fi } # Reads auth_host, admin_tenant_name, admin_user and admin_password # values with debconf # Prototype: pkgos_read_admin_creds
# Example calls: # pkgos_read_admin_creds /etc/glance/glance-api.conf glance keystone_authtoken # To be used in: config pkgos_read_admin_creds () { local READ_ADMIN_CRED_CONF_FNAME READ_ADMIN_CRED_PKG_NAME READ_ADMIN_CRED_SEARCH_SECTION READ_ADMIN_CRED_CONF_FNAME=${1} READ_ADMIN_CRED_SEARCH_SECTION=${2} READ_ADMIN_CRED_PKG_NAME=${3} if [ ! -r "${READ_ADMIN_CRED_CONF_FNAME}" ] ; then # If the file doesn't exist, just ask... db_input high ${READ_ADMIN_CRED_PKG_NAME}/auth-host || true else if grep -q auth_host ${READ_ADMIN_CRED_CONF_FNAME} ; then pkgos_read_config ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} auth_host ${READ_ADMIN_CRED_PKG_NAME}/auth-host else # This is needed for l3_agent.ini if grep -q auth_url ${READ_ADMIN_CRED_CONF_FNAME} ; then pkgos_inifile get ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} auth_url if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then NO_PROTO=${RET#http://} BEFORE_PORT=$(echo ${NO_PROTO} | cut -d":" -f1) if [ -z "${BEFORE_PORT}" ] ; then db_set ${READ_ADMIN_CRED_PKG_NAME}/auth-host ${BEFORE_PORT} fi fi db_input high ${READ_ADMIN_CRED_PKG_NAME}/auth-host || true db_go else echo "Couldn't find either auth_host or auth_url :(" fi fi fi pkgos_read_config -p medium ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} admin_tenant_name ${READ_ADMIN_CRED_PKG_NAME}/admin-tenant-name pkgos_read_config -p medium ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} admin_user ${READ_ADMIN_CRED_PKG_NAME}/admin-user pkgos_read_config ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} admin_password ${READ_ADMIN_CRED_PKG_NAME}/admin-password } # To be used in: postinst pkgos_write_admin_creds () { local WRITE_CRED_CONF_FNAME WRITE_CRED_PKG_NAME WRITE_CRED_SECTION NO_PROTO AFTER_PORT WRITE_CRED_URL WRITE_CRED_CONF_FNAME=${1} WRITE_CRED_SECTION=${2} WRITE_CRED_PKG_NAME=${3} db_get ${WRITE_CRED_PKG_NAME}/auth-host WRITE_CRED_AUTH_HOST=${RET} if grep -q auth_host ${WRITE_CRED_CONF_FNAME} ; then pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} ${RET} else # This is needed for l3_agent.ini if grep -q auth_url ${WRITE_CRED_CONF_FNAME} ; then pkgos_inifile get ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} auth_url NO_PROTO=${RET#http://} AFTER_PORT=$(echo ${NO_PROTO} | cut -d":" -f2) WRITE_CRED_URL="http://${WRITE_CRED_AUTH_HOST}:${AFTER_PORT}" pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} auth_url ${WRITE_CRED_URL} else echo "Couldn't find either auth_host or auth_url :(" fi fi db_get ${WRITE_CRED_PKG_NAME}/admin-tenant-name pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_tenant_name ${RET} db_get ${WRITE_CRED_PKG_NAME}/admin-user pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_user ${RET} db_get ${WRITE_CRED_PKG_NAME}/admin-password pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_password ${RET} } pkgos_write_new_conf () { local WRITE_N_CONF_PKG_NAME CONF_FNAME WRITE_N_CONF_PKG_NAME=${1} CONF_FNAME=${2} SRC_PATH=/usr/share/${DPKG_MAINTSCRIPT_PACKAGE}/${CONF_FNAME} DST_DIR=/etc/${WRITE_N_CONF_PKG_NAME} DST_PATH=${DST_DIR}/${CONF_FNAME} if [ ! -d ${DST_DIR} ] ; then mkdir -p ${DST_DIR} fi chmod 0750 ${DST_DIR} chown ${WRITE_N_CONF_PKG_NAME}:${WRITE_N_CONF_PKG_NAME} ${DST_DIR} if [ ! -e ${DST_PATH} ] ; then install -D -m 640 -o ${WRITE_N_CONF_PKG_NAME} -g ${WRITE_N_CONF_PKG_NAME} ${SRC_PATH} ${DST_PATH} fi } pkgos_adduser () { local VAR_UG_PKG_NAME VAR_UG_PKG_NAME=${1} # Create user and groups if they don't exist if ! getent group ${VAR_UG_PKG_NAME} > /dev/null 2>&1 ; then addgroup --quiet --system ${VAR_UG_PKG_NAME} fi if ! getent passwd ${VAR_UG_PKG_NAME} > /dev/null 2>&1 ; then adduser --system \ --home /var/lib/${VAR_UG_PKG_NAME} \ --no-create-home \ --quiet \ --disabled-password \ --shell /bin/bash \ --group ${VAR_UG_PKG_NAME} fi } pkgos_var_user_group () { local VAR_UG_PKG_NAME VAR_UG_PKG_NAME=${1} pkgos_adduser ${VAR_UG_PKG_NAME} # Create /var/{lib,log}/ with that user/group if it doesn't exist if [ ! -d /var/lib/${VAR_UG_PKG_NAME} ] ; then mkdir -p /var/lib/${VAR_UG_PKG_NAME}/cache fi chown ${VAR_UG_PKG_NAME}:${VAR_UG_PKG_NAME} /var/lib/${VAR_UG_PKG_NAME} if [ "${VAR_UG_PKG_NAME}" = "nova" ] ; then chmod 755 /var/lib/nova else chmod 0750 /var/lib/${VAR_UG_PKG_NAME} fi if [ ! -d /var/log/${VAR_UG_PKG_NAME} ] ; then mkdir -p /var/log/${VAR_UG_PKG_NAME} fi chown ${VAR_UG_PKG_NAME}:${VAR_UG_PKG_NAME} /var/log/${VAR_UG_PKG_NAME} chmod 0750 /var/log/${VAR_UG_PKG_NAME} } pkgos_init () { INIT_SCRIPT_NAME=${1} if [ -x /etc/init.d/${INIT_SCRIPT_NAME} ] ; then update-rc.d ${INIT_SCRIPT_NAME} defaults >/dev/null invoke-rc.d ${INIT_SCRIPT_NAME} start || true fi } pkgos_get_id () { SERVICE_ENDPOINT=${SERVICE_ENDPOINT:-http://127.0.0.1:35357/v2.0/} SERVICE_TOKEN=${AUTH_TOKEN} "$@" | awk '/ id / { print $4 }' } # Asks the debconf questions for registering a service and its endpoint in keystone # Prototype: pkgos_register_endpoint_config # Example: pkgos_register_endpoint_config glance # To be used in: config pkgos_register_endpoint_config () { local REG_ENDP_PKG_NAME DEFROUTE_IF DEFROUTE_IP REG_ENDP_PKG_NAME=${1} db_input high ${REG_ENDP_PKG_NAME}/register-endpoint || true db_go db_get ${REG_ENDP_PKG_NAME}/register-endpoint if [ "${RET}" = "true" ] ; then db_get ${REG_ENDP_PKG_NAME}/keystone-ip if [ -z "${RET}" ] ; then db_set ${REG_ENDP_PKG_NAME}/keystone-ip 127.0.0.1 fi db_input medium ${REG_ENDP_PKG_NAME}/keystone-ip || true db_input high ${REG_ENDP_PKG_NAME}/keystone-auth-token || true db_get ${REG_ENDP_PKG_NAME}/endpoint-ip || true if [ -z "${RET}" ] ; then DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }'` DEFROUTE_IP=`LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` if [ -n "${DEFROUTE_IP}" ] ; then db_set ${REG_ENDP_PKG_NAME}/endpoint-ip ${DEFROUTE_IP} fi fi db_input medium ${REG_ENDP_PKG_NAME}/endpoint-ip || true db_input medium ${REG_ENDP_PKG_NAME}/region-name || true db_go fi } # Register a service and its endpoint in keystone # Prototype: # Example: pkgos_register_endpoint_postinst glance glance image "Glance Image Service" 9292 /v1 # To be used in: postinst pkgos_register_endpoint_postinst () { local PKG_NAME SERVICE_NAME SERVICE_TYPE SERVICE_DESC SERVICE_PORT SERVICE_URL KEYSTONE_ENDPOINT_IP AUTH_TOKEN PKG_ENDPOINT_IP REGION_NAME PKG_SERVICE_ID PKG_NAME=${1} SERVICE_NAME=${2} SERVICE_TYPE=${3} SERVICE_DESC=${4} SERVICE_PORT=${5} SERVICE_URL=${6} db_get ${PKG_NAME}/register-endpoint if [ "${RET}" = "true" ] ; then db_get ${PKG_NAME}/keystone-ip KEYSTONE_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` db_get ${PKG_NAME}/keystone-auth-token AUTH_TOKEN=${RET} db_get ${PKG_NAME}/endpoint-ip PKG_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` db_get ${PKG_NAME}/region-name REGION_NAME=${RET} if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT_IP}" ] && [ -n "${REGION_NAME}" ] && [ -n "${AUTH_TOKEN}" ] ; then echo "Registering service and endpoints for ${SERVICE_NAME} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}" PKG_SERVICE_ID=$(pkgos_get_id keystone --token ${AUTH_TOKEN} --endpoint http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ service-create \ --name=${SERVICE_NAME} --type=${SERVICE_TYPE} --description="${SERVICE_DESC}") PKG_ENDPOINT_ID=$(pkgos_get_id keystone --token ${AUTH_TOKEN} --endpoint http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ endpoint-create \ --region "${REGION_NAME}" --service_id=${PKG_SERVICE_ID} \ --publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \ --internalurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \ --adminurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}) else echo "Problem in endpoint parameter (IPs or otherwise)." fi # Since there's very little chance a 2nd registration of the # endpoint will be needed, we forget the value of # ${PKG_NAME}/register-endpoint. If later on the # administrator of the server upgrades, it will be asked # again, or eventually, dpkg-reconfigure can # be used. db_unregister ${PKG_NAME}/register-endpoint else echo "Will not register "${SERVICE_NAME}" endpoint this time (no user request for it)." fi # For security reasons, we don't keep the auth-token in the debconf # memory, so we purge it with db_unregister. db_unregister ${PKG_NAME}/keystone-auth-token } openstack-pkg-tools-8/pkgos_insert_include0000755000000000000000000000060112220513746016154 0ustar #!/bin/sh set -e # Example call: pkgos_insert_include pkgos_func keystone.config INC=/usr/share/openstack-pkg-tools/${1} DST=debian/${2} SRC="debian/${2}.in" awk '{if ($1 == "#PKGOS-INCLUDE#") { print "### Start of included " G " library" while ((getline line < F) > 0) print line print "### End of included " G " library" } else print}' F=${INC} G=$(basename $INC) ${SRC} > ${DST} openstack-pkg-tools-8/pkgos.make0000644000000000000000000000706212220513746014006 0ustar # -*- Makefile -*-, you silly Emacs! # vim: set ft=make: DEBVERS ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') VERSION ?= $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//') DEBFLAVOR ?= $(shell dpkg-parsechangelog | grep -E ^Distribution: | cut -d" " -f2) DEBPKGNAME ?= $(shell dpkg-parsechangelog | grep -E ^Source: | cut -d" " -f2) UPSTREAM_GIT ?= git://github.com/openstack/$(DEBPKGNAME).git GIT_TAG ?= $(shell echo '$(VERSION)' | sed -e 's/~/_/') MANIFEST_EXCLUDE_STANDARD ?= $(DEBPKGNAME) DEBIAN_BRANCH ?= $(shell cat debian/gbp.conf | grep debian-branch | cut -d'=' -f2 | awk '{print $1}') # Activate xz compression override_dh_builddeb: dh_builddeb -- -Zxz -z9 # Only use upstart scripts in Ubuntu. All .upstart files have to be renamed .upstart.in # NOTE: this is actually no longer required as the debhelper in wheezy and Ubuntu just # do the right things now but this needs to be retained for compatibility override_dh_installinit: if dpkg-vendor --derives-from ubuntu ; then \ for i in `ls -1 debian/*.upstart.in` ; do \ MYPKG=`echo $$i | sed s/.upstart.in//` ; \ cp $$MYPKG.upstart.in $$MYPKG.upstart ; \ done ; \ fi dh_installinit --error-handler=true gen-author-list: git log --format='%aN <%aE>' | awk '{arr[$$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d' ' -f2- gen-upstream-changelog: git checkout master git reset --hard $(GIT_TAG) git log >$(CURDIR)/../CHANGELOG git checkout debian/$(DEBFLAVOR) mv $(CURDIR)/../CHANGELOG $(CURDIR)/debian/CHANGELOG git add $(CURDIR)/debian/CHANGELOG git commit -a -m "Updated upstream changelog" override_dh_installchangelogs: if [ -e $(CURDIR)/debian/CHANGELOG ] ; then \ dh_installchangelogs $(CURDIR)/debian/CHANGELOG ; \ else \ dh_installchangelogs ; \ fi get-orig-source: uscan --verbose --force-download --rename --destdir=../build-area fetch-upstream-remote: git remote add upstream $(UPSTREAM_GIT) || true git fetch upstream gen-orig-xz: git show $(GIT_TAG) | cat if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] ; then \ git archive --prefix=$(DEBPKGNAME)-$(VERSION)/ $(GIT_TAG) | xz >../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ; \ fi [ ! -e ../build-area ] && mkdir ../build-area || true [ ! -e ../build-area/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] && cp ../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ../build-area get-master-branch: if ! git checkout master ; then \ echo "No upstream branch: checking out" ; \ git checkout -b master upstream/master ; \ fi git checkout $(DEBIAN_BRANCH) get-vcs-source: $(CURDIR)/debian/rules fetch-upstream-remote $(CURDIR)/debian/rules gen-orig-xz $(CURDIR)/debian/rules get-master-branch versioninfo: echo $(VERSION) > versioninfo display-po-stats: cd $(CURDIR)/debian/po ; for i in *.po ; do \ echo -n $$i": " ; \ msgfmt -o /dev/null --statistic $$i ; \ done call-for-po-trans: podebconf-report-po --call --withtranslators --languageteam regen-manifest-patch: quilt pop -a || true quilt push install-missing-files.patch git checkout MANIFEST.in git ls-files --no-empty-directory --exclude-standard $(MANIFEST_EXCLUDE_STANDARD) | grep -v '.py$$' | grep -v LICENSE | sed -n 's/.*/include &/gp' >> MANIFEST.in quilt refresh quilt pop -a override_dh_gencontrol: if dpkg-vendor --derives-from ubuntu ; then \ dh_gencontrol -- -T$(CURDIR)/debian/ubuntu_control_vars ; \ else \ dh_gencontrol -- -T$(CURDIR)/debian/debian_control_vars ; \ fi .PHONY: get-vcs-source get-orig-source override_dh_installinit override_dh_builddeb regen-manifest-patch call-for-po-trans display-po-stats versioninfo