|
1 | 1 | #!/bin/sh
|
2 |
| -export PATH=$PATH:/opt/bliss/conda/venv/dahu/bin |
3 |
| -rm -rf deb_dist/ |
4 |
| -/usr/bin/python3 -m pip wheel . --no-cache-dir |
5 |
| -wheel2deb default --output-dir deb_dist --exclude numpy* |
6 |
| -cd deb_dist/python3-dahu*_amd64 |
7 |
| -dpkg-buildpackage -r -uc -us |
8 |
| -cd .. |
9 |
| -sudo dpkg -i python3-dahu*.deb |
10 |
| -cd .. |
| 2 | +# |
| 3 | +# Project: PyFAI Input/Output |
| 4 | +# https://github.com/silx-kit/pyFAI |
| 5 | +# |
| 6 | +# Copyright (C) 2015-2025 European Synchrotron Radiation Facility, Grenoble, France |
| 7 | +# |
| 8 | +# Principal author: Jérôme Kieffer ([email protected]) |
| 9 | +# |
| 10 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 11 | +# of this software and associated documentation files (the "Software"), to deal |
| 12 | +# in the Software without restriction, including without limitation the rights |
| 13 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 14 | +# copies of the Software, and to permit persons to whom the Software is |
| 15 | +# furnished to do so, subject to the following conditions: |
| 16 | +# |
| 17 | +# The above copyright notice and this permission notice shall be included in |
| 18 | +# all copies or substantial portions of the Software. |
| 19 | +# |
| 20 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 23 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 25 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 26 | +# THE SOFTWARE |
11 | 27 |
|
| 28 | +# Script that builds a debian package from this library |
| 29 | + |
| 30 | +project=dahu |
| 31 | +source_project=dahu |
| 32 | +version=$(python3 -c"import version; print(version.version)") |
| 33 | +echo version $version |
| 34 | +strictversion=$(python3 -c"import version; print(version.strictversion)") |
| 35 | +echo strictversion $strictversion |
| 36 | +debianversion=$(python3 -c"import version; print(version.debianversion)") |
| 37 | +echo debianversion $debianversion |
| 38 | + |
| 39 | +deb_name=$(echo "$source_project" | tr '[:upper:]' '[:lower:]') |
| 40 | + |
| 41 | +# target system |
| 42 | +if [ -f /etc/debian_version ] |
| 43 | +then |
| 44 | + debian_version=$(cat /etc/debian_version | cut -d. -f1 | grep -o '[0-9]*') |
| 45 | + if [ -z $debian_version ] |
| 46 | + then |
| 47 | + #we are probably on a ubuntu platform |
| 48 | + debian_version=$(< /etc/debian_version cut -d/ -f1) |
| 49 | + case $debian_version in |
| 50 | + squeeze) |
| 51 | + debian_version=6 |
| 52 | + ;; |
| 53 | + wheezy) |
| 54 | + debian_version=7 |
| 55 | + ;; |
| 56 | + jessie) |
| 57 | + debian_version=8 |
| 58 | + ;; |
| 59 | + stretch) |
| 60 | + debian_version=9 |
| 61 | + ;; |
| 62 | + buster) |
| 63 | + debian_version=10 |
| 64 | + ;; |
| 65 | + bullseye) |
| 66 | + debian_version=11 |
| 67 | + ;; |
| 68 | + bookworm) |
| 69 | + debian_version=12 |
| 70 | + ;; |
| 71 | + trixie) |
| 72 | + debian_version=13 |
| 73 | + ;; |
| 74 | + sid) |
| 75 | + debian_version=13 |
| 76 | + ;; |
| 77 | + esac |
| 78 | + fi |
| 79 | + |
| 80 | +else |
| 81 | + debian_version=0 |
| 82 | +fi |
| 83 | +target_system=debian${debian_version} |
| 84 | + |
| 85 | +project_directory="`dirname \"$0\"`" |
| 86 | +project_directory="`( cd \"$project_directory\" && pwd )`" # absolutized |
| 87 | +dist_directory=${project_directory}/dist/${target_system} |
| 88 | +build_directory=${project_directory}/build/${target_system} |
| 89 | + |
| 90 | +if [ -d /usr/lib/ccache ]; |
| 91 | +then |
| 92 | + export PATH=/usr/lib/ccache:$PATH |
| 93 | + export CCACHE_DIR=${HOME}/.ccache |
| 94 | +fi |
| 95 | + |
| 96 | +usage="usage: $(basename "$0") [options] |
| 97 | +
|
| 98 | +Build the Debian ${debian_version} package of the ${project} library. |
| 99 | +
|
| 100 | +If the build succeed the directory dist/debian${debian_version} will |
| 101 | +contains the packages. |
| 102 | +
|
| 103 | +optional arguments: |
| 104 | + --help Show this help text |
| 105 | + --install Install the packages generated at the end of |
| 106 | + the process using 'sudo dpkg' |
| 107 | + --stdeb-py3 Build using stdeb for python3 |
| 108 | + --debian9 Simulate a debian 9 Stretch system |
| 109 | + --debian10 Simulate a debian 10 Buster system |
| 110 | + --debian11 Simulate a debian 11 Bullseye system |
| 111 | + --debian12 Simulate a debian 12 Bookworm system |
| 112 | +" |
| 113 | + |
| 114 | +install=0 |
| 115 | +use_stdeb=0 |
| 116 | +stdeb_all_python=0 |
| 117 | + |
| 118 | +while : |
| 119 | +do |
| 120 | + case "$1" in |
| 121 | + -h | --help) |
| 122 | + echo "$usage" |
| 123 | + exit 0 |
| 124 | + ;; |
| 125 | + --install) |
| 126 | + install=1 |
| 127 | + shift |
| 128 | + ;; |
| 129 | + --stdeb-py2) |
| 130 | + use_stdeb=1 |
| 131 | + stdeb_all_python=0 |
| 132 | + shift |
| 133 | + ;; |
| 134 | + --stdeb-py2.py3) |
| 135 | + use_stdeb=1 |
| 136 | + stdeb_all_python=1 |
| 137 | + shift |
| 138 | + ;; |
| 139 | + --debian9) |
| 140 | + debian_version=9 |
| 141 | + target_system=debian${debian_version} |
| 142 | + dist_directory=${project_directory}/dist/${target_system} |
| 143 | + build_directory=${project_directory}/build/${target_system} |
| 144 | + shift |
| 145 | + ;; |
| 146 | + --debian10) |
| 147 | + debian_version=10 |
| 148 | + target_system=debian${debian_version} |
| 149 | + dist_directory=${project_directory}/dist/${target_system} |
| 150 | + build_directory=${project_directory}/build/${target_system} |
| 151 | + shift |
| 152 | + ;; |
| 153 | + --debian11) |
| 154 | + debian_version=11 |
| 155 | + target_system=debian${debian_version} |
| 156 | + dist_directory=${project_directory}/dist/${target_system} |
| 157 | + build_directory=${project_directory}/build/${target_system} |
| 158 | + shift |
| 159 | + ;; |
| 160 | + --debian12) |
| 161 | + debian_version=12 |
| 162 | + target_system=debian${debian_version} |
| 163 | + dist_directory=${project_directory}/dist/${target_system} |
| 164 | + build_directory=${project_directory}/build/${target_system} |
| 165 | + shift |
| 166 | + ;; |
| 167 | + -*) |
| 168 | + echo "Error: Unknown option: $1" >&2 |
| 169 | + echo "$usage" |
| 170 | + exit 1 |
| 171 | + ;; |
| 172 | + *) # No more options |
| 173 | + break |
| 174 | + ;; |
| 175 | + esac |
| 176 | +done |
| 177 | + |
| 178 | +clean_up() |
| 179 | +{ |
| 180 | + echo "Clean working dir:" |
| 181 | + # clean up previous build |
| 182 | + rm -rf ${build_directory} |
| 183 | + # create the build context |
| 184 | + mkdir -p ${build_directory} |
| 185 | +} |
| 186 | + |
| 187 | +build_deb() { |
| 188 | + echo "Build for debian 9 or newer using actual packaging" |
| 189 | + tarname=${project}_${debianversion}.orig.tar.gz |
| 190 | + clean_up |
| 191 | + if [ $debian_version -le 11 ] |
| 192 | + then |
| 193 | + python3 setup.py debian_src |
| 194 | + directory=${project}-${strictversion} |
| 195 | + else |
| 196 | + python3 -m build -s |
| 197 | + ln -s ${source_project}-${strictversion}.tar.gz dist/${tarname} |
| 198 | + directory=${source_project}-${strictversion} |
| 199 | + fi |
| 200 | + cp -f dist/${tarname} ${build_directory} |
| 201 | + if [ -f dist/${project}-testimages.tar.gz ] |
| 202 | + then |
| 203 | + cp -f dist/${project}-testimages.tar.gz ${build_directory} |
| 204 | + fi |
| 205 | + |
| 206 | + cd ${build_directory} |
| 207 | + tar -xzf ${tarname} |
| 208 | + |
| 209 | + |
| 210 | + newname=${deb_name}_${debianversion}.orig.tar.gz |
| 211 | + |
| 212 | + #echo tarname $tarname newname $newname |
| 213 | + if [ $tarname != $newname ] |
| 214 | + then |
| 215 | + if [ -h $newname ] |
| 216 | + then |
| 217 | + rm ${newname} |
| 218 | + fi |
| 219 | + ln -s ${tarname} ${newname} |
| 220 | + fi |
| 221 | + |
| 222 | + if [ -f ${project}-testimages.tar.gz ] |
| 223 | + then |
| 224 | + if [ ! -h ${deb_name}_${debianversion}.orig-testimages.tar.gz ] |
| 225 | + then |
| 226 | + ln -s ${project}-testimages.tar.gz ${deb_name}_${debianversion}.orig-testimages.tar.gz |
| 227 | + fi |
| 228 | + fi |
| 229 | + |
| 230 | + cd ${directory} |
| 231 | + cp -r ${project_directory}/package/${target_system} debian |
| 232 | + cp ${project_directory}/copyright debian |
| 233 | + |
| 234 | + #handle test images |
| 235 | + if [ -f ../${deb_name}_${debianversion}.orig-testimages.tar.gz ] |
| 236 | + then |
| 237 | + if [ ! -d testimages ] |
| 238 | + then |
| 239 | + mkdir testimages |
| 240 | + fi |
| 241 | + cd testimages |
| 242 | + tar -xzf ../${deb_name}_${debianversion}.orig-testimages.tar.gz |
| 243 | + cd .. |
| 244 | + else |
| 245 | + # Disable to skip tests during build |
| 246 | + echo No test data |
| 247 | + #export PYBUILD_DISABLE_python2=test |
| 248 | + #export PYBUILD_DISABLE_python3=test |
| 249 | + #export DEB_BUILD_OPTIONS=nocheck |
| 250 | + fi |
| 251 | + |
| 252 | + case $debian_version in |
| 253 | + 9) |
| 254 | + debian_name=stretch |
| 255 | + ;; |
| 256 | + 10) |
| 257 | + debian_name=buster |
| 258 | + ;; |
| 259 | + 11) |
| 260 | + debian_name=bullseye |
| 261 | + ;; |
| 262 | + 12) |
| 263 | + debian_name=bookworm |
| 264 | + ;; |
| 265 | + esac |
| 266 | + |
| 267 | + dch --force-distribution -v ${debianversion}-1 "upstream development build of ${project} ${version}" |
| 268 | + dch --force-distribution -D ${debian_name}-backports -l~bpo${debian_version}+ "${project} snapshot ${version} built for ${target_system}" |
| 269 | + #dch --bpo "${project} snapshot ${version} built for ${target_system}" |
| 270 | + dpkg-buildpackage -r |
| 271 | + rc=$? |
| 272 | + |
| 273 | + if [ $rc -eq 0 ]; then |
| 274 | + # move packages to dist directory |
| 275 | + echo Build succeeded... |
| 276 | + rm -rf ${dist_directory} |
| 277 | + mkdir -p ${dist_directory} |
| 278 | + mv ${build_directory}/*.deb ${dist_directory} |
| 279 | + mv ${build_directory}/*.x* ${dist_directory} |
| 280 | + mv ${build_directory}/*.dsc ${dist_directory} |
| 281 | + mv ${build_directory}/*.changes ${dist_directory} |
| 282 | + cd ../../.. |
| 283 | + else |
| 284 | + echo Build failed, please investigate ... |
| 285 | + exit "$rc" |
| 286 | + fi |
| 287 | +} |
| 288 | + |
| 289 | + |
| 290 | +build_stdeb () { |
| 291 | + echo "Build for debian using stdeb" |
| 292 | + tarname=${project}-${strictversion}.tar.gz |
| 293 | + clean_up |
| 294 | + |
| 295 | + python3 setup.py sdist |
| 296 | + cp -f dist/${tarname} ${build_directory} |
| 297 | + cd ${build_directory} |
| 298 | + tar -xzf ${tarname} |
| 299 | + cd ${project}-${strictversion} |
| 300 | + |
| 301 | + if [ $stdeb_all_python -eq 1 ] |
| 302 | + then |
| 303 | + echo Using Python 2+3 |
| 304 | + python3 setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True --with-python3=True --no-python3-scripts=True build --no-cython bdist_deb |
| 305 | + rc=$? |
| 306 | + else |
| 307 | + echo Using Python 3 |
| 308 | + # bdist_deb feed /usr/bin using setup.py entry-points |
| 309 | + python3 setup.py --command-packages=stdeb.command build --no-cython bdist_deb |
| 310 | + rc=$? |
| 311 | + fi |
| 312 | + |
| 313 | + # move packages to dist directory |
| 314 | + rm -rf ${dist_directory} |
| 315 | + mkdir -p ${dist_directory} |
| 316 | + mv -f deb_dist/*.deb ${dist_directory} |
| 317 | + |
| 318 | + # back to the root |
| 319 | + cd ../../.. |
| 320 | +} |
| 321 | + |
| 322 | + |
| 323 | +if [ $use_stdeb -eq 1 ]; then |
| 324 | + build_stdeb |
| 325 | +else |
| 326 | + build_deb |
| 327 | +fi |
| 328 | + |
| 329 | + |
| 330 | +if [ $install -eq 1 ]; then |
| 331 | + sudo su -c "dpkg -i ${dist_directory}/*.deb" |
| 332 | +fi |
| 333 | + |
| 334 | +exit "$rc" |
0 commit comments