]> mj.ucw.cz Git - libucw.git/blob - debian/mk
Packages: Implemented `debian/mk --no-source'.
[libucw.git] / debian / mk
1 #!/bin/bash
2 # A script for building of LibUCW packages
3 # (c) 2013--2014 Pavel Charvat <pchar@ucw.cz>
4
5 set -e
6 . debian/pkg-lib
7
8 function usage {
9         cat >&2 <<EOF
10 Usage: $0 <options>
11 Options:
12 --archonly              Build only binary packages
13 --no-source             Don't build source files
14 --cleanup               Cleanup temporary files when finished
15 --version=<ver>         Custom version number of resulting packages (default: autodetect from git-describe)
16 --abi-version=<ver>     Custom version number of the LibUCW's ABI (default: defined in ucw/default.cfg)
17 --gen-script=<script>   Custom script to postprocess
18 EOF
19         exit 1
20 }
21
22 function pkg-gen-debian {(
23         cd $BUILDDIR
24         echo "Configuring"
25         ./configure debian/config VER="$VER" TREEHASH="$TREEHASH" $CONF \
26                 PREFIX=/ \
27                 INSTALL_INCLUDE_DIR=/usr/include/libucw \
28                 INSTALL_DOC_DIR=/usr/share/doc/libucw/html \
29                 INSTALL_CONFIG_DIR=/usr/share/doc/libucw/examples/etc
30
31         echo "Creating debian/control"
32         build/genconf debian/control.in debian/control obj/config.mk
33
34         if [ -n "$GEN_SCRIPT" ] ; then
35                 echo "Executing $GEN_SCRIPT"
36                 $GEN_SCRIPT
37         fi
38
39         echo "Creating debian/changelog"
40         export EDITOR=true
41         CL=debian/changelog
42         rm -f $CL
43         dch --changelog=$CL --create --package=$PKG --newversion=$VER "Automatic release."
44         dch --changelog=$CL --release
45         sed -i '/Initial release/d' $CL
46 )}
47
48 ROOT="`pwd`"
49 PKG=libucw
50 ARCHONLY=
51 NO_SOURCE=
52 CLEANUP=
53 CONF=
54 GEN_SCRIPT=
55 while [ -n "$1" ] ; do
56         case "$1" in
57         --archonly)     ARCHONLY=1
58                         ;;
59         --no-source)    NO_SOURCE=1
60                         ;;
61         --cleanup)      CLEANUP=1
62                         ;;
63         --version=*)    PKGVER="${1:10}"
64                         ;;
65         --abi-version=*)CONF="$CONF UCW_ABI_SUFFIX=-${1:14}"
66                         ;;
67         --gen-script=*) GEN_SCRIPT="${1:13}"
68                         ;;
69         *)              usage
70                         ;;
71         esac
72         shift
73 done
74
75 pkg-git-version
76 pkg-git-checkout
77
78 echo $TREEVER >$BUILDDIR/UCW_VERSION
79 pkg-gen-debian
80
81 BUILDOPTS=
82 if [ -n "$ARCHONLY" ] ; then
83         BUILDOPTS=-B
84 elif [ -n "$NO_SOURCE" ] ; then
85         BUILDOPTS=-b
86 fi
87 (cd $BUILDDIR && dpkg-buildpackage -rfakeroot -us -uc $BUILDOPTS)
88 [ -z "$ARCHONLY" ] || rm -f debian-tmp/*_all.deb
89 pkg-get-files debian-tmp/*.{deb,dsc,changes,tar.gz}
90
91 [ -z "$CLEANUP" ] || pkg-cleanup