/usr/bin/pkgos-debpypi is in openstack-pkg-tools 54.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | #!/bin/sh
set -e
set -x
if [ "${1}" = "-u" ] && [ -n "${2}" ] ; then
ORIG_URL="${2}"
shift
shift
fi
if [ -z "${1}" ] ; then
echo "This tool creates a template Debian package out of a PyPi package name."
echo "Once this script has run, make sure it did what you expected, then use"
echo "the newly created source package as a template. Make sure you correct"
echo "the debian/copyright file before publishing any package."
echo "Usage: ${0} package-name"
exit 1
fi
PKG_NAME=${1}
# Calculate the package name based on the command line argument
LOWER_PKG_NAME=`echo ${PKG_NAME} | awk '{print tolower($0)}'`
LOWER_PKG_NAME=`echo ${LOWER_PKG_NAME} | sed 's/_/-/g'`
if echo ${LOWER_PKG_NAME} | grep -q '^python-' ; then
DEB_PKG_NAME=${LOWER_PKG_NAME}
else
DEB_PKG_NAME=python-${LOWER_PKG_NAME}
fi
echo "===> Package name will be ${DEB_PKG_NAME}"
if [ ! -e ${PKG_NAME}.xml ] ; then
echo "===> Downloading DOAP XML record"
wget -nv "https://pypi.python.org/pypi?:action=doap&name=${PKG_NAME}" -O ${PKG_NAME}.xml
fi
# Get info from the XML document using xpath.
VERSION_STRING=`xpath -e "//release/Version/revision/text()" ${PKG_NAME}.xml 2> /dev/null`
SHORT_DESC=`xpath -e "//shortdesc/text()" ${PKG_NAME}.xml 2> /dev/null`
LONG_DESC=`xpath -e "//description/text()" ${PKG_NAME}.xml 2> /dev/null`
UP_MAINT_NAME=`xpath -e "//maintainer/foaf:Person/foaf:name/text()" ${PKG_NAME}.xml 2> /dev/null`
HOMEPAGE=`xpath -e "//homepage/@rdf:resource" ${PKG_NAME}.xml 2> /dev/null | cut -d= -f2 | sed 's#"##g'`
FIRST_LETTER=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'`
if [ -e ${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz ] ; then
ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz
else
ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.gz
fi
echo "===> Package info:
Upstream version: ${VERSION_STRING}
Author: ${UP_MAINT_NAME}
Homepage: ${HOMEPAGE}"
if [ ! -e ${ORIG} ] ; then
echo "===> Downloading ${ORIG} file"
if [ -z "${ORIG_URL}" ] ; then
ORIG_URL=https://pypi.python.org/packages/source/${FIRST_LETTER}/${PKG_NAME}/${PKG_NAME}-${VERSION_STRING}.tar.gz
fi
wget -nv "${ORIG_URL}" -O ${ORIG}
fi
echo "===> Extracting ${ORIG}"
tar -xf ${ORIG}
if ! [ ${PKG_NAME}-${VERSION_STRING} = ${DEB_PKG_NAME}-${VERSION_STRING} ] ; then
mv ${PKG_NAME}-${VERSION_STRING} ${DEB_PKG_NAME}-${VERSION_STRING}
fi
# Trying to guess the maintainer's email
if [ -r ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ] ; then
if grep -q author_email ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ; then
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.]*$'`
fi
fi
echo "===> Creating debian folder for ${DEB_PKG_NAME}"
if [ ! -d ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source ] ; then
mkdir -p ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source
fi
cd ${DEB_PKG_NAME}-${VERSION_STRING}
echo "===> Searching for sphinx doc folder"
if [ -e doc ] ; then
DOC_FOLDER=doc
elif [ -e docs ] ; then
DOC_FOLDER=docs
fi
if [ -n "${DOC_FOLDER}" ] ; then
CONFPY_FILE=`find ${DOC_FOLDER} -name 'conf.py'`
if [ -r "${CONFPY_FILE}" ] ; then
DOC_FOLDER=`dirname ${CONFPY_FILE}`
SPHINX_BUILD_DEP=", python-sphinx"
RULES_WITH=",sphinxdoc"
SUGGEST_DOC="
Suggests: ${DEB_PKG_NAME}-doc"
else
DOC_FOLDER=
SPHINX_BUILD_DEP=""
RULES_WITH=""
SUGGEST_DOC=""
fi
fi
echo "===> Checking for PBR and fixing accordingly"
# If the package uses PBR, then we need openstack-pkg-tools
if grep -q "setup_requires=\['pbr'\]" ${DEB_PKG_NAME}-${VERSION_STRING}/setup.py ; then
OSTACK_PKG_T_CTRL=", openstack-pkg-tools"
# We need a mandatory include...
# ... and the export OSLO_PACKAGE_VERSION=$(VERSION)
OSTACK_PKG_T_RULES="include /usr/share/openstack-pkg-tools/pkgos.make
export OSLO_PACKAGE_VERSION=\$(VERSION)"
else
# Otherwise, we just include it non-mandatorily, so that
# we can use ./debian/rules gen-orig-xz
OSTACK_PKG_T_CTRL=""
OSTACK_PKG_T_RULES="-include /usr/share/openstack-pkg-tools/pkgos.make"
fi
echo "Source: ${DEB_PKG_NAME}
Section: python
Priority: optional
Maintainer: PKG OpenStack <openstack-devel@lists.alioth.debian.org>
Uploaders: Thomas Goirand <zigo@debian.org>
Build-Depends: debhelper (>= 9),
dh-python,
python-setuptools,
python-all,
python3-setuptools,
python3-all${SPHINX_BUILD_DEP}${OSTACK_PKG_T_CTRL}
Standards-Version: 3.9.8
Vcs-Browser: https://anonscm.debian.org/cgit/openstack/${DEB_PKG_NAME}.git/
Vcs-Git: https://anonscm.debian.org/git/openstack/${DEB_PKG_NAME}.git
Homepage: ${HOMEPAGE}
Package: ${DEB_PKG_NAME}
Architecture: all
Depends: \${python:Depends}, \${misc:Depends}${SUGGEST_DOC}
Description: ${SHORT_DESC} - Python 2.7
${LONG_DESC}
.
This package contains the Python 2.7 module.
Package: python3-${LOWER_PKG_NAME}
Architecture: all
Depends: \${python3:Depends}, \${misc:Depends}${SUGGEST_DOC}
Description: ${SHORT_DESC} - Python 3.x
- REPLACE ME -
.
This package contains the Python 3.x module.
" >debian/control
if [ -n "${DOC_FOLDER}" ] ; then
echo "Package: python-${LOWER_PKG_NAME}-doc
Section: doc
Architecture: all
Depends: \${misc:Depends}, \${sphinxdoc:Depends}
Description: ${SHORT_DESC} - doc
- REPLACE ME -
.
This package contains the documentation.
" >>debian/control
echo "Document: ${DEB_PKG_NAME}-doc
Title: ${PKG_NAME} Documentation
Author: N/A
Abstract: Sphinx documentation for ${PKG_NAME}
Section: Programming/Python
Format: HTML
Index: /usr/share/doc/python-${LOWER_PKG_NAME}-doc/html/index.html
Files: /usr/share/doc/python-${LOWER_PKG_NAME}-doc/html/*" >debian/python-${LOWER_PKG_NAME}-doc.doc-base
fi
EDITOR=touch dch --create --package ${DEB_PKG_NAME} --distribution unstable --urgency medium -v ${VERSION_STRING}-1
rm +1
echo "9" >debian/compat
if [ -n "${AUTHOR_EMAIL}" ] ; then
UP_MAINT_AND_EMAIL="${UP_MAINT_NAME} <${AUTHOR_EMAIL}>"
else
UP_MAINT_AND_EMAIL=${UP_MAINT_NAME}
fi
echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ${PKG_NAME}
Source: ${HOMEPAGE}
Files: debian/*
Copyright: (c) 2014, Thomas Goirand <zigo@debian.org>
License: Apache-2
Files: *
Copyright: (c) 2013, ${UP_MAINT_AND_EMAIL}
License: Apache-2
License: Apache-2
Licensed under the Apache License, Version 2.0 (the \"License\");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an \"AS IS\" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian-based systems the full text of the Apache version 2.0 license
can be found in /usr/share/common-licenses/Apache-2.0.
" >debian/copyright
echo "[DEFAULT]
upstream-branch = master
debian-branch = debian/unstable
upstream-tag = %(version)s
compression = xz
[buildpackage]
export-dir = ../build-area/
" >debian/gbp.conf
if [ -n "${DOC_FOLDER}" ] ; then
SPHINX_BUILD_RULES="override_dh_sphinxdoc:
ifeq (,\$(findstring nodocs, \$(DEB_BUILD_OPTIONS)))
sphinx-build -b html ${DOC_FOLDER} debian/python-${LOWER_PKG_NAME}-doc/usr/share/doc/python-${LOWER_PKG_NAME}-doc/html
dh_sphinxdoc -O--buildsystem=python_distutils
endif
"
else
SPHINX_BUILD_RULES=""
fi
if [ -e .testr.conf ] ; then
UNIT_TEST_RULES="override_dh_auto_test:
ifeq (,\$(findstring nocheck, \$(DEB_BUILD_OPTIONS)))
@echo \"===> Running tests\"
set -e ; set -x ; for i in 2.7 \$(PYTHON3S) ; do \\
PYMAJOR=\`echo \$\$i | cut -d'.' -f1\` ; \\
echo \"===> Testing with python\$\$i (python\$\$PYMAJOR)\" ; \\
rm -rf .testrepository ; \\
testr-python\$\$PYMAJOR init ; \\
TEMP_REZ=\`mktemp -t\` ; \\
PYTHONPATH=\$(CURDIR) PYTHON=python\$\$i testr-python\$\$PYMAJOR run --subunit | tee \$\$TEMP_REZ | subunit2pyunit ; \\
cat \$\$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \\
rm -f \$\$TEMP_REZ ; \\
testr-python\$\$PYMAJOR slowest ; \\
done
endif
"
else
UNIT_TEST_RULES="override_dh_auto_test:
ifeq (,\$(findstring nocheck, \$(DEB_BUILD_OPTIONS)))
set -e ; for pyvers in \$(PYTHONS) \$(PYTHON3S); do \\
python\$\$pyvers setup.py test ; \\
done
endif
"
fi
echo "#!/usr/bin/make -f
PYTHONS:=\$(shell pyversions -vr)
PYTHON3S:=\$(shell py3versions -vr)
UPSTREAM_GIT := https://github.com/<please-user>/${PKG_NAME}.git
${OSTACK_PKG_T_RULES}
%:
dh \$@ --buildsystem=python_distutils --with python2,python3${RULES_WITH}
override_dh_auto_install:
set -e ; for pyvers in \$(PYTHONS); do \\
python\$\$pyvers setup.py install --install-layout=deb \\
--root \$(CURDIR)/debian/python-${LOWER_PKG_NAME}; \\
done
set -e ; for pyvers in \$(PYTHON3S); do \\
python\$\$pyvers setup.py install --install-layout=deb \\
--root \$(CURDIR)/debian/python3-${LOWER_PKG_NAME}; \\
done
rm -rf \$(CURDIR)/debian/python*-${LOWER_PKG_NAME}/usr/lib/python*/dist-packages/*.pth
${UNIT_TEST_RULES}
${SPHINX_BUILD_RULES}
override_dh_clean:
dh_clean -O--buildsystem=python_distutils
rm -rf build
# Commands not to run
override_dh_installcatalogs:
override_dh_installemacsen override_dh_installifupdown:
override_dh_installinfo override_dh_installmenu override_dh_installmime:
override_dh_installmodules override_dh_installlogcheck:
override_dh_installpam override_dh_installppp override_dh_installudev override_dh_installwm:
override_dh_installxfonts override_dh_gconf override_dh_icons override_dh_perl override_dh_usrlocal:
override_dh_installcron override_dh_installdebconf:
override_dh_installlogrotate override_dh_installgsettings:
" >debian/rules
chmod +x debian/rules
echo "version=3
opts=uversionmangle=s/(rc|a|b|c)/~\$1/ \\
https://pypi.debian.net/${PKG_NAME}/${PKG_NAME}-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
" >debian/watch
echo "3.0 (quilt)" >debian/source/format
echo 'extend-diff-ignore = "^[^/]*[.]egg-info/"' >debian/source/options
|