This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
forked from runtimeverification/rv-predict
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deb-release.sh
executable file
·148 lines (117 loc) · 4.65 KB
/
deb-release.sh
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
#!/bin/sh
set -e
set -u
set -x
usage()
{
echo "usage: $(basename $0) version" 1>&2
exit 1
}
cleanup()
{
trap - EXIT ALRM HUP INT PIPE QUIT TERM
cd ${start_dir}
rm -rf ${tmpdir}
}
[ $# -eq 1 ] || usage
version=$1
start_dir=$(pwd)
tmpdir=$(mktemp -d -t $(basename $0).XXXXX)
destdir=${tmpdir}/debian/rv-predict-c
trap cleanup EXIT ALRM HUP INT PIPE QUIT TERM
changelog_regex="^rv-predict-c ($(echo $version | sed 's,\.,\\.,g')-1) xenial; urgency=medium"
cp -a debian $tmpdir/
if [ ${version%%-SNAPSHOT} != ${version} ]
then
cat - debian/changelog > ${tmpdir}/debian/changelog <<CHANGELOG_TEMPLATE
rv-predict-c (${version}-1) xenial; urgency=medium
* Miscellaneous bug fixes and new features.
-- Runtime Verification, Inc. <[email protected]> $(date +'%a, %d %b %Y %H:%M:%S %z')
CHANGELOG_TEMPLATE
elif ! head -1 debian/changelog > ${tmpdir}/changelog_first_line || \
! grep -q "${changelog_regex}" < ${tmpdir}/changelog_first_line
then
echo "Before you run $(basename $0), you should add version ${version} to debian/changelog." 1>&2
exit 1
else
cp debian/changelog ${tmpdir}/debian/changelog
fi
gzip -9fn < ${tmpdir}/debian/changelog > ${tmpdir}/changelog.Debian.gz
# Create `version` file that records rv-predict/c version number
echo $version > ${tmpdir}/version
# avoid creating files & directories with permissions 0775
#umask 022
NBINSTALL="nb-install -U -D ${destdir} -M ${destdir}/metalog -h md5"
DEBINSTALL="nb-install -U -D ${tmpdir}/debian -M ${tmpdir}/debian/metalog"
#
# Get nb-install onto our PATH
#
export PATH=$(rvpmake -V '$(.OBJDIR)')/.tools/bin:${PATH}
#
# Call rvpmake with NBINSTALL=yes so that meta-information is
# captured.
#
RVPMAKE="rvpmake DEBUG=yes RELEASE=yes DESTDIR=${destdir} PREFIX=/usr PACKAGE_LIBDIR=/usr/lib/x86_64-linux-gnu LIBEXECDIR=/usr/lib/x86_64-linux-gnu"
$RVPMAKE all
# nb-install requires that the directory that receives the metalog exists.
mkdir -p ${destdir}
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/lib
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/doc
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/doc/rv-predict-c
$NBINSTALL -o root -g root -m 0644 ${tmpdir}/changelog.Debian.gz \
${destdir}/usr/share/doc/rv-predict-c/changelog.Debian.gz
$NBINSTALL -o root -g root -m 0444 ${tmpdir}/version \
${destdir}/usr/share/doc/rv-predict-c/version
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/examples
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/examples/rv-predict-c
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/man
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/rv-predict-c
$NBINSTALL -d -o root -g root -m 0755 ${destdir}/usr/share/rv-predict-c/html-report
$RVPMAKE NBINSTALL="${NBINSTALL}" install
cd $tmpdir
dh_makeshlibs
dpkg-shlibdeps debian/rv-predict-c/usr/lib/x86_64-linux-gnu/rvpinstrument.so \
debian/rv-predict-c/usr/bin/rvpdump \
debian/rv-predict-c/usr/bin/rvp-error \
debian/rv-predict-c/usr/bin/rvpshortenpaths \
debian/rv-predict-c/usr/bin/rvpsymbolize-json \
debian/rv-predict-c/usr/bin/rvptrimframe \
debian/rv-predict-c/usr/bin/rvsyms
dpkg-gencontrol -Pdebian/rv-predict-c
cd $start_dir
deb_filename=rv-predict-c_${version}-1_amd64.deb
man_match="^\./usr/share/man/.*\.[0-9]\>"
cd ${destdir}/DEBIAN
nb-pax -wzf ${tmpdir}/control.tar.gz .
cd ${destdir}/
grep "${man_match}" < ${destdir}/metalog > ${destdir}/metalog.man
grep -v "${man_match}" < ${destdir}/metalog > ${destdir}/metalog.dedup
mv -f ${destdir}/metalog.dedup ${destdir}/metalog
while read fn rest; do
gzip -9fn < $fn > ${tmpdir}/tmp.gz
$NBINSTALL -o root -g root -m 0644 \
${tmpdir}/tmp.gz ${destdir}/${fn##./}.gz
rm -f ${tmpdir}/tmp.gz
done < ${destdir}/metalog.man
{
echo "/set uname=root gname=root"
#
# lintian(1) expects directory names to end in /, apparently.
# Make it so. Also sort by filename.
#
# sed 's,\([^[:space:]]*[^/]\)\([[:space:]]\+.*type=dir.*\)$,\1/\2,' < \
# ${destdir}/metalog | sort -u -k 1,1
sort -u -k 1,1 < ${destdir}/metalog
} | tee ${destdir}/metalog.new | nb-mtree -D -k md5 | \
grep '\<md5=' | sed 's/[[:space:]]*\<type=[^[:space:]]\+[[:space:]]*//' | \
sed 's/md5=\([^[:space:]]\+\)/\1 /' > ${tmpdir}/md5sum
$DEBINSTALL -o root -g root -m 0644 ${tmpdir}/md5sum ${destdir}/DEBIAN/md5sums
mv -f ${destdir}/metalog.new ${destdir}/metalog
nb-pax --xz -M -wf ${tmpdir}/data.tar.xz < ${destdir}/metalog
echo "2.0" > ${tmpdir}/debian-binary
cd ${tmpdir}
ar rcs ${start_dir}/${deb_filename} debian-binary control.tar.gz data.tar.xz
exit 0