├── .gitreview ├── build-tools ├── pkgos-bb ├── pkgos-bop ├── pkgos-bop-jenkins ├── pkgos-scan-repo └── pkgos-setup-sbuild ├── debian ├── changelog ├── compat ├── control ├── copyright ├── gbp.conf ├── openstack-pkg-tools.install ├── rules └── source │ └── format ├── etc └── pkgos │ ├── build-list │ ├── packages-list │ ├── experimental-branch │ ├── openstack-release-branch │ └── pkg-javascript-repo │ ├── pkgos.conf │ └── substitute ├── init-template ├── init-script-template ├── pkgos-gen-systemd-unit └── pkgos-gen-upstart-job ├── misc ├── openstack.profile ├── pkgos-alioth-new-git ├── pkgos-alternative-bin ├── pkgos-debpypi ├── pkgos-fetch-fake-repo ├── pkgos-parse-requirements ├── pkgos-reqsdiff ├── pkgos-show-control-depends └── pkgos-testr ├── pkgos.make ├── pkgos_func └── pkgos_insert_include /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=review.opendev.org 3 | port=29418 4 | project=openstack/deb-openstack-pkg-tools.git 5 | defaultbranch=debian/liberty 6 | -------------------------------------------------------------------------------- /build-tools/pkgos-bb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 7 | echo "Could not read /etc/pkgos/pkgos.conf" 8 | exit 1 9 | else 10 | . /etc/pkgos/pkgos.conf 11 | fi 12 | 13 | # Manage parameters of this script 14 | usage () { 15 | echo "Usage: $0 [-u] [-d ]" 16 | echo " -u: Upload to the defined Debian repository" 17 | echo " -d : Define from which distro to backport" 18 | exit 1 19 | } 20 | 21 | UPLOAD=no 22 | SRC_DISTRO=sid 23 | for i in $@ ; do 24 | case ${1} in 25 | "-u") 26 | UPLOAD=yes 27 | shift 28 | ;; 29 | "-d") 30 | if [ -z "${2}" ] || [ -z "${3}" ] ; then usage ; fi 31 | SRC_DISTRO=${2} 32 | shift 33 | shift 34 | ;; 35 | *) 36 | ;; 37 | esac 38 | done 39 | 40 | if [ -z "${1}" ] ; then usage ; fi 41 | 42 | PKG_NAME=${1} 43 | 44 | # Double-guessing some stuffs 45 | if [ `whoami` = "jenkins" ] ; then 46 | BUILD_ROOT=/var/lib/jenkins/backports/${BUILD_NUMBER} 47 | else 48 | BUILD_ROOT=~/src/os-bpo 49 | fi 50 | 51 | 52 | # Get info from packages.debian.org 53 | PKG_INFO_FILE=`mktemp -t pkg_info_file.XXXXXX` 54 | wget --no-check-certificate -O ${PKG_INFO_FILE} http://packages.debian.org/${SRC_DISTRO}/${PKG_NAME} 55 | DEB_VERSION=`rmadison --suite=${SRC_DISTRO} ${PKG_NAME} | grep -E 'amd64|all' | awk '{print $3}'` 56 | UPSTREAM_VERSION=`echo ${DEB_VERSION} | cut -d'-' -f1 | cut -d":" -f2` 57 | DSC_URL=`cat ${PKG_INFO_FILE} | grep dsc | cut -d'"' -f2` 58 | rm ${PKG_INFO_FILE} 59 | 60 | # Prepare build folder and go in it 61 | MY_CWD=`pwd` 62 | rm -rf ${BUILD_ROOT}/$PKG_NAME 63 | mkdir -p ${BUILD_ROOT}/$PKG_NAME 64 | cd ${BUILD_ROOT}/$PKG_NAME 65 | 66 | # Download the .dsc and extract it 67 | dget -d -u ${DSC_URL} 68 | PKG_SRC_NAME=`ls *.dsc | cut -d_ -f1` 69 | PKG_NAME_FIRST_CHAR=`echo ${PKG_SRC_NAME} | awk '{print substr($0,1,1)}'` 70 | 71 | # Guess source package name using an ls of the downloaded .dsc file 72 | DSC_FILE=`ls *.dsc` 73 | DSC_FILE=`basename $DSC_FILE` 74 | SOURCE_NAME=`echo $DSC_FILE | cut -d_ -f1` 75 | 76 | # Rename the build folder if the source package name is different from binary 77 | if ! [ "${PKG_NAME}" = "${SOURCE_NAME}" ] ; then 78 | cd .. 79 | rm -rf $SOURCE_NAME 80 | mv $PKG_NAME $SOURCE_NAME 81 | cd $SOURCE_NAME 82 | fi 83 | 84 | # Extract the source and make it a backport 85 | dpkg-source -x *.dsc 86 | cd ${SOURCE_NAME}-${UPSTREAM_VERSION} 87 | dch --newversion ${DEB_VERSION}~${BPO_POSTFIX} -b --allow-lower-version --distribution ${TARGET_DISTRO}-backports -m "Rebuilt for ${TARGET_DISTRO}." 88 | 89 | # Build the package 90 | sbuild 91 | 92 | # Copy in the FTP repo 93 | cd .. 94 | rm ${SOURCE_NAME}_${DEB_VERSION}~${BPO_POSTFIX}_amd64.build 95 | TARGET_FTP_FOLDER=${REPO_ROOT}/debian/pool/${REPO_NOCHANGE_BACKPORT_DEST}/main/${PKG_NAME_FIRST_CHAR}/$SOURCE_NAME 96 | rm -rf ${TARGET_FTP_FOLDER} 97 | mkdir -p ${TARGET_FTP_FOLDER} 98 | cp *bpo* *.orig.tar.* ${TARGET_FTP_FOLDER} 99 | 100 | # Update the archive and the sbuild chroot 101 | pkgos-scan-repo ${REPO_NOCHANGE_BACKPORT_DEST} 102 | 103 | # Uploading to FTP 104 | if [ "${UPLOAD}" = "yes" ] ; then 105 | REMOTE_FOLDER=/home/ftp/debian/pool/${SCP_DEST_SUITE}/main/${PKG_NAME_FIRST_CHAR}/$SOURCE_NAME 106 | ssh ${SCP_DEST_HOST} "mkdir -p ${REMOTE_FOLDER}" 107 | scp *bpo* *.orig.tar.* ${SCP_DEST_HOST}:${REMOTE_FOLDER} 108 | fi 109 | -------------------------------------------------------------------------------- /build-tools/pkgos-bop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build an OpenStack team's package and write it in /home/ftp 3 | 4 | set -e 5 | 6 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 7 | echo "Could not read /etc/pkgos/pkgos.conf" 8 | exit 1 9 | else 10 | . /etc/pkgos/pkgos.conf 11 | fi 12 | 13 | # Some quick calculation 14 | BPO_DISTRO_NUM=~bpo${TARGET_DISTRO_NUM}+1 15 | if [ `uname -m` = "x86_64" ] ; then 16 | BOP_BUILD_ARCH=amd64 17 | else 18 | echo "Arch not supported: exiting." 19 | exit 1 20 | fi 21 | 22 | cleanup_old_build () { 23 | echo "===> Cleaning-up old builds" 24 | rm -rf ../*.orig.tar.xz ../*.orig.tar.gz ../build-area 25 | } 26 | 27 | # Finds the current version of the package 28 | get_deb_version() { 29 | PKG_NAME=`dpkg-parsechangelog | grep -E "^Source:" | cut -d" " -f2` 30 | DEB_VERS=`dpkg-parsechangelog | grep -E "^Version: " | cut -d" " -f2` 31 | NO_EPOC=`echo ${DEB_VERS} | cut -d":" -f2` 32 | UPSTREAM_VERS=`echo ${NO_EPOC} | cut -d"-" -f1` 33 | if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi 34 | ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz 35 | CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes 36 | PKG_NAME_FIRST_CHAR=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'` 37 | } 38 | 39 | create_orig_tar () { 40 | if grep pristine-tar debian/gbp.conf | grep -q -i true ; then 41 | echo "Nothing special to do with Pristine tar: not generating orig file!" 42 | else 43 | if [ "${IS_NATIVE}" = "no" ] ; then 44 | COMPRESSION_TYPE=xz 45 | if [ -r debian/gbp.conf ] ; then 46 | COMPRESSION_IN_FILE=`cat debian/gbp.conf | grep compression | cut -d'=' -f2 | awk '{print $1}'` 47 | if [ "${COMPRESSION_IN_FILE}" = "gz" ] ; then 48 | COMPRESSION_TYPE=gz 49 | elif [ "${COMPRESSION_IN_FILE}" = "bzip2" ] ; then 50 | COMPRESSION_TYPE=bzip2 51 | fi 52 | fi 53 | if [ "${COMPRESSION_TYPE}" = "gz" ] ; then 54 | ./debian/rules gen-orig-gz 55 | elif [ "${COMPRESSION_TYPE}" = "bzip2" ] ; then 56 | ./debian/rules gen-orig-bz2 57 | else 58 | ./debian/rules gen-orig-xz 59 | fi 60 | fi 61 | fi 62 | } 63 | 64 | bop_it () { 65 | echo "===> Building using git-buildpackage" 66 | LAST_GIT_COMMIT=`git log | head -n 1 | awk '{print $2}'` 67 | dch --newversion ${DEB_VERS}${BPO_DISTRO_NUM} -b --allow-lower-version -m "Rebuilt by bop." 68 | git commit debian/changelog -m "Rebuilt by bop." 69 | if ! git-buildpackage ; then 70 | git reset --hard ${LAST_GIT_COMMIT} 71 | echo "There was an error when bop called git-buildpackage: exiting." 72 | exit 1 73 | else 74 | git reset --hard ${LAST_GIT_COMMIT} 75 | fi 76 | } 77 | 78 | test_the_package () { 79 | lintian -I -E --pedantic --profile debian/openstack ../build-area/*.changes 80 | } 81 | 82 | copy_to_ftparchive () { 83 | echo "===> Copying to the FTP repo" 84 | rm ../build-area/${PKG_NAME}_${NO_EPOC}${BPO_DISTRO_NUM}_amd64.build 85 | TARGET_FOLDER=${REPO_ROOT}/debian/pool/${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports/main/${PKG_NAME_FIRST_CHAR}/${PKG_NAME} 86 | rm -rf ${TARGET_FOLDER} 87 | mkdir -p ${TARGET_FOLDER} 88 | cp ../build-area/* ${TARGET_FOLDER} 89 | } 90 | 91 | cleanup_old_build 92 | get_deb_version 93 | create_orig_tar 94 | bop_it 95 | test_the_package 96 | copy_to_ftparchive 97 | # Scan the repo to add the new package 98 | pkgos-scan-repo 99 | -------------------------------------------------------------------------------- /build-tools/pkgos-bop-jenkins: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | . /etc/pkgos/pkgos.conf 7 | 8 | PKG_NAME=${1} 9 | 10 | ARCH=i386 ; if [ `uname -m` = "x86_64" ] ; then ARCH=amd64 ; fi 11 | if ! [ `whoami` = "root" ] ; then SU=sudo ; fi 12 | 13 | ################################# 14 | # Define some utility functions # 15 | ################################# 16 | # Is the package from the pkgs-js group? 17 | is_pkg_js () { 18 | ISPKGJS="no" 19 | for i in $PKG_JS ; do 20 | if [ "${i}" = "${PKG_NAME}" ] ; then 21 | ISPKGJS="yes" 22 | fi 23 | done 24 | } 25 | 26 | # Is the package maintained on a debian/ branch? 27 | is_core () { 28 | ISCORE="no" 29 | for i in $OSTACK_PKGS ; do 30 | if [ "${i}" = "${PKG_NAME}" ] ; then 31 | ISCORE="yes" 32 | return 33 | fi 34 | done 35 | } 36 | 37 | # Is the package maintained on a debian/experimental branch? 38 | is_experi () { 39 | ISEXPERI="no" 40 | for i in ${EXPERIMENTAL_BRANCH} ; do 41 | if [ "${i}" = "${PKG_NAME}" ] ; then 42 | ISEXPERI="yes" 43 | return 44 | fi 45 | done 46 | } 47 | 48 | # Get some version information out of the debian/changelog last entry 49 | get_deb_version() { 50 | PKG_NAME=`dpkg-parsechangelog | grep -E "^Source:" | cut -d" " -f2` 51 | DEB_VERS=`dpkg-parsechangelog | grep -E "^Version: " | cut -d" " -f2` 52 | NO_EPOC=`echo ${DEB_VERS} | cut -d":" -f2` 53 | UPSTREAM_VERS=`echo ${NO_EPOC} | cut -d"-" -f1` 54 | if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi 55 | ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz 56 | CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes 57 | PKG_NAME_FIRST_CHAR=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'` 58 | } 59 | 60 | ############################## 61 | # Start of the actual script # 62 | ############################## 63 | MY_CWD=`pwd` 64 | 65 | # Go in the build dir and make sure it's cleaned 66 | BUILD_ROOT=/var/lib/jenkins/jobs/${PKG_NAME}/builds/${BUILD_NUMBER} 67 | rm -rf ${BUILD_ROOT}/$PKG_NAME 68 | mkdir -p ${BUILD_ROOT}/$PKG_NAME 69 | cd ${BUILD_ROOT}/$PKG_NAME 70 | 71 | # "git clone" the package from the correct repo (either pkg-javascript or openstack) 72 | is_pkg_js 73 | if [ "${ISPKGJS}" = "yes" ] ; then 74 | git clone ${CLONE_URL_PKGJS}/${PKG_NAME}.git 75 | else 76 | git clone ${CLONE_URL_BASE}/${PKG_NAME}.git 77 | fi 78 | cd $PKG_NAME 79 | 80 | # Checkout the correct branch(es) before building 81 | PRIS=$(grep pristine-tar debian/gbp.conf | awk '{print $1}') 82 | if [ "${PRIS}" = "pristine-tar" ] ; then 83 | PRIS_VAL=$(grep pristine-tar debian/gbp.conf | cut -d'=' -f2 | awk '{print $1}') 84 | if [ "${PRIS_VAL}" = "False" ] ; then 85 | PRIS="none" 86 | fi 87 | fi 88 | if [ "${PRIS}" = "pristine-tar" ] ; then 89 | # If it's a pristine-tar package, checkout the pristine-tar and upstream-unstable branches 90 | git checkout -b pristine-tar origin/pristine-tar 91 | git checkout -b upstream-unstable origin/upstream-unstable 92 | is_experi 93 | if [ "${ISEXPERI}" = "yes" ] ; then 94 | git checkout -b debian-experimental origin/debian-experimental 95 | else 96 | git checkout debian-unstable 97 | fi 98 | get_deb_version 99 | else 100 | is_core 101 | if [ "${ISCORE}" = "yes" ] ; then 102 | # If it's a core package, listed in OSTACK_PKGS in /etc/pkgos/pkgos.conf 103 | # then we use debian/juno, debian/kilo, etc. as packaging branch. 104 | git checkout -b debian/${TARGET_OPENSTACK_REL} origin/debian/${TARGET_OPENSTACK_REL} || true 105 | else 106 | # If it's listed as EXPERIMENTAL_BRANCH in /etc/pkgos/pkgos.conf, then we 107 | # use debian/experimental branch. 108 | is_experi 109 | if [ "${ISEXPERI}" = "yes" ] ; then 110 | CURBRANCH=`git branch | grep '*' | cut -d' ' -f2` 111 | if [ "${CURBRANCH}" = "debian/experimental" ] ; then 112 | echo "Already on debian/experimental" 113 | else 114 | git checkout -b debian/experimental origin/debian/experimental 115 | fi 116 | else 117 | git checkout -b ${DEBIAN_BRANCH} origin/${DEBIAN_BRANCH} || true 118 | fi 119 | fi 120 | get_deb_version 121 | # Generate the .orig.tar.xz using git archive... 122 | if [ "${IS_NATIVE}" = "no" ] ; then 123 | ./debian/rules gen-orig-xz 124 | fi 125 | fi 126 | 127 | # Build the package using sbuild (see that script, which can be used 128 | # in your own laptop if you don't want to use jenkins...) 129 | pkgos-bop 130 | -------------------------------------------------------------------------------- /build-tools/pkgos-scan-repo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | #set -x 5 | 6 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 7 | echo "Could not read /etc/pkgos/pkgos.conf" 8 | exit 1 9 | else 10 | . /etc/pkgos/pkgos.conf 11 | fi 12 | 13 | # It's possible to give the repo name as parameter 14 | if [ -n "${1}" ] ; then 15 | REPO_DEST=${1} 16 | fi 17 | 18 | # Scan the repo 19 | scan_repo() { 20 | echo "===> Scanning ${REPO_ROOT} for packages in ${REPO_DEST} with arch ${SCAN_ARCHES}" 21 | local MYCUR_DIR 22 | MYCURDIR=`pwd` 23 | cd ${REPO_ROOT}/debian 24 | for i in ${SCAN_ARCHES} ; do 25 | mkdir -p dists/${REPO_DEST}/main/binary-${i} 26 | dpkg-scanpackages -a ${i} pool/${REPO_DEST}/main /dev/null > dists/${REPO_DEST}/main/binary-${i}/Packages 27 | gzip -c dists/${REPO_DEST}/main/binary-${i}/Packages >dists/${REPO_DEST}/main/binary-${i}/Packages.gz 28 | bzip2 -f -k dists/${REPO_DEST}/main/binary-${i}/Packages 29 | done 30 | mkdir -p dists/${REPO_DEST}/main/source 31 | dpkg-scansources pool/${REPO_DEST}/main /dev/null >dists/${REPO_DEST}/main/source/Sources 32 | gzip -c dists/${REPO_DEST}/main/source/Sources >dists/${REPO_DEST}/main/source/Sources.gz 33 | bzip2 -f -k dists/${REPO_DEST}/main/source/Sources 34 | cd dists/${REPO_DEST} 35 | rm -f Release Release.gpg 36 | TMPFILE=`mktemp -t pkgos_scan.XXXXXX` 37 | apt-ftparchive release . -o APT::FTPArchive::Release::Origin="Mirantis" -o APT::FTPArchive::Release::Codename="${REPO_DEST}" > ${TMPFILE} 38 | mv ${TMPFILE} ./Release 39 | gpg -abs -o Release.gpg Release 40 | chmod +r Release Release.gpg 41 | cd ${MYCURDIR} 42 | } 43 | 44 | scan_repo 45 | for i in ${SCAN_ARCHES} ; do 46 | echo "===> Updating schroot ${TARGET_DISTRO}-${i}" 47 | sudo sbuild-update -udcar ${TARGET_DISTRO}-${i} 48 | done 49 | -------------------------------------------------------------------------------- /build-tools/pkgos-setup-sbuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | ################################# 7 | # AUTOMATICALLY DETECT ENV HERE # 8 | ################################# 9 | 10 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 11 | echo "Could not read /etc/pkgos/pkgos.conf" 12 | exit 1 13 | else 14 | . /etc/pkgos/pkgos.conf 15 | fi 16 | 17 | detect_env () { 18 | DEB_RELEASE=`lsb_release -a | grep Codename: | awk '{print $2}'` 19 | DEB_RELEASE_NUM=`lsb_release -a | grep Release: | awk '{print $2}'` 20 | APT="apt-get install -y" 21 | echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/80norecommends 22 | } 23 | 24 | configure_hostname () { 25 | DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }' | cut -d" " -f1` 26 | if [ -n "${DEFROUTE_IF}" ] ; then 27 | 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}$'` 28 | if [ -n "${DEFROUTE_IP}" ] ; then 29 | echo "Detected IP: ${DEFROUTE_IP}" 30 | echo "127.0.0.1 localhost.localdomain localhost 31 | ${DEFROUTE_IP} ${HOST_FQDN} ${TARGET_OPENSTACK_REL}-${TARGET_DISTRO} 32 | 33 | # The following lines are desirable for IPv6 capable hosts 34 | ::1 ip6-localhost ip6-loopback 35 | fe00::0 ip6-localnet 36 | ff00::0 ip6-mcastprefix 37 | ff02::1 ip6-allnodes 38 | ff02::2 ip6-allrouters 39 | ff02::3 ip6-allhosts 40 | " >/etc/hosts 41 | fi 42 | fi 43 | echo $HOST_FQDN >/etc/hostname 44 | hostname `cat /etc/hostname` 45 | } 46 | 47 | install_all_software () { 48 | ${APT} linux-image-amd64 sbuild apache2 screen joe apache2 pure-ftpd ftp most \ 49 | man-db git-buildpackage debhelper eatmydata build-essential python-setuptools \ 50 | fakeroot python3-all python-all python3-setuptools pristine-tar dh-autoreconf ssl-cert \ 51 | dh-python dh-systemd python-sphinx sudo debootstrap openstack-pkg-tools \ 52 | lintian lsb-release postfix gem2deb 53 | if [ "${DEV_OR_JENKINS}" = "jenkins" ] ; then 54 | ${APT} jenkins jenkins-job-builder jenkins-cli 55 | fi 56 | } 57 | 58 | configure_apache () { 59 | a2enmod proxy 60 | a2enmod proxy_http 61 | a2enmod ssl 62 | a2enmod headers 63 | if [ "${DEB_RELEASE}" = "precise" ] ; then 64 | APACHE_SSL_VHOST_CONF=default-ssl 65 | FORWARD_TO_ADDR=ip6-localhost 66 | DEFAULT_SITE=default 67 | DEFAULT_SSL_SITE=default-ssl 68 | elif [ "${DEB_RELEASE}" = "wheezy" ] ; then 69 | APACHE_SSL_VHOST_CONF=default-ssl 70 | FORWARD_TO_ADDR=localhost 71 | DEFAULT_SITE=default 72 | DEFAULT_SSL_SITE=default-ssl 73 | else 74 | APACHE_SSL_VHOST_CONF=default-ssl.conf 75 | FORWARD_TO_ADDR=localhost 76 | DEFAULT_SITE=000-default.conf 77 | DEFAULT_SSL_SITE=default-ssl.conf 78 | fi 79 | a2ensite ${DEFAULT_SSL_SITE} 80 | APACHE_SSL_VHOST_CONF_FULL_PATH=/etc/apache2/sites-available/${APACHE_SSL_VHOST_CONF} 81 | echo " 82 | 83 | ServerAdmin webmaster@localhost 84 | ErrorLog \${APACHE_LOG_DIR}/error.log 85 | CustomLog \${APACHE_LOG_DIR}/access.log combined 86 | 87 | SSLEngine on 88 | SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem 89 | SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key 90 | 91 | 92 | SSLOptions +StdEnvVars 93 | 94 | 95 | SSLOptions +StdEnvVars 96 | 97 | 98 | # Jenkins proxy (and reverse) 99 | ProxyPass / http://${FORWARD_TO_ADDR}:8080/ nocanon 100 | ProxyPassReverse / http://${FORWARD_TO_ADDR}:8080/ 101 | ProxyRequests Off 102 | AllowEncodedSlashes NoDecode 103 | Header edit Location ^http://${HOST_FQDN}/ https://${HOST_FQDN}/ 104 | RequestHeader set X-Forwarded-Proto \"https\" 105 | RequestHeader set X-Forwarded-Port \"443\" 106 | ProxyPreserveHost on 107 | SetOutputFilter INFLATE;proxy-html;DEFLATE 108 | SetEnv proxy-nokeepalive 1 109 | 110 | ServerAdmin webmaster@localhost 111 | 112 | 113 | " >${APACHE_SSL_VHOST_CONF_FULL_PATH} 114 | a2ensite ${APACHE_SSL_VHOST_CONF} 115 | invoke-rc.d apache2 restart 116 | if [ ! -e /var/www/html/debian ] && [ ! -h /var/www/html/debian ] ; then 117 | ln -s /home/ftp/debian /var/www/html/debian 118 | fi 119 | } 120 | 121 | configure_pure () { 122 | if getent passwd ftp >/dev/null ; then 123 | echo "FTP user already existing" 124 | else 125 | /usr/sbin/useradd -m ftp 126 | fi 127 | chown ${THE_DEV_USER}:${THE_DEV_USER} /home/ftp 128 | rm -f /etc/pure-ftpd/conf/NoAnonymous 129 | invoke-rc.d pure-ftpd stop 130 | sleep 2 131 | invoke-rc.d pure-ftpd start 132 | } 133 | 134 | install_jenkins_plugins () { 135 | jenkins-cli -s https://${HOST_FQDN}/ -noCertificateCheck install-plugin instant-messaging 136 | jenkins-cli -s https://${HOST_FQDN}/ -noCertificateCheck install-plugin ircbot 137 | } 138 | 139 | configure_jenkins_dotgitconfig () { 140 | echo "[user] 141 | email = zigo@debian.org 142 | name = Thomas Goirand 143 | [gitreview] 144 | username = thomas-goirand 145 | [alias] 146 | wdiff = diff --color-words 147 | wshow = show --color-words 148 | [color] 149 | ui = true" >/var/lib/jenkins/.gitconfig 150 | } 151 | 152 | configure_jenkins_sudoers () { 153 | echo "jenkins ALL = NOPASSWD: /usr/bin/sbuild-update -udcar ${TARGET_DISTRO}-amd64" >/etc/sudoers.d/jenkins 154 | chmod 440 /etc/sudoers.d/jenkins 155 | } 156 | 157 | # @param: $1 homedir of the GPG user 158 | gen_the_dev_user_gpg_key () { 159 | GPG_USER_HOMEDIR=${1} 160 | mkdir -p ${GPG_USER_HOMEDIR}/.gnupg 161 | chmod 700 ${GPG_USER_HOMEDIR}/.gnupg 162 | chmod 700 ${GPG_USER_HOMEDIR}/.gnupg 163 | if ! [ -r ${GPG_USER_HOMEDIR}/.gnupg/gpg.conf ] ; then 164 | echo "keyserver hkp://pool.sks-keyservers.net 165 | personal-digest-preferences SHA256 166 | default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed 167 | cert-digest-algo SHA256 168 | " >${GPG_USER_HOMEDIR}/.gnupg/gpg.conf 169 | fi 170 | if ! [ -r ${GPG_USER_HOMEDIR}/.gnupg/pkgos-gen-key-batchfile ] ; then 171 | echo " 172 | %echo Generating a basic OpenPGP key 173 | Key-Type: RSA 174 | Key-Length: 4096 175 | Name-Real: Autogenerated key 176 | Name-Email: ${THE_DEV_USER}@"`hostname --fqdn`" 177 | Expire-Date: 0 178 | " >${GPG_USER_HOMEDIR}/.gnupg/pkgos-gen-key-batchfile 179 | fi 180 | chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${GPG_USER_HOMEDIR}/.gnupg 181 | su ${THE_DEV_USER} -c 'gpg --gen-key --batch '${GPG_USER_HOMEDIR}'/.gnupg/pkgos-gen-key-batchfile' 182 | } 183 | 184 | configure_jenkins_gpg_key () { 185 | # Generate a self-signed gpg key so that we can sign packages 186 | if ! [ -e /var/lib/jenkins/.gnupg/secring.gpg ] ; then 187 | gen_the_dev_user_gpg_key /var/lib/jenkins 188 | fi 189 | } 190 | 191 | 192 | check_user_gpg_key () { 193 | if ! [ -d /home/${THE_DEV_USER}/.gnupg ] ; then 194 | echo "There's no /home/${THE_DEV_USER}/.gnupg folder," 195 | echo "do you want this script to generate one? If you" 196 | echo "don't, the script will exit." 197 | echo -n "Generate a GPG key (Y/n)?" 198 | read GEN_KEY 199 | if [ -z "${GEN_KEY}" ] || [ "${GEN_KEY}" = "y" ] || [ "${GEN_KEY}" = "Y" ] ; then 200 | echo "Genrating a gpg key for you..." 201 | gen_the_dev_user_gpg_key /home/${THE_DEV_USER} 202 | else 203 | echo "No gpg key: exiting..." 204 | exit 1 205 | fi 206 | fi 207 | GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2 | head -n 1") 208 | if [ -z "${GPG_KEY_ID}" ] ; then 209 | echo "Cloud not find key ID, but there's a /home/${THE_DEV_USER}/.gnupg" 210 | echo -n "Generate a GPG key (Y/n)?" 211 | read GEN_KEY 212 | if [ -z "${GEN_KEY}" ] || [ "${GEN_KEY}" = "y" ] || [ "${GEN_KEY}" = "Y" ] ; then 213 | echo "Genrating a gpg key for you..." 214 | gen_the_dev_user_gpg_key /home/${THE_DEV_USER} 215 | else 216 | echo "No gpg key: exiting..." 217 | exit 1 218 | fi 219 | fi 220 | GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2 | head -n 1") 221 | echo "===> Key ID: ${GPG_KEY_ID}" 222 | } 223 | 224 | build_ostack_archive_keyring_package () { 225 | # Export the jenkins GPG key as pubkey.gpg in debian/dists/pubkey.gpg 226 | mkdir -p ${REPO_ROOT}/debian/dists 227 | chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian/dists 228 | chown ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian 229 | su ${THE_DEV_USER} -c "gpg --export -a ${THE_DEV_USER}" >${REPO_ROOT}/debian/dists/pubkey.gpg 230 | # Create a Debian package out of it, called openstack-debian-archive-keyring 231 | # and put it in the newly created Debian repository. 232 | # Yes, a working, Debian-policy-compliant package is really only a few lines of shell... :) 233 | TMPDIR=`mktemp -d` 234 | MYCWD=`pwd` 235 | cd ${TMPDIR} 236 | chown ${THE_DEV_USER}:${THE_DEV_USER} . 237 | VER=0.1 238 | NAME=${TARGET_OPENSTACK_REL}-${TARGET_DISTRO}-archive-keyring 239 | rm -rf ${NAME}-${VER} 240 | mkdir -p ${NAME}-${VER}/debian/source 241 | cd ${NAME}-${VER} 242 | export DEBFULLNAME="Debian OpenStack Jenkins" 243 | export DEBEMAIL="${THE_DEV_USER}@${HOST_FQDN}" 244 | dch --create --package ${NAME} -D unstable --noquery --newversion 0.1 -m "Automatic archive package build." 245 | sed -i 's/MAINTAINER /Debian OpenStack <'${THE_DEV_USER}'@'${HOST_FQDN}'>/' debian/changelog 246 | echo "3.0 (native)" >debian/source/format 247 | echo 9 >debian/compat 248 | echo "#!/usr/bin/make -f 249 | %: 250 | dh \$@ 251 | " >debian/rules 252 | echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 253 | Upstream-Name: ${NAME} 254 | Source: See the openstack-pkg-tools package 255 | 256 | Files: * 257 | Copyright: (c) 2015, Thomas Goirand 258 | License: Apache-2 259 | Licensed under the Apache License, Version 2.0 (the \"License\"); 260 | you may not use this file except in compliance with the License. 261 | You may obtain a copy of the License at 262 | . 263 | http://www.apache.org/licenses/LICENSE-2.0 264 | . 265 | Unless required by applicable law or agreed to in writing, software 266 | distributed under the License is distributed on an \"AS IS\" BASIS, 267 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 268 | See the License for the specific language governing permissions and 269 | limitations under the License. 270 | . 271 | On Debian-based systems the full text of the Apache version 2.0 license 272 | can be found in /usr/share/common-licenses/Apache-2.0. 273 | " >debian/copyright 274 | echo "Source: ${NAME} 275 | Section: net 276 | Priority: extra 277 | Maintainer: PKG OpenStack 278 | Uploaders: Thomas Goirand 279 | Build-Depends: debhelper (>= 9) 280 | Standards-Version: 3.9.6 281 | 282 | Package: ${NAME} 283 | Architecture: all 284 | Depends: \${misc:Depends} 285 | Description: OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring 286 | OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring 287 | ">debian/control 288 | cp ${REPO_ROOT}/debian/dists/pubkey.gpg . 289 | echo "pubkey.gpg /usr/share/${NAME}" >debian/${NAME}.install 290 | echo "#!/bin/sh 291 | set -e 292 | 293 | if [ \"\$1\" = \"configure\" ] || [ \"\$1\" = \"reconfigure\" ] ; then 294 | apt-key add /usr/share/${NAME}/pubkey.gpg 295 | fi 296 | 297 | #DEBHELPER# 298 | 299 | exit 0 300 | " >debian/${NAME}.postinst 301 | chown -R ${THE_DEV_USER}:${THE_DEV_USER} . 302 | su ${THE_DEV_USER} -c dpkg-buildpackage || true 303 | FIRST_LETTER=`echo ${TARGET_OPENSTACK_REL} | awk '{print substr($0,0,2)}'` 304 | cd .. 305 | MYDEST=${REPO_ROOT}/debian/pool/${REPO_DEST}/main/${FIRST_LETTER}/${NAME} 306 | MYDEST2=${REPO_ROOT}/debian/pool/${REPO_NOCHANGE_BACKPORT_DEST}/main/${FIRST_LETTER}/${NAME} 307 | for i in ${MYDEST} ${MYDEST2} ; do 308 | su ${THE_DEV_USER} -c "mkdir -p ${i}" 309 | cp *.changes *.tar.xz *.deb *.dsc ${i} 310 | chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${i} 311 | done 312 | cd ${MYCWD} 313 | rm -r ${TMPDIR} 314 | } 315 | 316 | configure_sbuildrc () { 317 | GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2") 318 | DOT_SBUILDRC_PATH=${THE_USER_HOMEDIR}/.sbuildrc 319 | if ! [ -r "${DOT_SBUILDRC_PATH}" ] ; then 320 | echo "# don't remove this, Perl needs it: 321 | 322 | \$build_arch_all = 1; 323 | \$build_source = 1; 324 | \$distribution = '"${TARGET_DISTRO}"'; 325 | \$run_lintian = 0; 326 | 327 | # Don't sign packages: 328 | #\$pgp_options = '-us -uc'; 329 | 330 | # FIX THIS !!! 331 | \$key_id = '${GPG_KEY_ID}'; 332 | 333 | 1; 334 | " >${DOT_SBUILDRC_PATH} 335 | fi 336 | } 337 | 338 | configure_sbuild () { 339 | # Setup the gpg key for sbuild 340 | mkdir -p /root/.gnupg 341 | chmod 600 /root/.gnupg 342 | gpg --list-keys 343 | sbuild-update --keygen 344 | 345 | # Add jenkins as a sbuild user 346 | sbuild-adduser ${THE_DEV_USER} 347 | 348 | # Create the actual schroot env 349 | if ! [ -e /var/lib/sbuild/${TARGET_DISTRO}-amd64.tar.gz ] ; then 350 | sbuild-createchroot --make-sbuild-tarball=/var/lib/sbuild/${TARGET_DISTRO}-amd64.tar.gz ${TARGET_DISTRO} `mktemp -d` ${CLOSEST_DEBIAN_MIRROR} 351 | fi 352 | 353 | # Make sure git-buildpackage is using sbuild 354 | sed -i 's/^[ #\t]*builder[ #\t]*=.*/builder = sbuild -v --no-apt-update/' /etc/git-buildpackage/gbp.conf 355 | sed -i 's/^[ #\t]*cleaner[ #\t]*=.*/cleaner = \/bin\/true/' /etc/git-buildpackage/gbp.conf 356 | 357 | # Make sure that /dev/shm is mounted in the chroot, otherwise anything which 358 | # uses /dev/shm (like python-taskflow, etc.) will fail to build 359 | sed -i 's|#/dev/shm|/dev/shm|' /etc/schroot/default/fstab 360 | 361 | # Install the juno-jessie-archive-keyring package in the repository 362 | FIRST_LETTER=`echo ${TARGET_OPENSTACK_REL} | awk '{print substr($0,0,2)}'` 363 | NAME=${TARGET_OPENSTACK_REL}-${TARGET_DISTRO}-archive-keyring 364 | VERS=0.1 365 | MYPKG_FILE_NAME=${NAME}_0.1_all.deb 366 | LOCATION=debian/pool/${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports/main/${FIRST_LETTER}/${NAME}/${MYPKG_FILE_NAME} 367 | schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- apt-get install -y wget 368 | schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- wget http://localhost/${LOCATION} 369 | schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- dpkg -i ${MYPKG_FILE_NAME} 370 | 371 | # Since we have already a first package (the archive-keyring one), 372 | # let's scan the tree in /home/ftp/debian/pool, and build a valid Debian repo 373 | 374 | MYCWD=`pwd` 375 | cd ${THE_USER_HOMEDIR} 376 | su ${THE_DEV_USER} -c pkgos-scan-repo 377 | su ${THE_DEV_USER} -c pkgos-scan-repo ${REPO_NOCHANGE_BACKPORT_DEST} 378 | cd ${MYCWD} 379 | 380 | # Add a hook to have both our repositories used inside the sbuild chroot 381 | echo "#!/bin/sh 382 | 383 | set -e 384 | 385 | . \"\$SETUP_DATA_DIR/common-data\" 386 | . \"\$SETUP_DATA_DIR/common-functions\" 387 | . \"\$SETUP_DATA_DIR/common-config\" 388 | 389 | if [ \$STAGE = \"setup-start\" ] || [ \$STAGE = \"setup-recover\" ]; then 390 | echo \"deb http://localhost/debian ${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports main\" >\${CHROOT_PATH}/etc/apt/sources.list.d/openstack.list 391 | echo \"deb http://localhost/debian ${REPO_NOCHANGE_BACKPORT_DEST} main\" >\${CHROOT_PATH}/etc/apt/sources.list.d/openstack-backports.list 392 | fi" >>/etc/schroot/setup.d/80sources 393 | chmod +x /etc/schroot/setup.d/80sources 394 | } 395 | 396 | configure_jenkins_job_builder () { 397 | GENERATED_PASSWORD=$(dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum | awk '{print $1}') 398 | echo "[job_builder] 399 | ignore_cache=True 400 | keep_descriptions=False 401 | include_path=/usr/local/bin 402 | recursive=False 403 | allow_duplicates=False 404 | 405 | [jenkins] 406 | user=zigo 407 | password=${JENKINS_JOBS_BUILDER_PASS} 408 | url=http://localhost:8080/ 409 | " >/etc/jenkins_jobs/jenkins_jobs.ini 410 | echo "" >job.yaml 411 | for i in `cat /etc/pkgos/build-list` ; do 412 | echo "- job: 413 | name: $i 414 | builders: 415 | - shell: 'pkgos-bop-jenkins "${i}"' 416 | auth-token: g5rjtpms5emw 417 | logrotate: 418 | numToKeep: 4 419 | publishers: 420 | - ircbot: 421 | strategy: all 422 | notify-start: true 423 | message-type: summary 424 | wrappers: 425 | - ansicolor: 426 | colormap: xterm 427 | " >>job.yaml 428 | done 429 | jenkins-jobs update job.yaml 430 | } 431 | 432 | restart_jenkins () { 433 | service jenkins restart 434 | } 435 | 436 | ############################## 437 | # ACTUAL START OF THE SCRIPT # 438 | ############################## 439 | 440 | usage () { 441 | echo "Wrong usage: $0 [dev|jenkins] " 442 | echo "the username 2nd param is only if you use the dev mode" 443 | exit 1 444 | } 445 | 446 | if [ "${1}" = "dev" ] ; then 447 | echo "Setting-up a developer machine." 448 | DEV_OR_JENKINS=dev 449 | shift 450 | if [ -z "${1}" ] ; then 451 | usage 452 | fi 453 | THE_DEV_USER=${1} 454 | shift 455 | if [ -n "${1}" ] ; then 456 | usage 457 | fi 458 | THE_USER_HOMEDIR=/home/${THE_DEV_USER} 459 | elif [ "${1}" = "jenkins" ] ; then 460 | echo "Setting-up a Jenkins build server." 461 | DEV_OR_JENKINS=jenkins 462 | THE_DEV_USER=jenkins 463 | shift 464 | if [ -n "${1}" ] ; then 465 | usage 466 | fi 467 | THE_USER_HOMEDIR=/var/lib/jenkins 468 | else 469 | usage 470 | fi 471 | 472 | detect_env 473 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_hostname 474 | install_all_software 475 | configure_apache 476 | configure_pure 477 | # This often fails because the list of plugins isn't fetched by Jenkins 478 | #install_jenkins_plugins 479 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_dotgitconfig 480 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_sudoers 481 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_gpg_key 482 | [ "${DEV_OR_JENKINS}" = "dev" ] && check_user_gpg_key 483 | configure_sbuildrc 484 | build_ostack_archive_keyring_package 485 | configure_sbuild 486 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_job_builder 487 | # This is needed so that jenkins can login into sbuild 488 | [ "${DEV_OR_JENKINS}" = "jenkins" ] && restart_jenkins 489 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | openstack-pkg-tools (35) UNRELEASED; urgency=medium 2 | 3 | * Split the package list configuration into separate files from pkgos.conf. 4 | 5 | -- Thomas Goirand Thu, 17 Sep 2015 14:24:29 +0200 6 | 7 | openstack-pkg-tools (34) experimental; urgency=medium 8 | 9 | [ Ivan Udovichenko ] 10 | * Add possibility to set custom shell via pkgos_adduser 11 | function. 12 | * Fix issues with not sorted versions in pkgos-parse-requirements 13 | utility. 14 | * Fix issue with detecting the first character in package name 15 | in pkgos-debpypi script. 16 | 17 | [ Thomas Goirand ] 18 | * pkgos-debpypi now detects a .test.conf and writes debian/rules unit tests 19 | launching accordingly. 20 | * Correctly detects the location of the conf.py file to properly detect the 21 | way to run sphinx-build. 22 | * debpypi: respect the DEB_BUILD_OPTIONS=nodocs when creating debian/rules. 23 | * Optimized pkgos_inifile by stopping parsing when not in the correct 24 | section. 25 | * Repaired sets of auth_host directive when writing keystone_authtoken. 26 | 27 | -- Thomas Goirand Wed, 02 Sep 2015 14:56:07 +0200 28 | 29 | openstack-pkg-tools (33) experimental; urgency=medium 30 | 31 | * Fixes package branches when building Jessie backports on Jenkins. 32 | * Some fixes to build tools. 33 | 34 | -- Thomas Goirand Wed, 29 Jul 2015 23:31:43 +0200 35 | 36 | openstack-pkg-tools (32) unstable; urgency=medium 37 | 38 | * Really using bzip2 when compressing as bz2. 39 | 40 | -- Thomas Goirand Tue, 16 Jun 2015 13:29:54 +0000 41 | 42 | openstack-pkg-tools (31) unstable; urgency=medium 43 | 44 | * Added bzip2 compression support for the orig.tar. 45 | 46 | -- Thomas Goirand Tue, 16 Jun 2015 13:21:23 +0000 47 | 48 | openstack-pkg-tools (30) unstable; urgency=medium 49 | 50 | * Fixed pkgos-alternative-bin removing wrong python version of alternative. 51 | 52 | -- Thomas Goirand Mon, 15 Jun 2015 15:08:48 +0000 53 | 54 | openstack-pkg-tools (29) unstable; urgency=medium 55 | 56 | * Builds an orig.tar.gz if debian/gbp.conf indicates gz and not xz. 57 | 58 | -- Thomas Goirand Mon, 15 Jun 2015 10:31:56 +0200 59 | 60 | openstack-pkg-tools (28) unstable; urgency=medium 61 | 62 | * Removes override_dh_builddeb from .PHONY (which was causing .debs to not be 63 | created at all). 64 | 65 | -- Thomas Goirand Mon, 15 Jun 2015 10:21:01 +0200 66 | 67 | openstack-pkg-tools (27) unstable; urgency=medium 68 | 69 | * Added pkgos-alternative-bin to make it easy to handle alternatives as 70 | /usr/bin/python{2,3}-something. 71 | * Added a new gen-orig-gz feature, so we can use that instead of xz which 72 | produces unpredictable results. 73 | * Removed overrides of dh_builddeb an default compression options (as xz is 74 | now the default, and others pointed out -9 is a bad idea). 75 | 76 | -- Thomas Goirand Wed, 10 Jun 2015 15:13:42 +0200 77 | 78 | openstack-pkg-tools (26) unstable; urgency=medium 79 | 80 | * build-tools/pkgos-setup-sbuild: 81 | - Using invoke-rc.d instead of service, as it honores /usr/sbin/policy-rc.d 82 | 83 | -- Thomas Goirand Mon, 01 Jun 2015 17:33:57 +0200 84 | 85 | openstack-pkg-tools (25) unstable; urgency=medium 86 | 87 | * /var/log/ folders are now owned by the adm group (Closes: #781792). 88 | * Add "respawn limit" stanza to pkgos-gen-upstart-job script template. 89 | 90 | -- Thomas Goirand Mon, 01 Jun 2015 12:14:43 +0200 91 | 92 | openstack-pkg-tools (24) unstable; urgency=medium 93 | 94 | * Added tooling for sbuild. 95 | * Uploading to unstable. 96 | 97 | -- Thomas Goirand Fri, 17 Apr 2015 10:48:33 +0200 98 | 99 | openstack-pkg-tools (23) experimental; urgency=medium 100 | 101 | * Reviewed long description. 102 | * Added build scripts and lots of utilities to automate building of OpenStack 103 | packages. 104 | 105 | -- Thomas Goirand Wed, 25 Feb 2015 21:56:24 +0100 106 | 107 | openstack-pkg-tools (22) unstable; urgency=medium 108 | 109 | * Calls dh_installinit after dh_systemd_enable so that systemd services are 110 | started at install time. 111 | 112 | -- Thomas Goirand Thu, 08 Jan 2015 15:12:13 +0000 113 | 114 | openstack-pkg-tools (21) unstable; urgency=medium 115 | 116 | * Fixed mix-up with SYSTEM_USER and SYSTEM_GROUP in pkgos-gen-upstart-job. 117 | * Fixed creation of /var/run/${PROJECT_NAME} if using sysv-rc. 118 | 119 | -- Thomas Goirand Mon, 15 Dec 2014 15:53:43 +0800 120 | 121 | openstack-pkg-tools (20) unstable; urgency=medium 122 | 123 | * Now using a forking daemon anymore when using systemd. Thanks to Mikaël 124 | Cluseau for working on this cool feature. This also fixes 125 | the issue that /var/run/$PROJECT_NAME was not created at boot time, and 126 | then the daemon were not started. 127 | * Calling dh_systemd_enable correctly when a .service file is generated. 128 | 129 | -- Thomas Goirand Fri, 12 Dec 2014 15:24:43 +0000 130 | 131 | openstack-pkg-tools (19) unstable; urgency=medium 132 | 133 | * Using RuntimeDirectory=${PROJECT_NAME} as per advice in #debian-systemd. 134 | 135 | -- Thomas Goirand Mon, 10 Nov 2014 17:28:47 +0000 136 | 137 | openstack-pkg-tools (18) unstable; urgency=medium 138 | 139 | * Using /run and not /var/run. 140 | 141 | -- Thomas Goirand Tue, 11 Nov 2014 01:23:13 +0800 142 | 143 | openstack-pkg-tools (17) unstable; urgency=medium 144 | 145 | * Make it possible to have no --config-file= argument for the daemon. 146 | * Adds a RuntimeDirectory=/var/run/${PROJECT_NAME} in the systemd template, 147 | so that /var/run/${PROJECT_NAME} can be created on boot (Closes: #767711). 148 | 149 | -- Thomas Goirand Wed, 29 Oct 2014 00:31:49 +0800 150 | 151 | openstack-pkg-tools (16) unstable; urgency=medium 152 | 153 | * Fix some upstart job generation handling for murano-agent. 154 | 155 | -- Thomas Goirand Tue, 07 Oct 2014 22:59:41 +0800 156 | 157 | openstack-pkg-tools (15) unstable; urgency=medium 158 | 159 | * Uploading to unstable. 160 | 161 | -- Thomas Goirand Tue, 07 Oct 2014 13:42:53 +0800 162 | 163 | openstack-pkg-tools (14) experimental; urgency=medium 164 | 165 | * Adds the possibility to run daemons as root. 166 | 167 | -- Thomas Goirand Sat, 04 Oct 2014 21:42:52 +0800 168 | 169 | openstack-pkg-tools (13) experimental; urgency=medium 170 | 171 | * Added init script templating. 172 | * Uploading to experimental during the freeze. 173 | * Standards-Version is now 3.9.6. 174 | 175 | -- Thomas Goirand Fri, 03 Oct 2014 01:07:53 +0800 176 | 177 | openstack-pkg-tools (12) unstable; urgency=medium 178 | 179 | * Now setting-up database with ALTER DATABASE to use UTF8 instead of the dbc 180 | thing which didn't work. 181 | 182 | -- Thomas Goirand Tue, 03 Jun 2014 14:48:40 +0800 183 | 184 | openstack-pkg-tools (11) unstable; urgency=medium 185 | 186 | * Really fix dbc_{pg,my}sql_createdb_encoding="UTF8". 187 | 188 | -- Thomas Goirand Tue, 03 Jun 2014 01:30:50 +0800 189 | 190 | openstack-pkg-tools (10) unstable; urgency=medium 191 | 192 | * Now using dbc_{pg,my}sql_createdb_encoding="UTF8" when creating dbs. 193 | * Standards-Version: is now 3.9.5. 194 | 195 | -- Thomas Goirand Wed, 02 Apr 2014 22:10:33 +0800 196 | 197 | openstack-pkg-tools (9) unstable; urgency=medium 198 | 199 | * Fixed keystone endpoint registration for the new keystone command line 200 | syntax. 201 | 202 | -- Thomas Goirand Fri, 14 Feb 2014 17:20:34 +0000 203 | 204 | openstack-pkg-tools (8) unstable; urgency=low 205 | 206 | * Allow the upstart thing to also work with package.daemon.upstart.in 207 | (replaced the cut -d by a sed s/.upstart.in//). 208 | * Adds a git show in the gen-orig-xz, to check if the tag exists before 209 | creating the orig.tar.xz. 210 | * Added functions to automatically configure rabbit_* directives. 211 | 212 | -- Thomas Goirand Fri, 28 Jun 2013 16:18:55 +0800 213 | 214 | openstack-pkg-tools (7) unstable; urgency=low 215 | 216 | * Adds a pkgos_safesed function which doesn't put the (eventual) passwords 217 | visible using "ps", which makes it safe to use sed for passwords. Then 218 | pkgos_inifile uses that function now. 219 | * Added a function to remove a [SECTION] in a config file. 220 | 221 | -- Thomas Goirand Tue, 11 Jun 2013 11:58:32 +0800 222 | 223 | openstack-pkg-tools (6) unstable; urgency=low 224 | 225 | * Removed the -R flag when doing chown -R /var/lib/. 226 | * Extracted the adduser / addgroup function from pkgos_var_user_group as a 227 | separate (callable) function. 228 | * Bumped standard-version to 3.9.4. 229 | 230 | -- Thomas Goirand Thu, 30 May 2013 23:52:11 +0800 231 | 232 | openstack-pkg-tools (5) unstable; urgency=low 233 | 234 | * Uploading to SID. 235 | * Split the get-vcs-source: into 3 targets: 236 | - fetch-upstream-remote: 237 | - gen-orig-xz: 238 | - +get-master-branch: 239 | 240 | -- Thomas Goirand Fri, 10 May 2013 18:14:51 +0800 241 | 242 | openstack-pkg-tools (4) experimental; urgency=low 243 | 244 | * Clean-ups of function parameter calling order. 245 | * Rewrite of the pkgos_* functions for parsing ini files. 246 | 247 | -- Thomas Goirand Tue, 12 Mar 2013 00:43:02 +0800 248 | 249 | openstack-pkg-tools (3) experimental; urgency=low 250 | 251 | [ Thomas Goirand ] 252 | * Don't attempt to read anything from the config file if it isn't 253 | installed in /etc (in the pkgos_read_admin_creds pkgos.make target). 254 | 255 | [ James Page ] 256 | * Fixup handling of d/*.upstart.in to fix build failures 257 | downstream in Ubuntu. 258 | 259 | -- Thomas Goirand Sat, 02 Feb 2013 11:30:43 +0000 260 | 261 | openstack-pkg-tools (2) experimental; urgency=low 262 | 263 | * Now copying the orig.tar.xz in the build-area after creating it. 264 | * Now using the debian branch name defined in debian/gbp.conf for 265 | get-vcs-source. 266 | * Added code to handle auth_url instead of auth_host / auth_port / 267 | auth_proto. 268 | * Added a workround the fact that DPKG_MAINTSCRIPT_PACKAGE isn't always 269 | set (bug in debconf?) 270 | * Added a gen-author-list: target. 271 | * Sets various debconf questions with priority medium instead of high. 272 | * Added gen-upstream-changelog to generate a debian/CHANGELOG from 273 | upstream git log. 274 | 275 | -- Thomas Goirand Thu, 20 Dec 2012 09:50:58 +0000 276 | 277 | openstack-pkg-tools (1) experimental; urgency=low 278 | 279 | * Initial release. 280 | 281 | -- Thomas Goirand Fri, 16 Nov 2012 14:29:41 +0000 282 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: openstack-pkg-tools 2 | Section: devel 3 | Priority: extra 4 | Maintainer: PKG OpenStack 5 | Uploaders: Thomas Goirand 6 | Build-Depends: debhelper (>= 9) 7 | Standards-Version: 3.9.6 8 | Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/openstack-pkg-tools.git;a=summary 9 | Vcs-Git: git://anonscm.debian.org/openstack/openstack-pkg-tools.git 10 | 11 | Package: openstack-pkg-tools 12 | Architecture: all 13 | Depends: madison-lite, pristine-tar, libxml-xpath-perl, ${shlibs:Depends}, ${misc:Depends}, ${python:Depends} 14 | Description: Tools and scripts for building Openstack packages in Debian 15 | This package contains some useful shell scripts and helpers for building the 16 | Openstack packages in Debian, including: 17 | . 18 | * shared code for maintainer scripts (.config, .postinst, ...). 19 | * init script templates to automatically generate init scripts for sysv-rc, 20 | systemd and upstart. 21 | * tools to build backports using sbuild and/or Jenkins based on gbp workflow. 22 | * utility to maintain git packaging (to be included in a debian/rules). 23 | . 24 | Even if this package is maintained in order to build OpenStack packages, it is 25 | of a general purpose, and it can be used for building any package. 26 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: openstack-pkg-tools 3 | Source: git://anonscm.debian.org/openstack/openstack-pkg-tools.git 4 | 5 | Files: * 6 | Copyright: 2012, Thomas Goirand 7 | 2012, Roland Mas 8 | License: Apache-2 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | . 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | . 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the License is distributed on an "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | See the License for the specific language governing permissions and 19 | limitations under the License. 20 | . 21 | On Debian-based systems the full text of the Apache version 2.0 license 22 | can be found in `/usr/share/common-licenses/Apache-2.0'. 23 | -------------------------------------------------------------------------------- /debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debian-branch = debian/liberty 3 | 4 | [buildpackage] 5 | export-dir = ../build-area/ 6 | -------------------------------------------------------------------------------- /debian/openstack-pkg-tools.install: -------------------------------------------------------------------------------- 1 | pkgos.make /usr/share/openstack-pkg-tools 2 | pkgos_func /usr/share/openstack-pkg-tools 3 | pkgos_insert_include /usr/share/openstack-pkg-tools 4 | init-template/init-script-template /usr/share/openstack-pkg-tools 5 | init-template/pkgos-gen-systemd-unit /usr/bin 6 | init-template/pkgos-gen-upstart-job /usr/bin 7 | misc/openstack.profile /usr/share/lintian/profiles/debian 8 | misc/pkgos* /usr/bin 9 | build-tools/* /usr/bin 10 | etc/pkgos/* /etc/pkgos 11 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | build-arch: build 4 | build-indep: build 5 | build: 6 | 7 | clean: 8 | dh_testdir 9 | dh_clean 10 | 11 | install: 12 | dh_testdir 13 | dh_testroot 14 | dh_prep 15 | 16 | binary-indep: install 17 | dh_testdir 18 | dh_testroot 19 | dh_installchangelogs 20 | dh_installdocs 21 | dh_install 22 | dh_compress 23 | dh_fixperms 24 | dh_installdeb 25 | dh_gencontrol 26 | dh_md5sums 27 | dh_builddeb 28 | 29 | get-vcs-source: 30 | echo "Nothing to do here..." 31 | 32 | binary-arch: install 33 | 34 | binary: binary-indep binary-arch 35 | .PHONY: build clean binary-indep binary-arch binary install 36 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /etc/pkgos/build-list: -------------------------------------------------------------------------------- 1 | ceilometer 2 | cinder 3 | cliff-tablib 4 | cobbler 5 | designate 6 | factory-boy 7 | ftp-cloudfs 8 | fuel-astute 9 | fuel-nailgun 10 | gf-complete 11 | git-review 12 | glance 13 | heat 14 | heat-cfntools 15 | horizon 16 | ironic 17 | jerasure 18 | keystone 19 | liberasurecode 20 | libjs-autonumeric 21 | libjs-backbone-deep-model 22 | libjs-backbone.stickit 23 | libjs-cocktail 24 | libjs-i18next 25 | libjs-require-css 26 | libjs-requirejs 27 | libjs-requirejs-text 28 | migrate 29 | msgpack-python 30 | murano 31 | murano-agent 32 | murano-dashboard 33 | nailgun-agent 34 | nailgun-mcagents 35 | neutron 36 | neutron-l3-healthcheck 37 | nova 38 | novnc 39 | ntpstat 40 | openstack-debian-images 41 | openstack-doc-tools 42 | openstack-meta-packages 43 | openstack-nose 44 | openstack-pkg-tools 45 | openstack-trove 46 | openvswitch 47 | oslo-config 48 | oslo.messaging 49 | oslo.rootwrap 50 | oslo-sphinx 51 | python-barbicanclient 52 | python-bashate 53 | python-ceilometerclient 54 | python-cinderclient 55 | python-cloudfiles 56 | python-coffin 57 | python-concurrent.futures 58 | python-couleur 59 | python-croniter 60 | python-daemonize 61 | python-dbutils 62 | python-ddt 63 | python-designateclient 64 | python-dib-utils 65 | python-diskimage-builder 66 | python-django-appconf 67 | python-django-bootstrap-form 68 | python-django-compressor 69 | python-django-discover-runner 70 | python-django-openstack-auth 71 | python-django-pyscss 72 | python-dogpile.cache 73 | python-dogpile.core 74 | python-extras 75 | python-falcon 76 | python-fixtures 77 | python-fuelclient 78 | python-glanceclient 79 | python-glance-store 80 | python-hacking 81 | python-happybase 82 | python-heatclient 83 | python-hp3parclient 84 | python-hplefthandclient 85 | python-httpretty 86 | python-hurry.filesize 87 | python-ibm-db-sa 88 | python-invocations 89 | python-invoke 90 | python-ironicclient 91 | python-jingo 92 | python-json-patch 93 | python-jsonpath-rw 94 | python-json-pointer 95 | python-jsonschema 96 | python-keystoneclient 97 | python-keystonemiddleware 98 | python-ldappool 99 | python-lesscpy 100 | python-logutils 101 | python-misaka 102 | python-mockito 103 | python-mox3 104 | python-muranoclient 105 | python-network-checker 106 | python-neutronclient 107 | python-nose-exclude 108 | python-nosehtmloutput 109 | python-nose-parameterized 110 | python-nose-testconfig 111 | python-nose-timer 112 | python-novaclient 113 | python-openstackclient 114 | python-os-apply-config 115 | python-os-client-config 116 | python-os-collect-config 117 | python-oslo.db 118 | python-oslo.i18n 119 | python-oslo.policy 120 | python-oslo.serialization 121 | python-oslotest 122 | python-oslo.utils 123 | python-oslo.vmware 124 | python-osprofiler 125 | python-os-refresh-config 126 | python-pbr 127 | python-pecan 128 | python-pint 129 | python-posix-ipc 130 | python-proboscis 131 | python-pycadf 132 | python-pyeclib 133 | python-pyghmi 134 | python-pymemcache 135 | python-pymysql 136 | python-pysaml2 137 | python-pyvmomi 138 | python-rednose 139 | python-requests-mock 140 | python-retrying 141 | python-rfc3986 142 | python-rtslib-fb 143 | python-rudolf 144 | python-saharaclient 145 | python-savannaclient 146 | python-seamicroclient 147 | python-semver 148 | python-shotgun 149 | python-sockjs-tornado 150 | python-sphinxcontrib.plantuml 151 | python-steadymark 152 | python-sure 153 | python-swiftclient 154 | python-sysv-ipc 155 | python-tablib 156 | python-taskflow 157 | python-tasklib 158 | python-tempest-lib 159 | python-termcolor 160 | python-termstyle 161 | python-testscenarios 162 | python-tooz 163 | python-trollius 164 | python-troveclient 165 | python-tuskarclient 166 | python-warlock 167 | python-wrapt 168 | python-wsgi-intercept 169 | python-wsme 170 | python-xmlbuilder 171 | python-xstatic 172 | python-xstatic-angular 173 | python-xstatic-angular-cookies 174 | python-xstatic-angular-mock 175 | python-xstatic-bootstrap-datepicker 176 | python-xstatic-bootstrap-scss 177 | python-xstatic-d3 178 | python-xstatic-font-awesome 179 | python-xstatic-hogan 180 | python-xstatic-jasmine 181 | python-xstatic-jquery 182 | python-xstatic-jquery.bootstrap.wizard 183 | python-xstatic-jquery-migrate 184 | python-xstatic-jquery.quicksearch 185 | python-xstatic-jquery.tablesorter 186 | python-xstatic-jquery-ui 187 | python-xstatic-jsencrypt 188 | python-xstatic-qunit 189 | python-xstatic-rickshaw 190 | python-xstatic-spin 191 | python-xvfbwrapper 192 | python-yaql 193 | python-zake 194 | q-text-as-data 195 | ruby-cstruct 196 | ruby-raemon 197 | ruby-rethtool 198 | ruby-symboltable 199 | sahara 200 | sftpcloudfs 201 | sphinxcontrib-docbookrestapi 202 | sphinxcontrib-httpdomain 203 | sphinxcontrib-issuetracker 204 | sphinxcontrib-pecanwsme 205 | sphinxcontrib-programoutput 206 | spice-html5 207 | stevedore 208 | subunit 209 | swift 210 | swift-account-stats 211 | swift-plugin-s3 212 | tasksel 213 | tempest 214 | testresources 215 | tripleo-heat-templates 216 | tripleo-image-elements 217 | tuskar 218 | tuskar-ui 219 | websockify 220 | -------------------------------------------------------------------------------- /etc/pkgos/packages-list/experimental-branch: -------------------------------------------------------------------------------- 1 | bandit 2 | python-autobahn 3 | python-cliff 4 | python-concurrent.futures 5 | python-django-openstack-auth 6 | python-fixtures 7 | python-httpretty 8 | python-jsonschema 9 | python-oslo.vmware 10 | python-pyghmi 11 | python-pykmip 12 | python-pysaml2 13 | python-requests-mock 14 | python-rtslib-fb 15 | python-scciclient 16 | python-testtools 17 | subunit 18 | -------------------------------------------------------------------------------- /etc/pkgos/packages-list/openstack-release-branch: -------------------------------------------------------------------------------- 1 | barbican 2 | ceilometer 3 | cinder 4 | designate 5 | glance 6 | heat 7 | horizon 8 | ironic 9 | keystone 10 | manila 11 | migrate 12 | murano 13 | murano-agent 14 | murano-dashboard 15 | neutron 16 | nova 17 | openstack-doc-tools 18 | openstack-meta-packages 19 | openstack-pkg-tools 20 | openstack-trove 21 | oslo-config 22 | oslo.messaging 23 | oslo.rootwrap 24 | oslo-sphinx 25 | python-barbicanclient 26 | python-ceilometerclient 27 | python-cinderclient 28 | python-congressclient 29 | python-django-openstack-auth 30 | python-gabbi 31 | python-glanceclient 32 | python-glance-store 33 | python-heatclient 34 | python-ironicclient 35 | python-keystoneclient 36 | python-keystonemiddleware 37 | python-manilaclient 38 | python-mistralclient 39 | python-muranoclient 40 | python-neutronclient 41 | python-novaclient 42 | python-openstackclient 43 | python-os-brick 44 | python-os-client-config 45 | python-oslo.concurrency 46 | python-oslo-context 47 | python-oslo.db 48 | python-oslo.i18n 49 | python-oslo.middleware 50 | python-oslo.serialization 51 | python-oslotest 52 | python-oslo.utils 53 | python-oslo.versionedobjects 54 | python-oslo.vmware 55 | python-pbr 56 | python-pecan 57 | python-proliantutils 58 | python-pycadf 59 | python-saharaclient 60 | python-swiftclient 61 | python-taskflow 62 | python-tempest-lib 63 | python-tooz 64 | python-troveclient 65 | python-yaql 66 | python-zaqarclient 67 | quantum 68 | sahara 69 | stevedore 70 | swift 71 | tempest 72 | -------------------------------------------------------------------------------- /etc/pkgos/packages-list/pkg-javascript-repo: -------------------------------------------------------------------------------- 1 | libjs-angularjs-smart-table 2 | libjs-angular-gettext 3 | libjs-autonumeric 4 | libjs-backbone-deep-model 5 | libjs-backbone.stickit 6 | libjs-bootswatch 7 | libjs-cocktail 8 | libjs-i18next 9 | libjs-jsencrypt 10 | libjs-lrdragndrop 11 | libjs-magic-search 12 | libjs-require-css 13 | libjs-requirejs 14 | libjs-requirejs-text 15 | libjs-term.js 16 | libjs-twitter-bootstrap-datepicker 17 | libjs-spin.js 18 | -------------------------------------------------------------------------------- /etc/pkgos/pkgos.conf: -------------------------------------------------------------------------------- 1 | ################################################# 2 | # This file configure build tools for OpenStack # 3 | # and is used by scripts under /usr/bin/pkgos-* # 4 | ################################################# 5 | 6 | ### Target OS and target OpenStack release ### 7 | ############################################## 8 | # Target distribution for which we are backporting for 9 | TARGET_DISTRO=jessie 10 | 11 | # OpenStack release name we're building 12 | TARGET_OPENSTACK_REL=liberty 13 | 14 | ### Target backport distribution ### 15 | # Release number as it appears on the changelog (ie: as in ~bpo8+1) 16 | TARGET_DISTRO_NUM=8 17 | 18 | # Release backport postfix, to use with pkgos-bb 19 | BPO_POSTFIX=bpo${TARGET_DISTRO_NUM}+1 20 | 21 | ### Definitions for your Debian repository ### 22 | ############################################## 23 | # Root folder where the Debian FTP archive will be populated by a build 24 | REPO_ROOT=/home/ftp 25 | 26 | # what will be the http://debian main ? 27 | REPO_DEST=${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports 28 | 29 | # Space separated list of arch to scan using dpkg-scanpackages 30 | SCAN_ARCHES=amd64 31 | 32 | # Where to store the strait backports (eg: backports with no change 33 | # at all from original source package, only a rebuild...) 34 | REPO_NOCHANGE_BACKPORT_DEST=${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports-nochange 35 | 36 | # This is where to upload a package to backport using pkgos-bb 37 | SCP_DEST_HOST=archive.gplhost.com 38 | 39 | # What folder inside SCP_DEST_HOST 40 | SCP_DEST_SUITE=${REPO_DEST} 41 | 42 | # Debian mirror near you for faster build (hint: you can use approx) 43 | CLOSEST_DEBIAN_MIRROR=http://185.8.56.70:9999/debian 44 | 45 | ### Hostname of your computer ### 46 | ################################# 47 | # Hostname postfix (for example, with the above, it's going to 48 | # be juno-jessie.pkgs.mirantis.com) 49 | HOSTNAME_POSTFIX="pkgs.mirantis.com" 50 | 51 | # Calculated using the above 52 | HOST_FQDN="${TARGET_OPENSTACK_REL}-${TARGET_DISTRO}.${HOSTNAME_POSTFIX}" 53 | 54 | # Password of the user for jenkins-jobs-builder to use 55 | JENKINS_JOBS_BUILDER_PASS= 56 | 57 | ### Git clone URLs (using alioth.debian.org ...) ### 58 | #################################################### 59 | # From what Git repository should we git clone packages? 60 | CLONE_URL_BASE=git://anonscm.debian.org/openstack 61 | 62 | # Same as above, but for javascript packages listed in PKG_JS below 63 | CLONE_URL_PKGJS=git://anonscm.debian.org/pkg-javascript 64 | 65 | ############################ 66 | # Definitions of branches. # 67 | ############################ 68 | # Packages using debian/${TARGET_OPENSTACK_REL} 69 | OSTACK_PKGS=`cat /etc/pkgos/packages-list/openstack-release-branch | tr '\n' ' '` 70 | 71 | # Packages using debian/experimental 72 | EXPERIMENTAL_BRANCH=`cat /etc/pkgos/packages-list/experimental-branch | tr '\n' ' '` 73 | 74 | # List of packages within the pkgs-js Alioth group, 75 | # cloned from the ${CLONE_URL_PKGJS} repository (see above for the URL) 76 | PKG_JS=`cat /etc/pkgos/packages-list/pkg-javascript-repo | tr '\n' ' '` 77 | -------------------------------------------------------------------------------- /etc/pkgos/substitute: -------------------------------------------------------------------------------- 1 | pyopenssl python-openssl 2 | sqlalchemy-migrate migrate 3 | mysql-python python-mysqldb 4 | ibm_db_sa python-ibm-db-sa 5 | msgpack-python python-msgpack 6 | pytz python-tz 7 | futures python-concurrent.futures 8 | pyzmq python-zmq 9 | qpid-python python-qpid 10 | pyyaml python-yaml 11 | pycrypto python-crypto 12 | python-memcached python-memcache 13 | pysqlite python-pysqlite2 14 | pysendfile python-sendfile 15 | kafka-python python-kafka 16 | pysnmp python-pysnmp4 17 | requests-aws python-awsauth 18 | django_openstack_auth python-openstack-auth 19 | django_compressor python-compressor 20 | beautifulsoup4 python-bs4 21 | gitpython python-git 22 | -------------------------------------------------------------------------------- /init-template/init-script-template: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The content after this line comes from openstack-pkg-tools 3 | # and has been automatically added to a .init.in script, which 4 | # contains only the descriptive part for the daemon. Everything 5 | # else is standardized as a single unique script. 6 | 7 | # Author: Thomas Goirand 8 | 9 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 10 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 11 | 12 | if [ -z "${DAEMON}" ] ; then 13 | DAEMON=/usr/bin/${NAME} 14 | fi 15 | PIDFILE=/var/run/${PROJECT_NAME}/${NAME}.pid 16 | if [ -z "${SCRIPTNAME}" ] ; then 17 | SCRIPTNAME=/etc/init.d/${NAME} 18 | fi 19 | if [ -z "${SYSTEM_USER}" ] ; then 20 | SYSTEM_USER=${PROJECT_NAME} 21 | fi 22 | if [ -z "${SYSTEM_USER}" ] ; then 23 | SYSTEM_GROUP=${PROJECT_NAME} 24 | fi 25 | if [ "${SYSTEM_USER}" != "root" ] ; then 26 | STARTDAEMON_CHUID="--chuid ${SYSTEM_USER}:${SYSTEM_GROUP}" 27 | fi 28 | if [ -z "${CONFIG_FILE}" ] ; then 29 | CONFIG_FILE=/etc/${PROJECT_NAME}/${PROJECT_NAME}.conf 30 | fi 31 | LOGFILE=/var/log/${PROJECT_NAME}/${NAME}.log 32 | if [ -z "${NO_OPENSTACK_CONFIG_FILE_DAEMON_ARG}" ] ; then 33 | DAEMON_ARGS="${DAEMON_ARGS} --config-file=${CONFIG_FILE}" 34 | fi 35 | 36 | # Exit if the package is not installed 37 | [ -x $DAEMON ] || exit 0 38 | 39 | # If ran as root, create /var/lock/X, /var/run/X, /var/lib/X and /var/log/X as needed 40 | if [ `whoami` = "root" ] ; then 41 | for i in lock run log lib ; do 42 | mkdir -p /var/$i/${PROJECT_NAME} 43 | chown ${SYSTEM_USER} /var/$i/${PROJECT_NAME} 44 | done 45 | fi 46 | 47 | # This defines init_is_upstart which we use later on (+ more...) 48 | . /lib/lsb/init-functions 49 | 50 | # Manage log options: logfile and/or syslog, depending on user's choosing 51 | [ -r /etc/default/openstack ] && . /etc/default/openstack 52 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 53 | [ "x$USE_SYSLOG" = "xyes" ] && DAEMON_ARGS="$DAEMON_ARGS --use-syslog" 54 | [ "x$USE_LOGFILE" != "xno" ] && DAEMON_ARGS="$DAEMON_ARGS --log-file=$LOGFILE" 55 | 56 | do_start() { 57 | start-stop-daemon --start --quiet --background ${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} --chdir /var/lib/${PROJECT_NAME} --startas $DAEMON \ 58 | --test > /dev/null || return 1 59 | start-stop-daemon --start --quiet --background ${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} --chdir /var/lib/${PROJECT_NAME} --startas $DAEMON \ 60 | -- $DAEMON_ARGS || return 2 61 | } 62 | 63 | do_stop() { 64 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE 65 | RETVAL=$? 66 | rm -f $PIDFILE 67 | return "$RETVAL" 68 | } 69 | 70 | do_systemd_start() { 71 | exec $DAEMON $DAEMON_ARGS 72 | } 73 | 74 | case "$1" in 75 | start) 76 | init_is_upstart > /dev/null 2>&1 && exit 1 77 | log_daemon_msg "Starting $DESC" "$NAME" 78 | do_start 79 | case $? in 80 | 0|1) log_end_msg 0 ;; 81 | 2) log_end_msg 1 ;; 82 | esac 83 | ;; 84 | stop) 85 | init_is_upstart > /dev/null 2>&1 && exit 0 86 | log_daemon_msg "Stopping $DESC" "$NAME" 87 | do_stop 88 | case $? in 89 | 0|1) log_end_msg 0 ;; 90 | 2) log_end_msg 1 ;; 91 | esac 92 | ;; 93 | status) 94 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? 95 | ;; 96 | systemd-start) 97 | do_systemd_start 98 | ;; 99 | restart|force-reload) 100 | init_is_upstart > /dev/null 2>&1 && exit 1 101 | log_daemon_msg "Restarting $DESC" "$NAME" 102 | do_stop 103 | case $? in 104 | 0|1) 105 | do_start 106 | case $? in 107 | 0) log_end_msg 0 ;; 108 | 1) log_end_msg 1 ;; # Old process is still running 109 | *) log_end_msg 1 ;; # Failed to start 110 | esac 111 | ;; 112 | *) log_end_msg 1 ;; # Failed to stop 113 | esac 114 | ;; 115 | *) 116 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|systemd-start}" >&2 117 | exit 3 118 | ;; 119 | esac 120 | 121 | exit 0 122 | -------------------------------------------------------------------------------- /init-template/pkgos-gen-systemd-unit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | INIT_TEMPLATE=${1} 4 | SERVICE_FILE=`echo ${INIT_TEMPLATE} | sed 's/.init.in/.service/'` 5 | 6 | # Get the variables defined in the init template 7 | . ${INIT_TEMPLATE} 8 | 9 | if [ -z "${SCRIPTNAME}" ] ; then 10 | SCRIPTNAME=/etc/init.d/${NAME} 11 | fi 12 | if [ -z "${SYSTEM_USER}" ] ; then 13 | SYSTEM_USER=${PROJECT_NAME} 14 | fi 15 | if [ -z "${SYSTEM_GROUP}" ] ; then 16 | SYSTEM_GROUP=${PROJECT_NAME} 17 | fi 18 | 19 | # Find out what should go in After= 20 | SHOULD_START=`cat ${INIT_TEMPLATE} | grep "# Should-Start:" | sed 's/# Should-Start://'` 21 | 22 | if [ -n "${SHOULD_START}" ] ; then 23 | AFTER="After=" 24 | for i in ${SHOULD_START} ; do 25 | AFTER="${AFTER}${i}.service " 26 | done 27 | fi 28 | 29 | echo "[Unit] 30 | Description=${DESC} 31 | $AFTER 32 | 33 | [Service] 34 | User=${SYSTEM_USER} 35 | Group=${SYSTEM_GROUP} 36 | WorkingDirectory=/var/lib/${PROJECT_NAME} 37 | PermissionsStartOnly=true 38 | ExecStartPre=/bin/mkdir -p /var/lock/${PROJECT_NAME} /var/log/${PROJECT_NAME} /var/lib/${PROJECT_NAME} 39 | ExecStartPre=/bin/chown ${SYSTEM_USER}:${SYSTEM_GROUP} /var/lock/${PROJECT_NAME} /var/log/${PROJECT_NAME} /var/lib/${PROJECT_NAME} 40 | ExecStart=${SCRIPTNAME} systemd-start 41 | Restart=on-failure 42 | LimitNOFILE=65535 43 | 44 | [Install] 45 | WantedBy=multi-user.target 46 | " >${SERVICE_FILE} 47 | -------------------------------------------------------------------------------- /init-template/pkgos-gen-upstart-job: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | INIT_TEMPLATE=${1} 4 | UPSTART_FILE=`echo ${INIT_TEMPLATE} | sed 's/.init.in/.upstart/'` 5 | 6 | # Get the variables defined in the init template 7 | . ${INIT_TEMPLATE} 8 | 9 | ## Find out what should go in After= 10 | #SHOULD_START=`cat ${INIT_TEMPLATE} | grep "# Should-Start:" | sed 's/# Should-Start://'` 11 | # 12 | #if [ -n "${SHOULD_START}" ] ; then 13 | # AFTER="After=" 14 | # for i in ${SHOULD_START} ; do 15 | # AFTER="${AFTER}${i}.service " 16 | # done 17 | #fi 18 | 19 | if [ -z "${DAEMON}" ] ; then 20 | DAEMON=/usr/bin/${NAME} 21 | fi 22 | PIDFILE=/var/run/${PROJECT_NAME}/${NAME}.pid 23 | if [ -z "${SCRIPTNAME}" ] ; then 24 | SCRIPTNAME=/etc/init.d/${NAME} 25 | fi 26 | if [ -z "${SYSTEM_USER}" ] ; then 27 | SYSTEM_USER=${PROJECT_NAME} 28 | fi 29 | if [ -z "${SYSTEM_GROUP}" ] ; then 30 | SYSTEM_GROUP=${PROJECT_NAME} 31 | fi 32 | if [ "${SYSTEM_USER}" != "root" ] ; then 33 | STARTDAEMON_CHUID="--chuid ${SYSTEM_USER}:${SYSTEM_GROUP}" 34 | fi 35 | if [ -z "${CONFIG_FILE}" ] ; then 36 | CONFIG_FILE=/etc/${PROJECT_NAME}/${PROJECT_NAME}.conf 37 | fi 38 | LOGFILE=/var/log/${PROJECT_NAME}/${NAME}.log 39 | 40 | echo "description \"${DESC}\" 41 | author \"Thomas Goirand \" 42 | 43 | start on runlevel [2345] 44 | stop on runlevel [!2345] 45 | 46 | chdir /var/run 47 | 48 | respawn 49 | respawn limit 20 5 50 | limit nofile 65535 65535 51 | 52 | pre-start script 53 | for i in lock run log lib ; do 54 | mkdir -p /var/\$i/${PROJECT_NAME} 55 | chown ${SYSTEM_USER} /var/\$i/${PROJECT_NAME} 56 | done 57 | end script 58 | 59 | script 60 | [ -x \"${DAEMON}\" ] || exit 0 61 | DAEMON_ARGS=\"${DAEMON_ARGS}\" 62 | [ -r /etc/default/openstack ] && . /etc/default/openstack 63 | [ -r /etc/default/\$UPSTART_JOB ] && . /etc/default/\$UPSTART_JOB 64 | [ \"x\$USE_SYSLOG\" = \"xyes\" ] && DAEMON_ARGS=\"\$DAEMON_ARGS --use-syslog\" 65 | [ \"x\$USE_LOGFILE\" != \"xno\" ] && DAEMON_ARGS=\"\$DAEMON_ARGS --log-file=${LOGFILE}\" 66 | 67 | exec start-stop-daemon --start --chdir /var/lib/${PROJECT_NAME} \\ 68 | ${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} \\ 69 | --exec ${DAEMON} -- --config-file=${CONFIG_FILE} \${DAEMON_ARGS} 70 | end script 71 | " >${UPSTART_FILE} 72 | -------------------------------------------------------------------------------- /misc/openstack.profile: -------------------------------------------------------------------------------- 1 | # This profile is auto-generated 2 | Profile: debian/main 3 | Extends: debian/ftp-master-auto-reject 4 | Enable-Tags-From-Check: apache2, automake, binaries, changelog-file, changes-file, 5 | conffiles, control-file, control-files, copyright-file, cruft, dbus, deb-format, 6 | debconf, debhelper, debian-readme, debian-source-dir, description, 7 | duplicate-files, fields, filename-length, files, group-checks, huge-usr-share, 8 | infofiles, init.d, java, lintian, manpages, md5sums, menu-format, menus, nmu, 9 | ocaml, patch-systems, phppear, po-debconf, rules, scripts, shared-libs, 10 | source-copyright, standards-version, symlinks, systemd, testsuite, 11 | version-substvars, watch-file 12 | Disable-Tags: hardening-no-stackprotector, debian-watch-may-check-gpg-signature, unused-file-paragraph-in-dep5-copyright, no-upstream-changelog, binary-without-manpage, maintainer-script-should-not-use-update-alternatives-remove, latest-debian-changelog-entry-without-new-version 13 | -------------------------------------------------------------------------------- /misc/pkgos-alioth-new-git: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | CWD=`pwd` 6 | PKG_NAME=`basename ${CWD}` 7 | 8 | usage () { 9 | echo "$0 creates a new Git repository out of your current working tree on alioth." 10 | echo "You must be at the root of that local git repository" 11 | echo "$0 will use the current folder as the name for the Alioth git repository." 12 | echo "" 13 | echo "Usage: $0 " 14 | echo "example: $0 openstack will create a /git/openstack/${PKG_NAME}.git repository" 15 | echo "note that you will need to have write access on the destination project," 16 | echo "which means you must be a member of that said project on Alioth." 17 | echo "" 18 | echo "Please send patch/comments to: Thomas Goirand " 19 | exit 1 20 | } 21 | 22 | if [ $# != 1 ] ; then 23 | usage 24 | fi 25 | 26 | DEST_PROJECT=$1 27 | 28 | # Create the tarball and upload it to Alioth 29 | cd .. 30 | echo "===> Cloning ${PKG_NAME} as bare: ${PKG_NAME}.git" 31 | git clone --bare ${PKG_NAME} ${PKG_NAME}.git 32 | echo "===> Building tarball: ${PKG_NAME}.git.tar.gz" 33 | tar -czf ${PKG_NAME}.git.tar.gz ${PKG_NAME}.git 34 | echo "===> Uploading ${PKG_NAME}.git.tar.gz to git.debian.org" 35 | scp ${PKG_NAME}.git.tar.gz git.debian.org: 36 | 37 | # Uncompress it on Alioth, fix perms and hook 38 | ssh git.debian.org "cd /git/${DEST_PROJECT} && echo '===> Uncompressing ${PKG_NAME}.git.tar.gz in /git/${DEST_PROJECT}' && tar -xzf ~/${PKG_NAME}.git.tar.gz && echo '===> Activating update-server-info hook' && mv ${PKG_NAME}.git/hooks/post-update.sample ${PKG_NAME}.git/hooks/post-update && cd /git/${DEST_PROJECT}/${PKG_NAME}.git && git --bare update-server-info && echo '===> Deleting tarball on alioth' && rm ~/${PKG_NAME}.git.tar.gz && echo '===> Fxing g+w unix permissions' && find /git/${DEST_PROJECT}/${PKG_NAME}.git -exec chmod g+w {} \\; && find . -type d -exec chmod g+s {} \\; && git config core.sharedRepository group " 39 | echo "===> Cleaning local bare copy and tarball" 40 | rm ${PKG_NAME}.git.tar.gz 41 | rm -rf ${PKG_NAME}.git 42 | -------------------------------------------------------------------------------- /misc/pkgos-alternative-bin: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | usage () { 6 | echo "$0 PKG-NAME bin-name-1 [ bin-name-2 ...]" 7 | exit 1 8 | } 9 | 10 | if [ $# -lt 2 ] ; then 11 | usage 12 | fi 13 | 14 | PKG_NAME=${1} 15 | PKG_PY2=python-${1} 16 | PKG_PY3=python3-${1} 17 | shift 18 | 19 | # postinst 20 | echo "#!/bin/sh 21 | 22 | set -e 23 | 24 | if [ \"\$1\" = \"configure\" ] ; then" >debian/$PKG_PY2.postinst 25 | cp debian/$PKG_PY2.postinst debian/$PKG_PY3.postinst 26 | 27 | # postrm 28 | echo "#!/bin/sh 29 | 30 | set -e 31 | 32 | if [ \"\$1\" = \"remove\" ] || [ \"\$1\" = \"disappear\" ] ; then" >debian/$PKG_PY2.postrm 33 | cp debian/$PKG_PY2.postrm debian/$PKG_PY3.postrm 34 | 35 | # postrm 36 | echo "#!/bin/sh 37 | 38 | set -e 39 | 40 | if [ \"\$1\" = \"remove\" ] ; then" >debian/$PKG_PY2.prerm 41 | cp debian/$PKG_PY2.prerm debian/$PKG_PY3.prerm 42 | 43 | RULES_ENTRY="" 44 | 45 | while [ -n "${1}" ] ; do 46 | BIN_UTIL_NAME=$1 47 | shift 48 | echo " update-alternatives --install /usr/bin/${BIN_UTIL_NAME} ${BIN_UTIL_NAME} /usr/bin/python2-${BIN_UTIL_NAME} 300" >>debian/$PKG_PY2.postinst 49 | echo " update-alternatives --install /usr/bin/${BIN_UTIL_NAME} ${BIN_UTIL_NAME} /usr/bin/python3-${BIN_UTIL_NAME} 200" >>debian/$PKG_PY3.postinst 50 | echo " update-alternatives --remove ${BIN_UTIL_NAME} /usr/bin/python2-${BIN_UTIL_NAME}" >>debian/$PKG_PY2.postrm 51 | echo " update-alternatives --remove ${BIN_UTIL_NAME} /usr/bin/python3-${BIN_UTIL_NAME}" >>debian/$PKG_PY3.postrm 52 | echo " update-alternatives --remove ${BIN_UTIL_NAME} /usr/bin/python2-${BIN_UTIL_NAME}" >>debian/$PKG_PY2.prerm 53 | echo " update-alternatives --remove ${BIN_UTIL_NAME} /usr/bin/python3-${BIN_UTIL_NAME}" >>debian/$PKG_PY3.prerm 54 | RULES_ENTRY="${RULES_ENTRY}\n\tmv \$(CURDIR)/debian/${PKG_PY2}/usr/bin/${BIN_UTIL_NAME} \$(CURDIR)/debian/${PKG_PY2}/usr/bin/python2-${BIN_UTIL_NAME}" 55 | RULES_ENTRY="${RULES_ENTRY}\n\tmv \$(CURDIR)/debian/${PKG_PY3}/usr/bin/${BIN_UTIL_NAME} \$(CURDIR)/debian/${PKG_PY3}/usr/bin/python3-${BIN_UTIL_NAME}" 56 | done 57 | 58 | for i in postinst prerm postrm ; do 59 | echo "fi 60 | 61 | #DEBHELPER# 62 | 63 | exit 0">>debian/$PKG_PY2.$i 64 | echo "fi 65 | 66 | #DEBHELPER# 67 | 68 | exit 0">>debian/$PKG_PY3.$i 69 | done 70 | 71 | echo "I created the below maintainer scripts for you: 72 | - debian/$PKG_PY2.postinst 73 | - debian/$PKG_PY3.postinst 74 | - debian/$PKG_PY2.postrm 75 | - debian/$PKG_PY3.postrm 76 | - debian/$PKG_PY2.prerm 77 | - debian/$PKG_PY3.prerm 78 | 79 | Please make sure to insert this in your debian/rules: 80 | ${RULES_ENTRY} 81 | " 82 | exit 0 83 | -------------------------------------------------------------------------------- /misc/pkgos-debpypi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | if [ "${1}" = "-u" ] && [ -n "${2}" ] ; then 7 | ORIG_URL="${2}" 8 | shift 9 | shift 10 | fi 11 | 12 | if [ -z "${1}" ] ; then 13 | echo "This tool creates a template Debian package out of a PyPi package name." 14 | echo "Once this script has run, make sure it did what you expected, then use" 15 | echo "the newly created source package as a template. Make sure you correct" 16 | echo "the debian/copyright file before publishing any package." 17 | echo "Usage: ${0} package-name" 18 | exit 1 19 | fi 20 | 21 | PKG_NAME=${1} 22 | # Calculate the package name based on the command line argument 23 | LOWER_PKG_NAME=`echo ${PKG_NAME} | awk '{print tolower($0)}'` 24 | LOWER_PKG_NAME=`echo ${LOWER_PKG_NAME} | sed 's/_/-/'` 25 | if echo ${LOWER_PKG_NAME} | grep -q '^python-' ; then 26 | DEB_PKG_NAME=${LOWER_PKG_NAME} 27 | else 28 | DEB_PKG_NAME=python-${LOWER_PKG_NAME} 29 | fi 30 | echo "===> Package name will be ${DEB_PKG_NAME}" 31 | 32 | if [ ! -e ${PKG_NAME}.xml ] ; then 33 | echo "===> Downloading DOAP XML record" 34 | wget -nv "https://pypi.python.org/pypi?:action=doap&name=${PKG_NAME}" -O ${PKG_NAME}.xml 35 | fi 36 | 37 | # Get info from the XML document using xpath. 38 | VERSION_STRING=`xpath -e "//release/Version/revision/text()" ${PKG_NAME}.xml 2> /dev/null` 39 | SHORT_DESC=`xpath -e "//shortdesc/text()" ${PKG_NAME}.xml 2> /dev/null` 40 | LONG_DESC=`xpath -e "//description/text()" ${PKG_NAME}.xml 2> /dev/null` 41 | UP_MAINT_NAME=`xpath -e "//maintainer/foaf:Person/foaf:name/text()" ${PKG_NAME}.xml 2> /dev/null` 42 | HOMEPAGE=`xpath -e "//homepage/@rdf:resource" ${PKG_NAME}.xml 2> /dev/null | cut -d= -f2 | sed 's#"##g'` 43 | FIRST_LETTER=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'` 44 | if [ -e ${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz ] ; then 45 | ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz 46 | else 47 | ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.gz 48 | fi 49 | 50 | echo "===> Package info: 51 | Upstream version: ${VERSION_STRING} 52 | Author: ${UP_MAINT_NAME} 53 | Homepage: ${HOMEPAGE}" 54 | 55 | if [ ! -e ${ORIG} ] ; then 56 | echo "===> Downloading ${ORIG} file" 57 | if [ -z "${ORIG_URL}" ] ; then 58 | ORIG_URL=https://pypi.python.org/packages/source/${FIRST_LETTER}/${PKG_NAME}/${PKG_NAME}-${VERSION_STRING}.tar.gz 59 | fi 60 | wget -nv "${ORIG_URL}" -O ${ORIG} 61 | fi 62 | 63 | echo "===> Extracting ${ORIG}" 64 | tar -xf ${ORIG} 65 | if ! [ ${PKG_NAME}-${VERSION_STRING} = ${DEB_PKG_NAME}-${VERSION_STRING} ] ; then 66 | mv ${PKG_NAME}-${VERSION_STRING} ${DEB_PKG_NAME}-${VERSION_STRING} 67 | fi 68 | 69 | # Trying to guess the maintainer's email 70 | if [ -r ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ] ; then 71 | if grep -q author_email ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ; then 72 | AUTHOR_EMAIL=`grep author_email ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py | cut -d= -f2 | awk '{print $1}' | sed -e 's/,//' -e "s/'//g" -e 's/"//g' | grep -e '^[._a-zA-Z0-9+-]*@[-a-z0-9.]*$'` 73 | fi 74 | fi 75 | 76 | echo "===> Creating debian folder for ${DEB_PKG_NAME}" 77 | if [ ! -d ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source ] ; then 78 | mkdir -p ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source 79 | fi 80 | cd ${DEB_PKG_NAME}-${VERSION_STRING} 81 | 82 | echo "===> Searching for sphinx doc folder" 83 | if [ -e doc ] ; then 84 | DOC_FOLDER=doc 85 | elif [ -e docs ] ; then 86 | DOC_FOLDER=docs 87 | fi 88 | if [ -n "${DOC_FOLDER}" ] ; then 89 | CONFPY_FILE=`find ${DOC_FOLDER} -name 'conf.py'` 90 | if [ -r "${CONFPY_FILE}" ] ; then 91 | DOC_FOLDER=`dirname ${CONFPY_FILE}` 92 | SPHINX_BUILD_DEP=", python-sphinx" 93 | RULES_WITH=",sphinxdoc" 94 | SUGGEST_DOC=" 95 | Suggests: ${DEB_PKG_NAME}-doc" 96 | else 97 | DOC_FOLDER= 98 | SPHINX_BUILD_DEP="" 99 | RULES_WITH="" 100 | SUGGEST_DOC="" 101 | fi 102 | fi 103 | 104 | echo "===> Checking for PBR and fixing accordingly" 105 | # If the package uses PBR, then we need openstack-pkg-tools 106 | if grep -q "setup_requires=\['pbr'\]" ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ; then 107 | OSTACK_PKG_T_CTRL=", openstack-pkg-tools" 108 | # We need a mandatory include... 109 | # ... and the export OSLO_PACKAGE_VERSION=$(VERSION) 110 | OSTACK_PKG_T_RULES="include /usr/share/openstack-pkg-tools/pkgos.make 111 | export OSLO_PACKAGE_VERSION=\$(VERSION)" 112 | else 113 | # Otherwise, we just include it non-mandatorily, so that 114 | # we can use ./debian/rules gen-orig-xz 115 | OSTACK_PKG_T_CTRL="" 116 | OSTACK_PKG_T_RULES="-include /usr/share/openstack-pkg-tools/pkgos.make" 117 | fi 118 | 119 | echo "Source: ${DEB_PKG_NAME} 120 | Section: python 121 | Priority: optional 122 | Maintainer: PKG OpenStack 123 | Uploaders: Thomas Goirand 124 | Build-Depends: debhelper (>= 9), 125 | dh-python, 126 | python-setuptools, 127 | python-all, 128 | python3-setuptools, 129 | python3-all${SPHINX_BUILD_DEP}${OSTACK_PKG_T_CTRL} 130 | Standards-Version: 3.9.6 131 | Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/${DEB_PKG_NAME}.git 132 | Vcs-Git: git://anonscm.debian.org/openstack/${DEB_PKG_NAME}.git 133 | Homepage: ${HOMEPAGE} 134 | 135 | Package: ${DEB_PKG_NAME} 136 | Architecture: all 137 | Depends: \${python:Depends}, \${misc:Depends}${SUGGEST_DOC} 138 | Description: ${SHORT_DESC} - Python 2.x 139 | ${LONG_DESC} 140 | . 141 | This package contains the Python 2.x module. 142 | 143 | Package: python3-${LOWER_PKG_NAME} 144 | Architecture: all 145 | Depends: \${python3:Depends}, \${misc:Depends}${SUGGEST_DOC} 146 | Description: ${SHORT_DESC} - Python 3.x 147 | - REPLACE ME - 148 | . 149 | This package contains the Python 3.x module. 150 | " >debian/control 151 | 152 | if [ -n "${DOC_FOLDER}" ] ; then 153 | echo "Package: python-${LOWER_PKG_NAME}-doc 154 | Section: doc 155 | Architecture: all 156 | Depends: \${misc:Depends}, \${sphinxdoc:Depends} 157 | Description: ${SHORT_DESC} - doc 158 | - REPLACE ME - 159 | . 160 | This package contains the documentation. 161 | " >>debian/control 162 | 163 | echo "Document: ${DEB_PKG_NAME}-doc 164 | Title: ${PKG_NAME} Documentation 165 | Author: N/A 166 | Abstract: Sphinx documentation for ${PKG_NAME} 167 | Section: Programming/Python 168 | 169 | Format: HTML 170 | Index: /usr/share/doc/python-${LOWER_PKG_NAME}-doc/html/index.html 171 | Files: /usr/share/doc/python-${LOWER_PKG_NAME}-doc/html/*" >debian/python-${LOWER_PKG_NAME}-doc.doc-base 172 | fi 173 | 174 | EDITOR=touch dch --create --package ${DEB_PKG_NAME} --distribution unstable --urgency medium -v ${VERSION_STRING}-1 175 | rm +1 176 | 177 | echo "9" >debian/compat 178 | 179 | if [ -n "${AUTHOR_EMAIL}" ] ; then 180 | UP_MAINT_AND_EMAIL="${UP_MAINT_NAME} <${AUTHOR_EMAIL}>" 181 | else 182 | UP_MAINT_AND_EMAIL=${UP_MAINT_NAME} 183 | fi 184 | echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 185 | Upstream-Name: ${PKG_NAME} 186 | Source: ${HOMEPAGE} 187 | 188 | Files: debian/* 189 | Copyright: (c) 2014, Thomas Goirand 190 | License: Apache-2 191 | 192 | Files: * 193 | Copyright: (c) 2013, ${UP_MAINT_AND_EMAIL} 194 | License: Apache-2 195 | 196 | License: Apache-2 197 | Licensed under the Apache License, Version 2.0 (the \"License\"); 198 | you may not use this file except in compliance with the License. 199 | You may obtain a copy of the License at 200 | . 201 | http://www.apache.org/licenses/LICENSE-2.0 202 | . 203 | Unless required by applicable law or agreed to in writing, software 204 | distributed under the License is distributed on an \"AS IS\" BASIS, 205 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 206 | See the License for the specific language governing permissions and 207 | limitations under the License. 208 | . 209 | On Debian-based systems the full text of the Apache version 2.0 license 210 | can be found in /usr/share/common-licenses/Apache-2.0. 211 | " >debian/copyright 212 | 213 | echo "[DEFAULT] 214 | upstream-branch = master 215 | debian-branch = debian/unstable 216 | upstream-tag = %(version)s 217 | compression = xz 218 | 219 | [git-buildpackage] 220 | export-dir = ../build-area/ 221 | " >debian/gbp.conf 222 | 223 | if [ -n "${DOC_FOLDER}" ] ; then 224 | SPHINX_BUILD_RULES="override_dh_sphinxdoc: 225 | ifeq (,\$(findstring nodocs, \$(DEB_BUILD_OPTIONS))) 226 | sphinx-build -b html ${DOC_FOLDER} debian/python-${LOWER_PKG_NAME}-doc/usr/share/doc/python-${LOWER_PKG_NAME}-doc/html 227 | dh_sphinxdoc -O--buildsystem=python_distutils 228 | endif 229 | " 230 | else 231 | SPHINX_BUILD_RULES="" 232 | fi 233 | 234 | if [ -e .testr.conf ] ; then 235 | UNIT_TEST_RULES="override_dh_auto_test: 236 | ifeq (,\$(findstring nocheck, \$(DEB_BUILD_OPTIONS))) 237 | @echo \"===> Running tests\" 238 | set -e ; set -x ; for i in 2.7 \$(PYTHON3S) ; do \\ 239 | PYMAJOR=\`echo \$\$i | cut -d'.' -f1\` ; \\ 240 | echo \"===> Testing with python\$\$i (python\$\$PYMAJOR)\" ; \\ 241 | rm -rf .testrepository ; \\ 242 | testr-python\$\$PYMAJOR init ; \\ 243 | TEMP_REZ=\`mktemp -t\` ; \\ 244 | PYTHONPATH=\$(CURDIR) PYTHON=python\$\$i testr-python\$\$PYMAJOR run --subunit | tee \$\$TEMP_REZ | subunit2pyunit ; \\ 245 | cat \$\$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \\ 246 | rm -f \$\$TEMP_REZ ; \\ 247 | testr-python\$\$PYMAJOR slowest ; \\ 248 | done 249 | endif 250 | " 251 | else 252 | UNIT_TEST_RULES="override_dh_auto_test: 253 | ifeq (,\$(findstring nocheck, \$(DEB_BUILD_OPTIONS))) 254 | set -e ; for pyvers in \$(PYTHONS) \$(PYTHON3S); do \\ 255 | python\$\$pyvers setup.py test ; \\ 256 | done 257 | endif 258 | " 259 | fi 260 | 261 | echo "#!/usr/bin/make -f 262 | 263 | PYTHONS:=\$(shell pyversions -vr) 264 | PYTHON3S:=\$(shell py3versions -vr) 265 | 266 | UPSTREAM_GIT = git://github.com//${PKG_NAME}.git 267 | ${OSTACK_PKG_T_RULES} 268 | 269 | %: 270 | dh \$@ --buildsystem=python_distutils --with python2,python3${RULES_WITH} 271 | 272 | override_dh_install: 273 | set -e ; for pyvers in \$(PYTHONS); do \\ 274 | python\$\$pyvers setup.py install --install-layout=deb \\ 275 | --root \$(CURDIR)/debian/python-${LOWER_PKG_NAME}; \\ 276 | done 277 | set -e ; for pyvers in \$(PYTHON3S); do \\ 278 | python\$\$pyvers setup.py install --install-layout=deb \\ 279 | --root \$(CURDIR)/debian/python3-${LOWER_PKG_NAME}; \\ 280 | done 281 | rm -rf \$(CURDIR)/debian/python*-${LOWER_PKG_NAME}/usr/lib/python*/dist-packages/*.pth 282 | 283 | ${UNIT_TEST_RULES} 284 | 285 | ${SPHINX_BUILD_RULES} 286 | override_dh_clean: 287 | dh_clean -O--buildsystem=python_distutils 288 | rm -rf build 289 | 290 | 291 | # Commands not to run 292 | override_dh_installcatalogs: 293 | override_dh_installemacsen override_dh_installifupdown: 294 | override_dh_installinfo override_dh_installmenu override_dh_installmime: 295 | override_dh_installmodules override_dh_installlogcheck: 296 | override_dh_installpam override_dh_installppp override_dh_installudev override_dh_installwm: 297 | override_dh_installxfonts override_dh_gconf override_dh_icons override_dh_perl override_dh_usrlocal: 298 | override_dh_installcron override_dh_installdebconf: 299 | override_dh_installlogrotate override_dh_installgsettings: 300 | " >debian/rules 301 | chmod +x debian/rules 302 | 303 | echo "version=3 304 | http://pypi.python.org/packages/source/${FIRST_LETTER}/${PKG_NAME} ${PKG_NAME}-(.*).tar.gz 305 | " >debian/watch 306 | 307 | echo "3.0 (quilt)" >debian/source/format 308 | echo 'extend-diff-ignore = "^[^/]*[.]egg-info/"' >debian/source/options 309 | -------------------------------------------------------------------------------- /misc/pkgos-fetch-fake-repo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script prepares a /etc/pkgos/fake-${TARGET_DISTRO}-mirror folder 3 | # with Packages.gz and Sources.gz files so that we can later on use 4 | # the madison-lite script when using pkgos-parse-requirements. 5 | # Indeed, using rmadison for this task is a way too slow, considering the 6 | # average amount of dependency in a typical OpenStack component. 7 | 8 | set -e 9 | 10 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 11 | echo "Could not read /etc/pkgos/pkgos.conf" 12 | exit 1 13 | else 14 | . /etc/pkgos/pkgos.conf 15 | fi 16 | 17 | # Create the folder and remove the Packages.gz / Sources.gz 18 | DEST_DIST_DIR=/etc/pkgos/fake-${TARGET_DISTRO}-mirror/dists/${TARGET_DISTRO}/main 19 | for i in binary-all binary-amd64 source ; do 20 | if ! [ -d ${DEST_DIST_DIR}/$i ] ; then 21 | mkdir -p ${DEST_DIST_DIR}/$i 22 | fi 23 | if [ "$i" = "source" ] ; then 24 | GZFILE=Sources.gz 25 | else 26 | GZFILE=Packages.gz 27 | fi 28 | rm -f ${DEST_DIST_DIR}/$i/$GZFILE 29 | wget ${CLOSEST_DEBIAN_MIRROR}/dists/${TARGET_DISTRO}/main/$i/$GZFILE -O ${DEST_DIST_DIR}/$i/$GZFILE 30 | done 31 | -------------------------------------------------------------------------------- /misc/pkgos-parse-requirements: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if ! [ -r /etc/pkgos/pkgos.conf ] ; then 6 | echo "Could not read /etc/pkgos/pkgos.conf" 7 | exit 1 8 | else 9 | . /etc/pkgos/pkgos.conf 10 | fi 11 | 12 | if [ "${1}" = "-h" ] ; then 13 | echo "This utility attemps to parse an OpenStack requirements.txt file" 14 | echo "as input, and produce a list of Debian dependencies as output." 15 | echo "Note that this is far from perfect, and that you *WILL* need to" 16 | echo "manually check for the dependencies. This is only a helper in" 17 | echo "order to gain some precious development time." 18 | echo "" 19 | echo "If this utility is called without a parameter, it will attempt" 20 | echo "to read the requirements.txt and test-requirements.txt file." 21 | echo "Otherwise, it takes the first argument as the file to parse." 22 | exit 0 23 | fi 24 | 25 | # Some packages should never be in the dependencies in Debian, 26 | # as they are included in Python 2.7. If you find one that is 27 | # missing, just add it to the list it here. 28 | BLACK_LIST="discover argparse ordereddict doc8 pylint flake8 pyflakes pep8" 29 | is_blacklisted () { 30 | ISBLACKLISTED="no" 31 | for i in $BLACK_LIST ; do 32 | if [ "${i}" = "${1}" ] ; then 33 | ISBLACKLISTED="yes" 34 | fi 35 | done 36 | } 37 | 38 | BLACK_LIST_PY3="python3-testrepository python3-oslosphinx python3-coverage python3-concurrent.futures" 39 | is_py3_blacklisted () { 40 | IS_PY3BLACKLISTED="no" 41 | for i in $BLACK_LIST_PY3 ; do 42 | if [ "${i}" = "${1}" ] ; then 43 | IS_PY3BLACKLISTED="yes" 44 | fi 45 | done 46 | } 47 | 48 | # Some packages should never make it into the Build-Depends-Indep:, 49 | # because they are already in Build-Depends:. Here's the list for it. 50 | BUILD_DEPENDS_LIST="sphinx pbr" 51 | is_build_depends () { 52 | ISBUILDDEPENDS="no" 53 | for i in ${BUILD_DEPENDS_LIST} ; do 54 | if [ "${i}" = ${1} ] ; then 55 | ISBUILDDEPENDS="yes" 56 | fi 57 | done 58 | } 59 | 60 | EPOC_1_IN="python-cinderclient python-keystoneclient python-glanceclient python-swiftclient python-oslo.config" 61 | has_1_in_epoc () { 62 | HAS_1_IN_EPOC="no" 63 | for i in ${EPOC_1_IN} ; do 64 | if [ "${i}" = ${1} ] ; then 65 | HAS_1_IN_EPOC="yes" 66 | fi 67 | done 68 | } 69 | 70 | EPOC_2_IN="python-novaclient" 71 | has_2_in_epoc () { 72 | HAS_2_IN_EPOC="no" 73 | for i in ${EPOC_2_IN} ; do 74 | if [ "${i}" = ${1} ] ; then 75 | HAS_2_IN_EPOC="yes" 76 | fi 77 | done 78 | } 79 | 80 | NO_PYTHON_PREFIX="alembic testrepository subunit websockify cliff-tablib" 81 | is_python_prefixed () { 82 | PY_PREFIX="yes" 83 | for i in ${NO_PYTHON_PREFIX} ; do 84 | if [ "${i}" = "${1}" ] ; then 85 | PY_PREFIX="no" 86 | fi 87 | done 88 | } 89 | 90 | # Param: $1: input file 91 | # $2: if set, then the Build-Depends: programs will be removed (for example: sphinx, pbr, etc.) 92 | parse_and_print () { 93 | INPUT_FILE=$1 94 | REMOVE_BUILD_DEPENDS="no" 95 | if [ "${2}" = "build-depends" ] ; then 96 | REMOVE_BUILD_DEPENDS="yes" 97 | fi 98 | PYVERS=${3} 99 | DEP_LIST="" 100 | # echo `cat ${INPUT_FILE} | grep -v '^#' | grep -v '^[ \t]*$' | awk '{print $1}' | tr '[:upper:]' '[:lower:]' | sed $EXP` 101 | for i in `cat ${INPUT_FILE} | grep -v '^#' | grep -v '^[ \t]*$' | awk '{print $1}' | tr '[:upper:]' '[:lower:]' | sed $EXP` ; do 102 | # echo "Line ---> $i" 103 | if echo $i | grep -q -e '^http://' ; then 104 | i=`echo $i | cut -d'=' -f2` 105 | VERS="" 106 | else 107 | TRIM_VERS=`echo $i | sed -e 's/^[-a-zA-Z0-9._]*//'` 108 | VERS=`echo $TRIM_VERS | sed -e 's/^[-a-zA-Z0-9._]*//' | tr ',|;' '\n' | sort | tr '\n' ',' | sed -e 's/,$//'` 109 | fi 110 | if [ -n "$VERS" ] ; then 111 | PKG=`echo $i | sed -e "s/${TRIM_VERS}//" | sed -e s/python-//` 112 | else 113 | PKG=`echo $i | sed -e s/python-//` 114 | fi 115 | PKG=`echo ${PKG} | sed -e s/_/-/g` 116 | is_blacklisted ${PKG} 117 | ISBUILDDEPENDS="no" 118 | if [ REMOVE_BUILD_DEPENDS="yes" ] ; then 119 | is_build_depends ${PKG} 120 | fi 121 | if [ $ISBLACKLISTED = "no" ] && [ ${ISBUILDDEPENDS} = "no" ]; then 122 | is_python_prefixed ${PKG} 123 | if [ ${PY_PREFIX} = "yes" ] ; then 124 | PKG=python-${PKG} 125 | fi 126 | # Convert the package name into lowercase, as Debian 127 | # doesn't have any upper case in package names 128 | PKG=`echo ${PKG} | tr '[:upper:]' '[:lower:]'` 129 | if [ -n "$VERS" ] && [ ${PKG} != "python-hacking" ] ; then 130 | # If there's a a version-depends, convert the pip style 131 | # of dependency to the Debian one (ie: >> instead of >) 132 | FIRST_CONSTR=`echo $VERS | cut -d, -f1` 133 | FIRST_NUMS=`echo $FIRST_CONSTR | sed -e 's/[<>=\!]*//'` 134 | FIRST_SIGN=`echo $FIRST_CONSTR | sed -e "s/${FIRST_NUMS}//"` 135 | if [ "${FIRST_SIGN}" = '<' ] ; then 136 | FIRST_SIGN='<<' 137 | fi 138 | if [ "${FIRST_SIGN}" = '>' ] ; then 139 | FIRST_SIGN='>>' 140 | fi 141 | has_1_in_epoc ${PKG} 142 | if [ "${HAS_1_IN_EPOC}" = "yes" ] ; then 143 | FIRST_NUMS="1:${FIRST_NUMS}" 144 | fi 145 | has_2_in_epoc ${PKG} 146 | if [ "${HAS_2_IN_EPOC}" = "yes" ] ; then 147 | FIRST_NUMS="2:${FIRST_NUMS}" 148 | fi 149 | # If there's a fake-jessie-mirror folder in /etc/pkgos 150 | # use that one with madison-lite to check if the version 151 | # of the package is already in Jessie. 152 | if [ -d /etc/pkgos/fake-jessie-mirror ] ; then 153 | STABLE_VERSION=`madison-lite -a all,amd64 --mirror /etc/pkgos/fake-${TARGET_DISTRO}-mirror ${PKG} | awk '{print $3}'` 154 | # Make sure that the package is in the stable repo 155 | if [ -z "${STABLE_VERSION}" ] ; then 156 | VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})" 157 | else 158 | #echo "Comparing for ${PKG}: dpkg --compare-versions ${STABLE_VERSION} gt ${FIRST_NUMS}" 159 | if dpkg --compare-versions ${STABLE_VERSION} gt ${FIRST_NUMS} ; then 160 | VERSION_TO_DEPEND_ON="" 161 | else 162 | VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})" 163 | fi 164 | fi 165 | else 166 | VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})" 167 | fi 168 | if [ "${PYVERS}" = 3 ] ; then 169 | PKG=`echo ${PKG} | sed s/python-/python3-/` 170 | is_py3_blacklisted ${PKG} 171 | if [ ${IS_PY3BLACKLISTED} = "yes" ] ; then 172 | continue 173 | fi 174 | fi 175 | if [ -z "${DEP_LIST}" ] ; then 176 | DEP_LIST="${PKG}${VERSION_TO_DEPEND_ON}" 177 | #echo " ${PKG} (${FIRST_SIGN} ${FIRST_NUMS})," 178 | else 179 | DEP_LIST="${DEP_LIST}\n${PKG}${VERSION_TO_DEPEND_ON}" 180 | fi 181 | else 182 | if [ -z "${DEP_LIST}" ] ; then 183 | DEP_LIST="${PKG}" 184 | else 185 | #echo " ${PKG}," 186 | DEP_LIST="${DEP_LIST}\n${PKG}" 187 | fi 188 | fi 189 | #echo "Package: ${PKG}\t\tFirst sign: ${FIRST_SIGN}\t\tFirst num: ${FIRST_NUMS}..." 190 | fi 191 | done 192 | } 193 | 194 | # Param: $DEPS: the dependency list, one package per line 195 | # $1: the word for the package dep (ie: Depends: or Build-Depends-Indep:) 196 | format_output () { 197 | # set -x 198 | SPACES_IN_FRONT=`echo "${1} " | sed -e 's/[a-zBDI:-]/ /g'` 199 | CNT="0" 200 | echo $DEPS | LC_COLLATE=C sort -u | while read i ; do 201 | if [ "${CNT}" = "0" ] ; then 202 | echo "${1} ${i}," 203 | else 204 | echo -n "${1}" | sed -e 's/[a-zBDI:-]/ /g' 205 | echo " ${i}," 206 | fi 207 | CNT=$(($CNT + 1)) 208 | done 209 | if [ $1 = "Depends:" ] ; then 210 | echo " \${misc:Depends}," 211 | echo " \${python:Depends}," 212 | fi 213 | } 214 | 215 | calc_substitue_list () { 216 | if [ -r /etc/pkgos/substitute ] ; then 217 | while read i ; do 218 | SOURCE=`echo $i | cut -d" " -f1` 219 | DEST=`echo $i | cut -d" " -f2` 220 | EXP="$EXP -e s/$SOURCE/$DEST/" 221 | done = 9), 256 | dh-python,${DH_SYSTEMD} 257 | openstack-pkg-tools${OSTACK_PKG_TOOLS_VERS},${PO_DEBCONF} 258 | python-all, 259 | python-pbr, 260 | python-setuptools, 261 | python-sphinx," 262 | # Adds python3 support packages 263 | if [ "${HAS_PY3_SUPPORT}" = "yes" ] ; then 264 | echo " python3-all, 265 | python3-pbr, 266 | python3-setuptools," 267 | fi 268 | 269 | # Gather the dependencies. 270 | if [ -e test-requirements-py2.txt ] ; then 271 | parse_and_print test-requirements-py2.txt build-depends 2 272 | else 273 | parse_and_print test-requirements.txt build-depends 2 274 | fi 275 | DEP_LIST_TESTS=${DEP_LIST} 276 | if [ -r requirements-py2.txt ] ; then 277 | parse_and_print requirements-py2.txt depends 278 | else 279 | parse_and_print requirements.txt depends 280 | fi 281 | DEP_LIST_RUNTIME=${DEP_LIST} 282 | 283 | # If the package has python3 support, let's try to also print python3 build-depends 284 | if [ "${HAS_PY3_SUPPORT}" = "yes" ] ; then 285 | parse_and_print requirements.txt depends 3 286 | DEP_LIST_TESTS="${DEP_LIST_TESTS}\n${DEP_LIST}" 287 | if [ -e test-requirements-py3.txt ] ; then 288 | parse_and_print test-requirements-py3.txt build-depends 3 289 | else 290 | parse_and_print test-requirements.txt build-depends 3 291 | fi 292 | DEP_LIST_TESTS="${DEP_LIST_TESTS}\n${DEP_LIST}" 293 | fi 294 | 295 | if [ -r .testr.conf ] ; then 296 | DEP_LIST_TESTS="${DEP_LIST_TESTS}\ntestrepository\nsubunit" 297 | if [ -r debian/control ] && [ -n "${HAS_PYTHON3}" ] ; then 298 | DEP_LIST_TESTS="${DEP_LIST_TESTS}\npython3-subunit" 299 | fi 300 | fi 301 | 302 | # Format the output 303 | DEPS="${DEP_LIST_RUNTIME}\n${DEP_LIST_TESTS}" 304 | format_output "Build-Depends-Indep:" 305 | 306 | DEPS=${DEP_LIST_RUNTIME} 307 | format_output "Depends:" 308 | fi 309 | -------------------------------------------------------------------------------- /misc/pkgos-reqsdiff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | TEMP_FILE1=`mktemp -t pkgos-reqsdiff1.XXXXXX` || exit 1 6 | TEMP_FILE2=`mktemp -t pkgos-reqsdiff1.XXXXXX` || exit 1 7 | pkgos-show-control-depends >${TEMP_FILE1} 8 | pkgos-parse-requirements >${TEMP_FILE2} 9 | diff -u ${TEMP_FILE1} ${TEMP_FILE2} 10 | rm -f ${TEMP_FILE1} ${TEMP_FILE2} 11 | -------------------------------------------------------------------------------- /misc/pkgos-show-control-depends: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | TOTAL_NUM_OF_LINES=`cat debian/control | wc -l` 6 | BUILD_DEPENDS_LINE=`cat debian/control | grep -n "^Build-Depends:" | head -n 1 | cut -d":" -f1` 7 | BUILD_DEPENDS_INDEP_LINE=`cat debian/control | grep -n "^Build-Depends-Indep:" | head -n 1 | cut -d":" -f1` 8 | STANDARD_VERSION_LINE=`cat debian/control | grep -n "^Standards-Version:" | head -n 1 | cut -d":" -f1` 9 | DEPENDS_LINE=`cat debian/control | grep -n "^Depends:" | head -n 1 | cut -d":" -f1` 10 | DESCRIPTION_LINE=`cat debian/control | grep -n "^Description:" | head -n 1 | cut -d":" -f1` 11 | 12 | # Params: $1 line start 13 | # $2 line end 14 | show_part_of_file () { 15 | LINE_END=$((${2} - 1)) 16 | TMP_FILE=`mktemp -t pkgos-show-control-depends.XXXXXX` || exit 1 17 | head -n ${LINE_END} debian/control >${TMP_FILE} 18 | LINE_START=$(($LINE_END - ${1} + 1)) 19 | tail -n ${LINE_START} ${TMP_FILE} 20 | rm ${TMP_FILE} 21 | } 22 | 23 | # Show Build-Depends: 24 | show_part_of_file ${BUILD_DEPENDS_LINE} ${BUILD_DEPENDS_INDEP_LINE} 25 | 26 | # Show Build-Depends-Indep: 27 | show_part_of_file ${BUILD_DEPENDS_INDEP_LINE} ${STANDARD_VERSION_LINE} 28 | 29 | # Show Depends: 30 | show_part_of_file ${DEPENDS_LINE} ${DESCRIPTION_LINE} 31 | -------------------------------------------------------------------------------- /misc/pkgos-testr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | PYTHON=${1} 6 | if [ -z "$PYTHON" ]; then 7 | echo "ERROR: Missing python version argument" 8 | echo "Usage: pkgos-testr []" 9 | exit 1 10 | fi 11 | 12 | PY_MAJOR=$(echo $PYTHON | cut -d . -f 1) 13 | SCOPE=${2} 14 | 15 | TEMP_REZ=`mktemp -t` 16 | 17 | function finish { 18 | rm -rf .testrepository 19 | rm -f $TEMP_REZ 20 | } 21 | trap finish EXIT 22 | 23 | echo "===> Testing for python$PYTHON" 24 | rm -rf .testrepository 25 | testr init 26 | PYTHON=python$PYTHON PYTHONPATH=`pwd` testr run --subunit $SCOPE | tee $TEMP_REZ | subunit2pyunit 27 | cat $TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats 28 | testr slowest 29 | echo "===> Testing with python$PYTHON complete." 30 | -------------------------------------------------------------------------------- /pkgos.make: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*-, you silly Emacs! 2 | # vim: set ft=make: 3 | 4 | DEBVERS ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') 5 | VERSION ?= $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//') 6 | DEBFLAVOR ?= $(shell dpkg-parsechangelog | grep -E ^Distribution: | cut -d" " -f2) 7 | DEBPKGNAME ?= $(shell dpkg-parsechangelog | grep -E ^Source: | cut -d" " -f2) 8 | UPSTREAM_GIT ?= git://github.com/openstack/$(DEBPKGNAME).git 9 | GIT_TAG ?= $(shell echo '$(VERSION)' | sed -e 's/~/_/') 10 | MANIFEST_EXCLUDE_STANDARD ?= $(DEBPKGNAME) 11 | DEBIAN_BRANCH ?= $(shell cat debian/gbp.conf | grep debian-branch | cut -d'=' -f2 | awk '{print $1}') 12 | 13 | gen-init-configurations: 14 | # Create the init scripts and systemd unit files from the template 15 | for i in `ls -1 debian/*.init.in` ; do \ 16 | MYINIT=`echo $$i | sed s/.init.in//` ; \ 17 | cp $$i $$MYINIT.init ; \ 18 | cat /usr/share/openstack-pkg-tools/init-script-template >>$$MYINIT.init ; \ 19 | pkgos-gen-systemd-unit $$i ; \ 20 | done 21 | # If there's an upstart.in file, use that one instead of the generated one 22 | for i in `ls -1 debian/*.upstart.in` ; do \ 23 | MYPKG=`echo $$i | sed s/.upstart.in//` ; \ 24 | cp $$MYPKG.upstart.in $$MYPKG.upstart ; \ 25 | done 26 | # Generate the upstart job if there's no already existing .upstart.in 27 | for i in `ls debian/*.init.in` ; do \ 28 | MYINIT=`echo $$i | sed s/.init.in/.upstart.in/` ; \ 29 | if ! [ -e $$MYINIT ] ; then \ 30 | pkgos-gen-upstart-job $$i ; \ 31 | fi \ 32 | done 33 | # If there's a service.in file, use that one instead of the generated one 34 | for i in `ls -1 debian/*.service.in`; do \ 35 | MYPKG=`echo $$i | sed s/.service.in//` ; \ 36 | cp $$MYPKG.service.in $$MYPKG.service ; \ 37 | done 38 | # Generate the systemd unit if there's no already existing .service.in 39 | for i in `ls debian/*.init.in` ; do \ 40 | MYINIT=`echo $$i | sed s/.init.in/.service.in/` ; \ 41 | if ! [ -e $$MYINIT ] ; then \ 42 | pkgos-gen-systemd-unit $$i ; \ 43 | fi \ 44 | done 45 | 46 | override_dh_systemd_enable: gen-init-configurations 47 | dh_systemd_enable 48 | 49 | override_dh_installinit: gen-init-configurations 50 | dh_installinit --error-handler=true 51 | 52 | gen-author-list: 53 | git log --format='%aN <%aE>' | awk '{arr[$$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d' ' -f2- 54 | 55 | gen-upstream-changelog: 56 | git checkout master || git checkout upstream/master 57 | git reset --hard $(GIT_TAG) 58 | git log >$(CURDIR)/../CHANGELOG 59 | git checkout debian/$(DEBFLAVOR) 60 | mv $(CURDIR)/../CHANGELOG $(CURDIR)/debian/CHANGELOG 61 | git add $(CURDIR)/debian/CHANGELOG 62 | git commit -a -m "Updated upstream changelog" 63 | 64 | override_dh_installchangelogs: 65 | if [ -e $(CURDIR)/debian/CHANGELOG ] ; then \ 66 | dh_installchangelogs $(CURDIR)/debian/CHANGELOG ; \ 67 | else \ 68 | dh_installchangelogs ; \ 69 | fi 70 | 71 | get-orig-source: 72 | uscan --verbose --force-download --rename --destdir=../build-area 73 | 74 | fetch-upstream-remote: 75 | git remote add upstream $(UPSTREAM_GIT) || true 76 | git fetch upstream 77 | 78 | gen-orig-xz: 79 | git tag -v $(GIT_TAG) || true 80 | if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] ; then \ 81 | git archive --prefix=$(DEBPKGNAME)-$(VERSION)/ $(GIT_TAG) | xz >../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ; \ 82 | fi 83 | [ ! -e ../build-area ] && mkdir ../build-area || true 84 | [ ! -e ../build-area/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] && cp ../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ../build-area 85 | 86 | gen-orig-gz: 87 | git tag -v $(GIT_TAG) || true 88 | if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.gz ] ; then \ 89 | git archive --prefix=$(DEBPKGNAME)-$(VERSION)/ $(GIT_TAG) | gzip >../$(DEBPKGNAME)_$(VERSION).orig.tar.gz ; \ 90 | fi 91 | [ ! -e ../build-area ] && mkdir ../build-area || true 92 | [ ! -e ../build-area/$(DEBPKGNAME)_$(VERSION).orig.tar.gz ] && cp ../$(DEBPKGNAME)_$(VERSION).orig.tar.gz ../build-area 93 | 94 | gen-orig-bz2: 95 | git tag -v $(GIT_TAG) || true 96 | if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.bz2 ] ; then \ 97 | git archive --prefix=$(DEBPKGNAME)-$(VERSION)/ $(GIT_TAG) | bzip2 >../$(DEBPKGNAME)_$(VERSION).orig.tar.bz2 ; \ 98 | fi 99 | [ ! -e ../build-area ] && mkdir ../build-area || true 100 | [ ! -e ../build-area/$(DEBPKGNAME)_$(VERSION).orig.tar.bz2 ] && cp ../$(DEBPKGNAME)_$(VERSION).orig.tar.bz2 ../build-area 101 | 102 | get-master-branch: 103 | if ! git checkout master ; then \ 104 | echo "No upstream branch: checking out" ; \ 105 | git checkout -b master upstream/master ; \ 106 | fi 107 | git checkout $(DEBIAN_BRANCH) 108 | 109 | get-vcs-source: 110 | $(CURDIR)/debian/rules fetch-upstream-remote 111 | $(CURDIR)/debian/rules gen-orig-xz 112 | $(CURDIR)/debian/rules get-master-branch 113 | 114 | versioninfo: 115 | echo $(VERSION) > versioninfo 116 | 117 | display-po-stats: 118 | cd $(CURDIR)/debian/po ; for i in *.po ; do \ 119 | echo -n $$i": " ; \ 120 | msgfmt -o /dev/null --statistic $$i ; \ 121 | done 122 | 123 | call-for-po-trans: 124 | podebconf-report-po --call --withtranslators --languageteam 125 | 126 | regen-manifest-patch: 127 | quilt pop -a || true 128 | quilt push install-missing-files.patch 129 | git checkout MANIFEST.in 130 | git ls-files --no-empty-directory --exclude-standard $(MANIFEST_EXCLUDE_STANDARD) | grep -v '.py$$' | grep -v LICENSE | sed -n 's/.*/include &/gp' >> MANIFEST.in 131 | quilt refresh 132 | quilt pop -a 133 | 134 | override_dh_gencontrol: 135 | if dpkg-vendor --derives-from ubuntu ; then \ 136 | dh_gencontrol -- -T$(CURDIR)/debian/ubuntu_control_vars ; \ 137 | else \ 138 | dh_gencontrol -- -T$(CURDIR)/debian/debian_control_vars ; \ 139 | fi 140 | 141 | .PHONY: get-vcs-source get-orig-source override_dh_installinit regen-manifest-patch call-for-po-trans display-po-stats versioninfo 142 | -------------------------------------------------------------------------------- /pkgos_func: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # -*- mode: shell-script -*- 3 | 4 | pkgos_gen_pass () { 5 | i=$(dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum) 6 | echo ${i% *} 7 | } 8 | 9 | # This function removes a section, because we need that in the case 10 | # of an upgrade from one version to the next. It is for example 11 | # needed for keystone to upgrade from Grizzly to Havana. 12 | # Params: 13 | # $1 Init file path 14 | # $2 Section to remove 15 | pkgos_remove_section () { 16 | local REMOVESEC_INIFILE REMOVESEC_SEARCH_SECTION REMOVESEC_INIFILE_CNT REMOVESEC_LINE REMOVESEC_FOUND_SECTION REMOVESEC_START_LINE REMOVESEC_END_LINE 17 | REMOVESEC_INIFILE=${1} 18 | REMOVESEC_SEARCH_SECTION=${2} 19 | if [ ! -r ${REMOVESEC_INIFILE} ] ; then return ; fi 20 | 21 | # Iterate through all lines of the file to search for section start/end line number 22 | REMOVESEC_INIFILE_CNT=0 23 | REMOVESEC_FOUND_SECTION="" 24 | REMOVESEC_START_LINE="" 25 | REMOVESEC_END_LINE="" 26 | while read REMOVESEC_LINE ; do 27 | REMOVESEC_INIFILE_CNT=$((${REMOVESEC_INIFILE_CNT} + 1 )) 28 | if echo ${REMOVESEC_LINE} | grep -q '^[ \t]*\[.*\][ \t]*$' ; then 29 | REMOVESEC_FOUND_SECTION=`echo ${REMOVESEC_LINE} | sed -e 's/\[//' | sed -e 's/\]//'` 30 | echo "Found section: ${REMOVESEC_FOUND_SECTION}" 31 | if [ "${REMOVESEC_FOUND_SECTION}" = "${REMOVESEC_SEARCH_SECTION}" ] ; then 32 | REMOVESEC_START_LINE=$(( ${REMOVESEC_INIFILE_CNT} - 1 )) 33 | else 34 | if [ -n "${REMOVESEC_START_LINE}" ] && [ -z "${REMOVESEC_END_LINE}" ] ; then 35 | REMOVESEC_END_LINE=$(( ${REMOVESEC_INIFILE_CNT} -1 )) 36 | fi 37 | fi 38 | fi 39 | done < ${REMOVESEC_INIFILE} 40 | 41 | 42 | # Case where the section is last in the file 43 | if [ -n "${REMOVESEC_START_LINE}" ] && [ -z "${REMOVESEC_END_LINE}" ] ; then 44 | REMOVESEC_END_LINE=${REMOVESEC_INIFILE_CNT} 45 | fi 46 | 47 | # Section found, remove it! 48 | if [ -n "${REMOVESEC_START_LINE}" ] && [ -n "${REMOVESEC_END_LINE}" ] ; then 49 | REMOVESEC_CONF_LINES_NUM=`wc -l ${REMOVESEC_INIFILE} | cut -d" " -f1` 50 | REMOVESEC_CUT_END=$((${REMOVESEC_CONF_LINES_NUM} - ${REMOVESEC_END_LINE} )) 51 | REMOVESEC_TMPFILE=`mktemp -t pkgos_removesec.XXXXXX` 52 | head -n ${REMOVESEC_START_LINE} ${REMOVESEC_INIFILE} >${REMOVESEC_TMPFILE} 53 | tail -n ${REMOVESEC_CUT_END} ${REMOVESEC_INIFILE} >>${REMOVESEC_TMPFILE} 54 | cat <${REMOVESEC_TMPFILE} >${REMOVESEC_INIFILE} 55 | rm ${REMOVESEC_TMPFILE} 56 | fi 57 | } 58 | 59 | # Using sed to set passwords with arguments on the command line makes 60 | # it possible to see the new passwords using ps. This function creates 61 | # a temp file which is used as a script for sed (using the -f option). 62 | # This is safe because what's put in the file is done with echo, which 63 | # is a built-in shell command, so it will not appear in /proc. 64 | # Params: 65 | # $1 Sed script to replace values in a config file 66 | # $2 Config file to change 67 | pkgos_safesed () { 68 | local SAFESED_SCRIPT SAFESED_CONFIG_FILENAME SAFESED_TMPFILE 69 | SAFESED_SCRIPT=${1} 70 | SAFESED_CONFIG_FILENAME=${2} 71 | 72 | SAFESED_TMPFILE=`mktemp -t pkgos_safe_sed.XXXXXX` 73 | echo "${SAFESED_SCRIPT}" >${SAFESED_TMPFILE} 74 | sed -i -f ${SAFESED_TMPFILE} ${SAFESED_CONFIG_FILENAME} 75 | rm ${SAFESED_TMPFILE} 76 | } 77 | 78 | # Params: $1 = set or get (set means read mode and return a directive value, get means write a new value in it) 79 | # $2 = config file path (example: /etc/nova/nova.conf) 80 | # $3 = .ini file section (example: DEFAULT) 81 | # $4 = directive name (example: sql_connection) 82 | # $5 = only present in "set" mode: new value to replace in the .ini file 83 | # Note that if $3 = NO_SECTION, then get or set mode will not manage sections at all, 84 | # and will totally ignore the sections in the .ini file. 85 | # 86 | # Example (get the value of keystone hostname in your Nova box): 87 | # parse_ini_file /etc/nova/api-paste.ini filter:authtoken auth_host 88 | # 89 | # Returns: $RET: either NOT_FOUND, or the (previous, in the case of set) value of the searched directive 90 | pkgos_inifile () { 91 | 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 92 | if [ "${1}" = "-shinc" ] ; then 93 | INIFILE_SHELL_INCLUDE=yes 94 | shift 95 | else 96 | INIFILE_SHELL_INCLUDE=no 97 | fi 98 | INIFILE_ACCESS_MODE=${1} ; INIFILE_MYCONFIG=${2} ; INIFILE_SEARCH_SECTION=${3} ; SEARCH_DIRECTIVE=${4} 99 | if [ "${PKGOS_VERBOSE}" = "yes" ] ; then 100 | if [ "x${INIFILE_ACCESS_MODE}" = "xset" ] ; then 101 | echo "pkgos_inifile: Setting value in ${INIFILE_MYCONFIG}:[${INIFILE_SEARCH_SECTION}]/${SEARCH_DIRECTIVE}" 102 | else 103 | echo "pkgos_inifile: Getting value in ${INIFILE_MYCONFIG}:[${INIFILE_SEARCH_SECTION}]/${SEARCH_DIRECTIVE}" 104 | fi 105 | fi 106 | if [ "x${INIFILE_ACCESS_MODE}" = "xset" ] ; then INIFILE_NEW_VALUE=${5} ; else INIFILE_NEW_VALUE="pkgos_inifile_function_called_with_wrong_access_mode" ; fi 107 | 108 | INIFILE_CNT=0 109 | RET=NOT_FOUND 110 | if [ ! -r "${INIFILE_MYCONFIG}" ] ; then 111 | if [ "${PKGOS_VERBOSE}" = "yes" ] ; then echo "Config file ${INIFILE_MYCONFIG} not readable: exiting" ; fi 112 | return 113 | fi 114 | 115 | # Iterate through all lines of the file 116 | while read INIFILE_LINE ; do 117 | INIFILE_CNT=$((${INIFILE_CNT} + 1 )) 118 | # This is a section block: [DEFAULT] 119 | if echo ${INIFILE_LINE} | grep -q '^[ \t]*\[.*\][ \t]*$' ; then 120 | if [ ! "${INIFILE_SEARCH_SECTION}" = "NO_SECTION" ] ; then 121 | INIFILE_SECTION=`echo ${INIFILE_LINE} | sed -e 's/\[//' -e 's/\]//'` 122 | #echo "===> $INIFILE_SECTION" 123 | fi 124 | continue 125 | fi 126 | # If we aren't in the section we're searching for, let's end things here for this line 127 | if ! [ "${INIFILE_SECTION}" = "${INIFILE_SEARCH_SECTION}" ] ; then 128 | continue 129 | fi 130 | # This is a directive: auth_host = 127.0.0.1 131 | if echo ${INIFILE_LINE} | grep -q '^[;#]*[ \t]*[\._\/a-zA-Z0-9]*[ \t]*[=\:][ \t]*' ; then 132 | # This is a commented out directive, let's remove the comment 133 | # if there's no such active directive in the file 134 | if grep -q '^[#;][ \t]*[\._\/a-zA-Z0-9]*[ \t]*[=\:][ \t]*' ${INIFILE_MYCONFIG} ; then 135 | if echo ${INIFILE_LINE} | grep -q '^[#;][ \t]*'${SEARCH_DIRECTIVE}'[ \t]*[=\:][ \t]*' ; then 136 | INIFILE_LINE=`echo ${INIFILE_LINE} | sed -e 's/^#//'` 137 | fi 138 | fi 139 | # This is a directive which uses the equal sign (directive = value) 140 | if echo ${INIFILE_LINE} | grep -q '^[ \t]*[\._\/a-zA-Z0-9]*[ \t]*=[ \t]*' ; then 141 | INIFILE_DIRECTIVE=`echo ${INIFILE_LINE} | cut -d= -f1 | awk '{print $1}'` 142 | DIRECTIVE_TYPE="equal" 143 | INIFILE_VALUE=`echo ${INIFILE_LINE} | cut -d= -f2 | sed -e 's/^[ \t]//'` 144 | #echo ${INIFILE_DIRECTIVE}=${INIFILE_VALUE} 145 | # This one uses the semi-column sign (/directive: value) 146 | else 147 | INIFILE_DIRECTIVE=`echo ${INIFILE_LINE} | cut -d':' -f1 | awk '{print $1}'` 148 | DIRECTIVE_TYPE="dots" 149 | INIFILE_VALUE=`echo ${INIFILE_LINE} | cut -d':' -f2 | sed -e 's/^[ \t]//'` 150 | #echo ${INIFILE_DIRECTIVE}: ${INIFILE_VALUE} 151 | fi 152 | if [ "${INIFILE_SECTION}" = "${INIFILE_SEARCH_SECTION}" ] && [ "${INIFILE_DIRECTIVE}" = "${SEARCH_DIRECTIVE}" ] ; then 153 | RET=${INIFILE_VALUE} 154 | if [ "x${INIFILE_ACCESS_MODE}" = "xset" ] ; then 155 | if [ "${DIRECTIVE_TYPE}" = "equal" ] ; then 156 | if [ "${INIFILE_SHELL_INCLUDE}" = "yes" ] ; then 157 | pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}'='${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} 158 | else 159 | pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}' = '${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} 160 | fi 161 | else 162 | pkgos_safesed ${INIFILE_CNT}' s|.*|'${INIFILE_DIRECTIVE}': '${INIFILE_NEW_VALUE}'|' ${INIFILE_MYCONFIG} 163 | fi 164 | fi 165 | return 166 | fi 167 | # This is a comment block 168 | elif echo $INIFILE_LINE | grep -q '^[ \t]*#.*$' ; then 169 | echo -n "" 170 | fi 171 | done < ${INIFILE_MYCONFIG} 172 | } 173 | 174 | # Read the value of a directive in a config file, 175 | # then prompt the user about it. 176 | # Example (options in this order please...): 177 | # pkgos_read_config -p medium /etc/keystone/keystone.conf auth_token keystone/auth-token DEFAULT 178 | # To be used in: config 179 | pkgos_read_config () { 180 | local READ_CONFIG_DIRECTIVE CONF_PATH READ_CONFIG_DEBCONF_NAME READ_CONFIG_SECTION FSET_SEEN READ_CONFIG_MY_PRIORITY 181 | if [ "${1}" = "-p" ] ; then 182 | READ_CONFIG_MY_PRIORITY=${2} 183 | shift 184 | shift 185 | else 186 | READ_CONFIG_MY_PRIORITY=high 187 | fi 188 | CONF_PATH=${1} 189 | READ_CONFIG_SECTION=${2} 190 | READ_CONFIG_DIRECTIVE=${3} 191 | READ_CONFIG_DEBCONF_NAME=${4} 192 | 193 | pkgos_inifile get ${CONF_PATH} ${READ_CONFIG_SECTION} ${READ_CONFIG_DIRECTIVE} 194 | if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then 195 | db_set ${READ_CONFIG_DEBCONF_NAME} ${RET} 196 | fi 197 | db_input ${READ_CONFIG_MY_PRIORITY} ${READ_CONFIG_DEBCONF_NAME} || true 198 | db_go 199 | db_get ${READ_CONFIG_DEBCONF_NAME} 200 | } 201 | 202 | # Read the current configuration for rabbitMQ and sets that into debconf 203 | # Params: $1 Path to config file 204 | # $2 Section in the config file 205 | # $3 prefix for the debconf template (eg: if we have nova/rabbit_host, then use "nova") 206 | # To be used in: config 207 | # Example call: pkgos_rabbit_read_conf /etc/nova/nova.conf DEFAULT nova 208 | pkgos_rabbit_read_conf () { 209 | local RB_CONF_PATH RB_SECTION RB_DEBCONF_PREFIX 210 | RB_CONF_PATH=${1} 211 | RB_SECTION=${2} 212 | RB_DEBCONF_PREFIX=${3} 213 | 214 | pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_host ${RB_DEBCONF_PREFIX}/rabbit_host 215 | pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_userid ${RB_DEBCONF_PREFIX}/rabbit_userid 216 | pkgos_read_config ${RB_CONF_PATH} ${RB_SECTION} rabbit_password ${RB_DEBCONF_PREFIX}/rabbit_password 217 | } 218 | 219 | # Write the configuration for rabbitMQ 220 | # Params: $1 Path to config file 221 | # $2 Section in the config file 222 | # $3 prefix for the debconf template (eg: if we have nova/rabbit_host, then use "nova") 223 | # To be used in: postinst 224 | # Example call: pkgos_rabbit_write_conf /etc/nova/nova.conf DEFAULT nova 225 | pkgos_rabbit_write_conf () { 226 | local RB_CONF_PATH RB_SECTION RB_DEBCONF_PREFIX 227 | RB_CONF_PATH=${1} 228 | RB_SECTION=${2} 229 | RB_DEBCONF_PREFIX=${3} 230 | 231 | db_get ${RB_DEBCONF_PREFIX}/rabbit_host 232 | pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_host ${RET} 233 | 234 | db_get ${RB_DEBCONF_PREFIX}/rabbit_userid 235 | pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_userid ${RET} 236 | 237 | db_get ${RB_DEBCONF_PREFIX}/rabbit_password 238 | pkgos_inifile set ${RB_CONF_PATH} ${RB_SECTION} rabbit_password ${RET} 239 | } 240 | 241 | # Read the connection directive from a config file 242 | # and fills the dbc_* variable accordingly, 243 | # then call dbconfig to do the actual configuration. 244 | # To be used in: config 245 | # Example call: pkgos_dbc_read_conf -pkg glance-common /etc/glance/glance-registry.conf glance DEFAULT sql_connection $@ 246 | pkgos_dbc_read_conf () { 247 | 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 248 | # This works around a bug in either dpkg, apt or debconf: in fact, 249 | # likely in debconf, the variable DPKG_MAINTSCRIPT_PACKAGE isn't 250 | # always set as it should. 251 | if [ "${1}" = "-pkg" ] ; then 252 | if [ -z "${DPKG_MAINTSCRIPT_PACKAGE}" ] ; then 253 | DPKG_MAINTSCRIPT_PACKAGE=$2 254 | fi 255 | shift 256 | shift 257 | fi 258 | CONF_PATH=${1} 259 | CONN_SECTION=${2} 260 | CONN_DIRECTIVE=${3} 261 | PKG_NAME=${4} 262 | # Do not remove what's bellow. 263 | # We need to shift, because we're using $@ in the dbc_go call later 264 | shift 265 | shift 266 | shift 267 | shift 268 | 269 | db_input high ${PKG_NAME}/configure_db || true 270 | db_go || true 271 | db_get ${PKG_NAME}/configure_db 272 | 273 | DEFAULT_DBNAME=$(echo ${PKG_NAME}db | sed s/-//g) 274 | if [ "$RET" = "true" ] && [ -f /usr/share/dbconfig-common/dpkg/config ] ; then 275 | . /usr/share/dbconfig-common/dpkg/config 276 | if [ -e "${CONF_PATH}" ] ; then 277 | pkgos_inifile get ${CONF_PATH} ${CONN_SECTION} ${CONN_DIRECTIVE} 278 | if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then 279 | CONN_STRING=${RET} 280 | fi 281 | else 282 | CONN_STRING="" 283 | fi 284 | PARSED_DB_TYPE=${CONN_STRING%%:*} 285 | # If we have an undefined SQL type, we go back to a more sane default (eg: SQLite) 286 | case "${PARSED_DB_TYPE}" in 287 | sqlite|mysql|pgsql) 288 | ;; 289 | postgresql*) 290 | PARSED_DB_TYPE=pgsql 291 | ;; 292 | *) 293 | CONN_STRING="sqlite:///var/lib/${PKG_NAME}/${DEFAULT_DBNAME}" 294 | PARSED_DB_TYPE="sqlite" 295 | ;; 296 | esac 297 | if [ "${PARSED_DB_TYPE}" = "sqlite" ] ; then 298 | if [ "${CONN_STRING}" = "sqlite:///${PKG_NAME}.db" ] ; then 299 | CONN_STRING="sqlite:///var/lib/${PKG_NAME}/${DEFAULT_DBNAME}" 300 | fi 301 | PARSED_DB_PATH=${CONN_STRING#sqlite://} 302 | if [ -z "${PARSED_DB_PATH}" ] ; then 303 | PARSED_DB_PATH=/var/lib/${PKG_NAME}/${DEFAULT_DBNAME} 304 | fi 305 | dbc_basepath=`dirname "${PARSED_DB_PATH}"` 306 | dbc_dbname=`basename "${PARSED_DB_PATH}"` 307 | dbc_dbtypes="sqlite3, mysql, pgsql" 308 | else 309 | ADDR=${CONN_STRING#*sql://} 310 | BEFORE_AT=${ADDR%%@*} 311 | AFTER_AT=${ADDR#*@} 312 | SERVER_PORT=${AFTER_AT%%/*} 313 | 314 | PARSED_USER=${BEFORE_AT%%:*} 315 | PARSED_PASS=${BEFORE_AT#*:} 316 | PARSED_DB_NAME=${AFTER_AT#*/} 317 | PARSED_SERVER=${SERVER_PORT%%:*} 318 | case "${SERVER_PORT}" in 319 | *:*) 320 | PARSED_PORT=${SERVER_PORT#*:} 321 | ;; 322 | *) 323 | PARSED_PORT="" 324 | ;; 325 | esac 326 | if [ -n "${PARSED_USER}" ] && [ -n "${PARSED_PASS}" ] && [ -n "${PARSED_SERVER}" ] && [ -n "${PARSED_DB_NAME}" ] ; then 327 | dbc_dbuser=${PARSED_USER} 328 | dbc_dbpass=${PARSED_PASS} 329 | dbc_dbserver=${PARSED_SERVER} 330 | dbc_dbport=${PARSED_PORT} 331 | dbc_dbname=${PARSED_DB_NAME} 332 | fi 333 | if [ "${PARSED_DB_TYPE}" = "mysql" ] ; then 334 | dbc_dbtypes="mysql, pgsql, sqlite3" 335 | else 336 | dbc_dbtypes="pgsql, mysql, sqlite3" 337 | fi 338 | dbc_authmethod_user="password" 339 | fi 340 | dbc_mysql_createdb_encoding="UTF8" 341 | dbc_pgsql_createdb_encoding="UTF8" 342 | echo "PKG-Openstack now calling: dbc_go "${DPKG_MAINTSCRIPT_PACKAGE} $@ 343 | dbc_go "${DPKG_MAINTSCRIPT_PACKAGE}" $@ 344 | fi 345 | } 346 | 347 | # Perform a MySQL query in a safe way (eg: no password or queries in the command line) 348 | pkgos_mysql_query () { 349 | local MYSQL_Q_TMP MYSQL_P_TMP MYSQL_DBUSER MYSQL_DBPASS MYSQL_DBHOST MYSQL_DBPORT MYSQL_DBNAME MYSQL_QUERY MY_PORT 350 | MYSQL_DBUSER=${1} 351 | MYSQL_DBPASS=${2} 352 | MYSQL_DBHOST=${3} 353 | MYSQL_DBPORT=${4} 354 | MYSQL_DBNAME=${5} 355 | MYSQL_QUERY=${6} 356 | 357 | MYSQL_P_TMP=`mktemp -t OpenStack-mysql-statement.XXXXXXXXXX` 358 | MYSQL_Q_TMP=`mktemp -t OpenStack-mysql-statement.XXXXXXXXXX` 359 | echo "[client] 360 | password=${MYSQL_DBPASS}" >${MYSQL_P_TMP} 361 | echo ${MYSQL_QUERY} >${MYSQL_Q_TMP} 362 | if [ -n "${MYSQL_DBPORT}" ] ; then 363 | MY_PORT="--port=${MYSQL_DBPORT}" 364 | fi 365 | mysql --defaults-file=${MYSQL_P_TMP} -h${MYSQL_DBHOST} ${MY_PORT} -u${MYSQL_DBUSER} -D${MYSQL_DBNAME} < ${MYSQL_Q_TMP} 366 | rm -f ${MYSQL_Q_TMP} ${MYSQL_P_TMP} 367 | } 368 | 369 | 370 | # Read values configured by dbconfig-common, 371 | # and set a connection directive accordingly 372 | # in a configuration file 373 | # 374 | # Caller should use something like this: 375 | # pkgos_dbc_postinst /etc/keystone/keystone.conf keystone connection $@ 376 | # since dbc_go expect $@ as well. 377 | pkgos_dbc_postinst () { 378 | local DBC_POST_CONF_PATH CONF_DIR DBC_POST_CONF_FNAME PKG_NAME SUITE 379 | if [ "${1}" = "--suite" ] ; then 380 | SUITE=${2} 381 | shift 382 | shift 383 | else 384 | SUITE=${4} 385 | fi 386 | DBC_POST_CONF_PATH=${1} 387 | CONN_SECTION=${2} 388 | CONN_DIRECTIVE=${3} 389 | PKG_NAME=${4} 390 | shift 391 | shift 392 | shift 393 | shift 394 | 395 | CONF_DIR=`dirname ${DBC_POST_CONF_PATH}` 396 | DBC_POST_CONF_FNAME=`basename ${DBC_POST_CONF_PATH}` 397 | 398 | # Create config files if they don't exist 399 | if [ ! -d ${CONF_DIR} ] ; then 400 | mkdir -p ${CONF_DIR} 401 | fi 402 | chmod 0770 ${CONF_DIR} 403 | chown ${SUITE}:${SUITE} ${CONF_DIR} 404 | if [ ! -e ${DBC_POST_CONF_PATH} ] ; then 405 | install -D -m 0660 -o ${SUITE} -g ${SUITE} /usr/share/${DPKG_MAINTSCRIPT_PACKAGE}/${DBC_POST_CONF_FNAME} ${DBC_POST_CONF_PATH} 406 | fi 407 | db_get ${PKG_NAME}/configure_db 408 | if [ "$RET" = "true" ] && [ -r /usr/share/dbconfig-common/dpkg/postinst ] ; then 409 | . /usr/share/dbconfig-common/dpkg/postinst 410 | dbc_dbfile_owner="${SUITE}:${SUITE}" 411 | dbc_mysql_createdb_encoding="UTF8" 412 | dbc_pgsql_createdb_encoding="UTF8" 413 | dbc_go "${DPKG_MAINTSCRIPT_PACKAGE}" $@ 414 | if [ "$dbc_install" = "true" ] ; then 415 | case "$dbc_dbtype" in 416 | mysql) 417 | if [ -n "$dbc_dbport" ] ; then 418 | dbport=:$dbc_dbport 419 | fi 420 | SQL_CONNECTION="mysql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname" 421 | # Set the DB as UTF8 422 | Q="ALTER DATABASE ${dbc_dbname} CHARACTER SET utf8 COLLATE utf8_unicode_ci" 423 | pkgos_mysql_query ${dbc_dbuser} ${dbc_dbpass} ${dbc_dbserver:-localhost} "${dbport}" ${dbc_dbname} "${Q}" 424 | ;; 425 | postgresql*|pgsql) 426 | if [ -n "$dbc_dbport" ] ; then 427 | dbport=:$dbc_dbport 428 | fi 429 | SQL_CONNECTION="postgresql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname" 430 | ;; 431 | *) 432 | SQL_CONNECTION="sqlite:///$dbc_basepath/$dbc_dbname" 433 | ;; 434 | esac 435 | pkgos_inifile set ${DBC_POST_CONF_PATH} ${CONN_SECTION} ${CONN_DIRECTIVE} ${SQL_CONNECTION} 436 | fi 437 | fi 438 | } 439 | 440 | # Reads auth_host, admin_tenant_name, admin_user and admin_password 441 | # values with debconf 442 | # Prototype: pkgos_read_admin_creds
443 | # Example calls: 444 | # pkgos_read_admin_creds /etc/glance/glance-api.conf glance keystone_authtoken 445 | # To be used in: config 446 | pkgos_read_admin_creds () { 447 | local READ_ADMIN_CRED_CONF_FNAME READ_ADMIN_CRED_PKG_NAME READ_ADMIN_CRED_SEARCH_SECTION 448 | READ_ADMIN_CRED_CONF_FNAME=${1} 449 | READ_ADMIN_CRED_SEARCH_SECTION=${2} 450 | READ_ADMIN_CRED_PKG_NAME=${3} 451 | 452 | if [ ! -r "${READ_ADMIN_CRED_CONF_FNAME}" ] ; then 453 | # If the file doesn't exist, just ask... 454 | db_input high ${READ_ADMIN_CRED_PKG_NAME}/auth-host || true 455 | else 456 | if grep -q auth_host ${READ_ADMIN_CRED_CONF_FNAME} ; then 457 | pkgos_read_config ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} auth_host ${READ_ADMIN_CRED_PKG_NAME}/auth-host 458 | else 459 | # This is needed for l3_agent.ini 460 | if grep -q auth_url ${READ_ADMIN_CRED_CONF_FNAME} ; then 461 | pkgos_inifile get ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} auth_url 462 | if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then 463 | NO_PROTO=${RET#http://} 464 | BEFORE_PORT=$(echo ${NO_PROTO} | cut -d":" -f1) 465 | if [ -z "${BEFORE_PORT}" ] ; then 466 | db_set ${READ_ADMIN_CRED_PKG_NAME}/auth-host ${BEFORE_PORT} 467 | fi 468 | fi 469 | db_input high ${READ_ADMIN_CRED_PKG_NAME}/auth-host || true 470 | db_go 471 | else 472 | echo "Couldn't find either auth_host or auth_url :(" 473 | fi 474 | fi 475 | fi 476 | 477 | 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 478 | pkgos_read_config -p medium ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} admin_user ${READ_ADMIN_CRED_PKG_NAME}/admin-user 479 | pkgos_read_config ${READ_ADMIN_CRED_CONF_FNAME} ${READ_ADMIN_CRED_SEARCH_SECTION} admin_password ${READ_ADMIN_CRED_PKG_NAME}/admin-password 480 | } 481 | 482 | # To be used in: postinst 483 | pkgos_write_admin_creds () { 484 | local WRITE_CRED_CONF_FNAME WRITE_CRED_PKG_NAME WRITE_CRED_SECTION NO_PROTO AFTER_PORT WRITE_CRED_URL 485 | WRITE_CRED_CONF_FNAME=${1} 486 | WRITE_CRED_SECTION=${2} 487 | WRITE_CRED_PKG_NAME=${3} 488 | 489 | db_get ${WRITE_CRED_PKG_NAME}/auth-host 490 | WRITE_CRED_AUTH_HOST=${RET} 491 | if grep -q auth_host ${WRITE_CRED_CONF_FNAME} ; then 492 | pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} auth_host ${RET} 493 | else 494 | # This is needed for l3_agent.ini 495 | if grep -q auth_url ${WRITE_CRED_CONF_FNAME} ; then 496 | pkgos_inifile get ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} auth_url 497 | NO_PROTO=${RET#http://} 498 | AFTER_PORT=$(echo ${NO_PROTO} | cut -d":" -f2) 499 | WRITE_CRED_URL="http://${WRITE_CRED_AUTH_HOST}:${AFTER_PORT}" 500 | pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} auth_url ${WRITE_CRED_URL} 501 | else 502 | echo "Couldn't find either auth_host or auth_url :(" 503 | fi 504 | fi 505 | db_get ${WRITE_CRED_PKG_NAME}/admin-tenant-name 506 | pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_tenant_name ${RET} 507 | db_get ${WRITE_CRED_PKG_NAME}/admin-user 508 | pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_user ${RET} 509 | db_get ${WRITE_CRED_PKG_NAME}/admin-password 510 | pkgos_inifile set ${WRITE_CRED_CONF_FNAME} ${WRITE_CRED_SECTION} admin_password ${RET} 511 | } 512 | 513 | pkgos_write_new_conf () { 514 | local WRITE_N_CONF_PKG_NAME CONF_FNAME 515 | WRITE_N_CONF_PKG_NAME=${1} 516 | CONF_FNAME=${2} 517 | 518 | SRC_PATH=/usr/share/${DPKG_MAINTSCRIPT_PACKAGE}/${CONF_FNAME} 519 | DST_DIR=/etc/${WRITE_N_CONF_PKG_NAME} 520 | DST_PATH=${DST_DIR}/${CONF_FNAME} 521 | if [ ! -d ${DST_DIR} ] ; then 522 | mkdir -p ${DST_DIR} 523 | fi 524 | chmod 0750 ${DST_DIR} 525 | chown ${WRITE_N_CONF_PKG_NAME}:${WRITE_N_CONF_PKG_NAME} ${DST_DIR} 526 | if [ ! -e ${DST_PATH} ] ; then 527 | install -D -m 640 -o ${WRITE_N_CONF_PKG_NAME} -g ${WRITE_N_CONF_PKG_NAME} ${SRC_PATH} ${DST_PATH} 528 | fi 529 | } 530 | 531 | pkgos_adduser () { 532 | local VAR_UG_PKG_NAME 533 | local VAR_UG_SHELL 534 | VAR_UG_PKG_NAME=${1} 535 | VAR_UG_SHELL=${2} 536 | 537 | if [ -z "${VAR_UG_SHELL}" ] ; then 538 | VAR_UG_SHELL='/bin/bash' 539 | fi 540 | 541 | # Create user and groups if they don't exist 542 | if ! getent group ${VAR_UG_PKG_NAME} > /dev/null 2>&1 ; then 543 | addgroup --quiet --system ${VAR_UG_PKG_NAME} 544 | fi 545 | if ! getent passwd ${VAR_UG_PKG_NAME} > /dev/null 2>&1 ; then 546 | adduser --system \ 547 | --home /var/lib/${VAR_UG_PKG_NAME} \ 548 | --no-create-home \ 549 | --quiet \ 550 | --disabled-password \ 551 | --shell ${VAR_UG_SHELL} \ 552 | --group ${VAR_UG_PKG_NAME} 553 | fi 554 | } 555 | 556 | pkgos_var_user_group () { 557 | local VAR_UG_PKG_NAME 558 | VAR_UG_PKG_NAME=${1} 559 | 560 | pkgos_adduser ${VAR_UG_PKG_NAME} 561 | 562 | # Create /var/{lib,log}/ with that user/group if it doesn't exist 563 | if [ ! -d /var/lib/${VAR_UG_PKG_NAME} ] ; then 564 | mkdir -p /var/lib/${VAR_UG_PKG_NAME}/cache 565 | fi 566 | chown ${VAR_UG_PKG_NAME}:${VAR_UG_PKG_NAME} /var/lib/${VAR_UG_PKG_NAME} 567 | if [ "${VAR_UG_PKG_NAME}" = "nova" ] ; then 568 | chmod 755 /var/lib/nova 569 | else 570 | chmod 0750 /var/lib/${VAR_UG_PKG_NAME} 571 | fi 572 | if [ ! -d /var/log/${VAR_UG_PKG_NAME} ] ; then 573 | mkdir -p /var/log/${VAR_UG_PKG_NAME} 574 | fi 575 | usermod -G adm ${VAR_UG_PKG_NAME} 576 | chown ${VAR_UG_PKG_NAME}:adm /var/log/${VAR_UG_PKG_NAME} 577 | chmod 0750 /var/log/${VAR_UG_PKG_NAME} 578 | } 579 | 580 | pkgos_init () { 581 | INIT_SCRIPT_NAME=${1} 582 | if [ -x /etc/init.d/${INIT_SCRIPT_NAME} ] ; then 583 | update-rc.d ${INIT_SCRIPT_NAME} defaults >/dev/null 584 | invoke-rc.d ${INIT_SCRIPT_NAME} start || true 585 | fi 586 | } 587 | 588 | pkgos_get_id () { 589 | SERVICE_ENDPOINT=${SERVICE_ENDPOINT:-http://127.0.0.1:35357/v2.0/} SERVICE_TOKEN=${AUTH_TOKEN} "$@" | awk '/ id / { print $4 }' 590 | } 591 | 592 | # Asks the debconf questions for registering a service and its endpoint in keystone 593 | # Prototype: pkgos_register_endpoint_config 594 | # Example: pkgos_register_endpoint_config glance 595 | # To be used in: config 596 | pkgos_register_endpoint_config () { 597 | local REG_ENDP_PKG_NAME DEFROUTE_IF DEFROUTE_IP 598 | REG_ENDP_PKG_NAME=${1} 599 | 600 | db_input high ${REG_ENDP_PKG_NAME}/register-endpoint || true 601 | db_go 602 | db_get ${REG_ENDP_PKG_NAME}/register-endpoint 603 | if [ "${RET}" = "true" ] ; then 604 | db_get ${REG_ENDP_PKG_NAME}/keystone-ip 605 | if [ -z "${RET}" ] ; then 606 | db_set ${REG_ENDP_PKG_NAME}/keystone-ip 127.0.0.1 607 | fi 608 | db_input medium ${REG_ENDP_PKG_NAME}/keystone-ip || true 609 | db_input high ${REG_ENDP_PKG_NAME}/keystone-auth-token || true 610 | 611 | db_get ${REG_ENDP_PKG_NAME}/endpoint-ip || true 612 | if [ -z "${RET}" ] ; then 613 | DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }'` 614 | 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}$'` 615 | if [ -n "${DEFROUTE_IP}" ] ; then 616 | db_set ${REG_ENDP_PKG_NAME}/endpoint-ip ${DEFROUTE_IP} 617 | fi 618 | fi 619 | db_input medium ${REG_ENDP_PKG_NAME}/endpoint-ip || true 620 | db_input medium ${REG_ENDP_PKG_NAME}/region-name || true 621 | db_go 622 | fi 623 | } 624 | 625 | # Register a service and its endpoint in keystone 626 | # Prototype: 627 | # Example: pkgos_register_endpoint_postinst glance glance image "Glance Image Service" 9292 /v1 628 | # To be used in: postinst 629 | pkgos_register_endpoint_postinst () { 630 | 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 631 | PKG_NAME=${1} 632 | SERVICE_NAME=${2} 633 | SERVICE_TYPE=${3} 634 | SERVICE_DESC=${4} 635 | SERVICE_PORT=${5} 636 | SERVICE_URL=${6} 637 | 638 | 639 | db_get ${PKG_NAME}/register-endpoint 640 | if [ "${RET}" = "true" ] ; then 641 | db_get ${PKG_NAME}/keystone-ip 642 | KEYSTONE_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` 643 | db_get ${PKG_NAME}/keystone-auth-token 644 | AUTH_TOKEN=${RET} 645 | db_get ${PKG_NAME}/endpoint-ip 646 | PKG_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` 647 | db_get ${PKG_NAME}/region-name 648 | REGION_NAME=${RET} 649 | 650 | if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT_IP}" ] && [ -n "${REGION_NAME}" ] && [ -n "${AUTH_TOKEN}" ] ; then 651 | echo "Registering service and endpoints for ${SERVICE_NAME} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}" 652 | PKG_SERVICE_ID=$(pkgos_get_id keystone --os-token ${AUTH_TOKEN} --os-endpoint http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ service-create \ 653 | --name=${SERVICE_NAME} --type=${SERVICE_TYPE} --description="${SERVICE_DESC}") 654 | PKG_ENDPOINT_ID=$(pkgos_get_id keystone --os-token ${AUTH_TOKEN} --os-endpoint http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ endpoint-create \ 655 | --region "${REGION_NAME}" --service_id=${PKG_SERVICE_ID} \ 656 | --publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \ 657 | --internalurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \ 658 | --adminurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}) 659 | else 660 | echo "Problem in endpoint parameter (IPs or otherwise)." 661 | fi 662 | # Since there's very little chance a 2nd registration of the 663 | # endpoint will be needed, we forget the value of 664 | # ${PKG_NAME}/register-endpoint. If later on the 665 | # administrator of the server upgrades, it will be asked 666 | # again, or eventually, dpkg-reconfigure can 667 | # be used. 668 | db_unregister ${PKG_NAME}/register-endpoint 669 | else 670 | echo "Will not register "${SERVICE_NAME}" endpoint this time (no user request for it)." 671 | fi 672 | # For security reasons, we don't keep the auth-token in the debconf 673 | # memory, so we purge it with db_unregister. 674 | db_unregister ${PKG_NAME}/keystone-auth-token 675 | } 676 | -------------------------------------------------------------------------------- /pkgos_insert_include: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Example call: pkgos_insert_include pkgos_func keystone.config 6 | INC=/usr/share/openstack-pkg-tools/${1} 7 | DST=debian/${2} 8 | SRC="debian/${2}.in" 9 | 10 | awk '{if ($1 == "#PKGOS-INCLUDE#") { 11 | print "### Start of included " G " library" 12 | while ((getline line < F) > 0) print line 13 | print "### End of included " G " library" 14 | } else print}' F=${INC} G=$(basename $INC) ${SRC} > ${DST} 15 | --------------------------------------------------------------------------------