forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-tsunami-package
executable file
·86 lines (77 loc) · 4.08 KB
/
build-tsunami-package
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
#!/bin/sh
################################################################################
#
# Helper script to build a deb package for MXNet
#
# This script provides some custom handling of git tags to allow us to tag
# package releases with well-crafted Debian package versions, e.g.:
#
# 1.0.0-0tsunami1
#
# where `1.0.0` is the upstream MXNet version, and `0tsunami1` is the package
# iteration -- in this case following the `debian_revision` format where the
# initial 0 indicates that we are not forking any upstream Debian package, the
# `tsunami` identifies Sociomantic Tsunami as the packager, and the last number
# corresponds to our package revision (1, 2, 3, ..., restarting from 1 every
# time the upstream version changes).
#
# This script parses the tag and separates out the upstream version and package
# iteration, appending dirty-build and distro-code details to the latter, before
# invoking Makd's package-building functionality with this version information
# specified.
#
################################################################################
#
# Copyright (c) 2018 dunnhumby Germany GmbH
#
# Boost Software License - Version 1.0 - August 17th, 2003
#
# Permission is hereby granted, free of charge, to any person or organization
# obtaining a copy of the software and accompanying documentation covered by
# this license (the "Software") to use, reproduce, display, distribute,
# execute, and transmit the Software, and to prepare derivative works of the
# Software, and to permit third-parties to whom the Software is furnished to
# do so, all subject to the following:
#
# The copyright notices in the Software and this entire statement, including
# the above license grant, this restriction and the following disclaimer,
# must be included in all copies of the Software, in whole or in part, and
# all derivative works of the Software, unless such copies or derivative
# works are solely in the form of machine-executable object code generated by
# a source language processor.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
################################################################################
set -ex
# extract base version tag (the most recent tag in the commit history)
# and the full 'dirty' version tag (which contains extra information
# on the number of commits since the last annotated tag, and on whether
# there are currently uncommitted changes in the tree)
version_tag=$(git describe --abbrev=0)
dirty_version_tag=$(git describe --dirty)
# extract the base package iteration from the version tag
# (the part of the tag to the right of the last hyphen)
base_package_iteration=$(echo $version_tag | sed 's/.*-//')
# extract dirty version information (any git describe output not
# in the most recent annotated tag) and convert `-` to `+` to
# enable us to include this in the package iteration without
# violating Debian versioning rules about hyphens
dirty_version_info=$(echo $dirty_version_tag | sed "s/$version_tag//" | sed 's/-/+/g')
# get the distro codename (will be appended to package iteration)
distro_codename=$(lsb_release -rs | grep rolling || lsb_release -cs)
# get the upstream version (the part of the version tag to the
# left of the rightmost hyphen)
package_version=$(echo $version_tag | sed "s/-$base_package_iteration//")
# construct the full package iteration we will use, combining
# the base package iteration (from the most recent annotated
# tag) with dirty version info (if any) and the distro code
package_iteration="$base_package_iteration$dirty_version_info~$distro_codename"
# build the package with these version and iteration specifications
make -f makd/Makd.mak PKGVERSION=$package_version PKGITERATION=$package_iteration pkg