Skip to content

Commit 7e6c887

Browse files
committed
Fixes for debian/changelog handling
- Fix paths for the case where "debian" dir is not at the top level - Break the release build if debian/changelog is outdated, instead of generating an entry (which would be unreproducible) - Make "Build for x" entry reproducible - force name and email, copy its date from previous entry - Deduplicate actual dpkg-buildpackage call
1 parent 4255071 commit 7e6c887

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

Makefile.debian

+7-7
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ endif
231231
fi; \
232232
fi
233233

234-
235234
ifneq (,$(INCREMENT_DEVEL_VERSIONS))
236235
# Break the hardlink - keep modified debian/changelog only inside of chroot
237236
cp $(CHROOT_DEBIAN_DIR)/changelog $(CHROOT_DEBIAN_DIR)/changelog.copy
@@ -245,21 +244,22 @@ ifneq (,$(INCREMENT_DEVEL_VERSIONS))
245244
# if the files are already there, do nothing because they are hardlinks
246245
cp -np $(CHROOT_DEBIAN_DIR)/changelog.dist $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/ 2>/dev/null || true
247246
cp -np $(CHROOT_DEBIAN_DIR)/changelog.$(DIST) $(ORIG_SRC)/$(DEBIAN_BUILD_DIRS)/ 2>/dev/null || true
248-
249-
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) su $(RUN_AS_USER) -c 'cd $(DIST_SRC_DEBIAN_DIR)/..; export LC_ALL=C; dpkg-buildpackage -sa -uc -us'
250247
else
251-
# Only used to update changelog to new version since changelog is
252-
# also called below
253-
cd $(CHROOT_DEBIAN_DIR)/..; $(DEBIAN_PLUGIN_DIR)/scripts/debian-changelog.sh
248+
# break the release build if changelog does not match version file
249+
cd $(CHROOT_DEBIAN_DIR)/..; $(DEBIAN_PLUGIN_DIR)/scripts/debian-changelog.sh --verify
254250

255251
# Break the hardlink
256252
cp $(CHROOT_DEBIAN_DIR)/changelog $(CHROOT_DEBIAN_DIR)/changelog.copy
257253
mv $(CHROOT_DEBIAN_DIR)/changelog.copy $(CHROOT_DEBIAN_DIR)/changelog
258254

259255
echo "Building package in $(DIST_SRC)"
260-
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) su $(RUN_AS_USER) -c 'cd $(DIST_SRC_DEBIAN_DIR)/..; export LC_ALL=C; debchange -t -l+$(DIST_TAG)u "Build for $(DIST)"; debchange -t --force-distribution -r -D $(DIST) $(DIST); dpkg-buildpackage -sa -uc -us'
256+
cd $(CHROOT_DIR)/$(DIST_SRC)/$(PACKAGE)/..; export LC_ALL=C DEBFULLNAME=Builder DEBEMAIL=user@localhost; \
257+
debchange -t -l+$(DIST_TAG)u "Build for $(DIST)"; debchange -t --force-distribution -r -D $(DIST) $(DIST)
258+
$(DEBIAN_PLUGIN_DIR)/scripts/clamp-changelog-entry-date $(CHROOT_DEBIAN_DIR)/changelog
261259
endif
262260

261+
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) su $(RUN_AS_USER) -c 'cd $(DIST_SRC_DEBIAN_DIR)/..; export LC_ALL=C; dpkg-buildpackage -sa -uc -us'
262+
263263
ifneq (,$(DEBIAN_BUILD_DIRS))
264264
dist-copy-out: release_name = $(shell $(DEBIAN_PARSER) changelog --package-release-name $(CHROOT_DEBIAN_DIR)/changelog)
265265
endif

scripts/clamp-changelog-entry-date

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# Clamp the topmost changelog entry date ("Build for ...") to the previous one
4+
# (actual meaningful entry)
5+
6+
CHANGELOG_PATH="$1"
7+
8+
if [ ! -r "$CHANGELOG_PATH" ]; then
9+
echo "Changelog file '$CHANGELOG_PATH' inaccessible!" >&2
10+
exit 1
11+
fi
12+
13+
# get previous date
14+
PREVIOUS_DATE=$(grep '^ --' $CHANGELOG_PATH |\
15+
head -n 2 | tail -n 1 | grep -o ' .*')
16+
17+
# replace topmost date
18+
sed -e "0,/^ --/s/^\( --.*\)\( .*\)/\1$PREVIOUS_DATE/" -i $CHANGELOG_PATH
19+
touch --date="$PREVIOUS_DATE" "$CHANGELOG_PATH"

scripts/debian-changelog.sh

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# package root directory differs from what is reported in changelog a
1515
# release is created, updating the changelog with commits since previous
1616
# version and bumping the changelog version
17+
#
18+
# Addtionally, if the script is called with --verify option, it will only check
19+
# if the debian/changelog entry matches version/rel file and set appropriate
20+
# exit code.
1721
# -----------------------------------------------------------------------------
1822
# NOTES:
1923
#
@@ -64,6 +68,16 @@ if [ -z "$deb_revision" ]; then
6468
revision=""
6569
fi
6670

71+
if [ "x$1" = "x--verify" ]; then
72+
if [ "${deb_version}-${deb_revision}" = "${version}-${revision}" ]; then
73+
exit 0
74+
else
75+
echo "Version mismatch: ${deb_version}-${deb_revision} in debian/changelog but ${version}-${revision} in version+rel" >&2
76+
exit 1
77+
fi
78+
fi
79+
80+
6781
# =============================================================================
6882
# R E L E A S E M O D E
6983
# =============================================================================

0 commit comments

Comments
 (0)