Adding GitLab Scanner
[osm/IM.git] / build-docs.sh
1 #!/bin/bash
2 # Copyright 2018 Sandvine
3 # All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
17 PKG_DIRECTORIES="osm_im_trees models"
18 MDG_NAME=im
19 PKG_NAME=osm-${MDG_NAME}docs
20 DEB_INSTALL=debian/${PKG_NAME}.install
21 export DEBEMAIL="mmarchetti@sandvine.com"
22 export DEBFULLNAME="Michael Marchetti"
23
24 PKG_VERSION=$(git describe --match "v*" --tags --abbrev=0)
25 PKG_VERSION_FULL=$(git describe --match "v*" --tags --long)
26 PKG_VERSION_PREFIX=$(echo $PKG_VERSION | sed -e 's/v//g')
27 PKG_VERSION_POST=$(git rev-list $PKG_VERSION..HEAD | wc -l)
28
29 IFS='-' read -ra PKG_VERSION_FIELDS <<< "$PKG_VERSION_FULL"
30
31 if [ "$PKG_VERSION_POST" -eq 0 ]; then
32 PKG_DIR="${PKG_NAME}-${PKG_VERSION_PREFIX}"
33 POST_UPDATE=
34 else
35 PKG_DIR="${PKG_NAME}-$PKG_VERSION_PREFIX.post${PKG_VERSION_POST}"
36 POST_UPDATE=".post${PKG_VERSION_FIELDS[1]}"
37 fi
38
39 rm -rf $PKG_DIR
40 rm -f *.orig.tar.xz
41 rm -f *.deb
42 rm -f $DEB_INSTALL
43 mkdir -p $PKG_DIR
44
45 for dir in $PKG_DIRECTORIES; do
46 ln -s $PWD/$dir $PKG_DIR/.
47 echo "$dir/* usr/share/osm-$MDG_NAME/$dir" >> $DEB_INSTALL
48 done
49 cp LICENSE $PKG_DIR/.
50 echo "LICENSE usr/share/osm-$MDG_NAME" >> $DEB_INSTALL
51 cp -R debian $PKG_DIR/.
52
53 cd $PKG_DIR
54 dh_make -y --indep --createorig --a -c apache
55 sed -i -e "s/${PKG_VERSION_PREFIX}${POST_UPDATE}-1/$PKG_VERSION_PREFIX${POST_UPDATE}-${PKG_VERSION_FIELDS[2]}/g" debian/changelog
56 dpkg-buildpackage -uc -us -tc -rfakeroot
57 cd -