File: import-orig

package info (click to toggle)
pkg-perl-tools 0.85
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 796 kB
  • sloc: perl: 3,254; sh: 3,244; makefile: 144; python: 18
file content (118 lines) | stat: -rwxr-xr-x 3,788 bytes parent folder | download
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
#!/bin/bash

# copyright, licensing and documentation at the end

set -e
set -u

. "${DPT__SCRIPTS:-/usr/share/pkg-perl-tools}/lib/dpt-lib.sh"

# defaults for configuration variable(s)

DPT_RM_TARGZ=${DPT_RM_TARGZ:-''}

# origin upstreamvcs
header "Git remote 'upstreamvcs'"
dpt upstreamvcs -u

# origin remote
header "gbp pull"
gbp pull

# uscan and versions
USCAN="$(uscan --report-status --dehs 2>/dev/null || true)"
UVERSION="$(echo $USCAN | perl -nE '/<upstream-version>([^<]+)<\/upstream-version>/ and say $1')"
UVERSIONZERO="$(echo "$UVERSION" | perl -ne 'print if s/0+$//')"
# in case of error, don't crash, just set to null string.
UTAG=''
UTAG="$(git tag | grep -x "v\?$UVERSION" || git tag | grep -- "[_-]$UVERSION\$")" || /bin/true
if [ -z "$UTAG" ] && [ -n "$UVERSIONZERO" ]; then
	UTAG="$(git tag | grep -x "v\?$UVERSIONZERO" || git tag | grep -- "[_-]$UVERSIONZERO\$")" || /bin/true
fi
# check if guessed tag actually exists
git show-ref --tags "$UTAG" --quiet || UTAG=''

# Download and import.
# We're using --no-interactive here because the dpt() shell function and
# "gbp import-orig" don't play well together (waiting for input before
# showing the question).
# Also create a changelog entry as a start, and to un-confuse git-dch later.
header "gbp import-orig"
gbp import-orig --no-interactive --pristine-tar \
	--filter='.gitignore' --filter='debian/*' --filter='.git/*' --filter='.git' \
	--postimport='dch -v${GBP_DEBIAN_VERSION} --no-auto-nmu --mainttrailer --release-heuristic=changelog "Import upstream version ${GBP_UPSTREAM_VERSION}."' \
	${UTAG:+--upstream-vcs-tag="$UTAG"} ${1:---uscan}

git add debian/changelog
git commit -m "Update debian/changelog" -m "Gbp-Dch: Ignore"

# cleanup on request
UNAME=$(awk '/Upstream-Name:/ {print $2;}' debian/copyright)
if [ -n "$DPT_RM_TARGZ" ] ; then
	rm -fv ../${PKG}*.tar.gz* ../${PKG}*.tgz* ../${PKG}*.tar.xz* ../${PKG}*.tar.bz2* ../${PKG}*.tar.lzma* ../${PKG}*.zip*
	rm -fv ../${UNAME}*.tar.gz ../${UNAME}*.tgz ../${UNAME}*.tar.xz ../${UNAME}*.tar.bz2 ../${UNAME}*.tar.lzma ../${UNAME}*.zip
fi

# diff against last debian/ tag
header "Git diff against last Debian tag"
gitddiff

# diff between upstreamvcs tag and upstream/ (tarball) tag
[ -n "$UTAG" ] || exit 0
TARTAG=$(git describe --abbrev=0 --match "$(gbp config DEFAULT.upstream-tag | sed -e 's/%(version)s/*/g;')")
echo
header "Compare Git tags"
if promptyesno "View diff between upstream Git tag ('$UTAG') and imported tarball ('$TARTAG')? y/N"; then
	git diff --ignore-space-at-eol "$UTAG" "$TARTAG"
fi

POD=<<'EOF'
=head1 NAME

dpt-import-orig - "gbp import-orig" wrapper with upstream tracking support

=head1 SYNOPSIS

B<dpt import-orig> [I<../package_version.orig.tar.gz>]

=head1 DESCRIPTION

B<dpt import-orig> is a wrapper around B<gbp import-orig> using its
B<--uscan> and B<--upstream-vcs-tag> options to fetch and import tarballs
and link to upstream Git tags.

If necessary, the B<git remote> is added using L<dpt-upstreamvcs(1)>.

If a parameter is passed, it's taken as orig tar-ball to import
instead of using uscan to download the tar ball. Needed if a newer
upstream release has a (from dpkg's point of view) lower version
number and gbp bails out over uscan not having downloaded a tar ball.

=head1 CONFIGURATION

B<dpt import-orig> reads the C<DPT_RM_TARGZ> environment variable to
determine if the downloaded F<.orig.tar.gz> should be removed after the
import.

See L<dpt-config(5)> for details.

=head1 SEE ALSO

L<dpt-upstreamvcs(1)>

=head1 COPYRIGHT & LICENSE

=over

=item Copyright 2013 Jonas Smedegaard L<dr@jones.dk>

=item Copyright 2013-2025 gregor herrmann L<gregoa@debian.org>

=item Copyright 2014 David Bremner L<bremner@debian.org>

=back

This program is free software, licensed under the same terms as perl.

=cut
EOF