-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdaorig
executable file
·39 lines (30 loc) · 1.27 KB
/
daorig
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
#!/bin/sh
# Usage: daorig
# Fake up an "original" source tarball for a Debathena package. Run
# this from the top level of a checkout or copy of the sources for a
# Debathena package; the orig tarball will be created in the parent
# directory if necessary.
# If the package has no Debian version component, this script will do
# nothing. If an orig file already exists, this script will also do
# nothing.
set -e
: ${DEBATHENA_APT=/mit/debathena/apt}
# Extract the changelog version and strip off the epoch and Debian component.
pkgname=$(dpkg-parsechangelog | sed -n 's/Source: //p')
changever=$(dpkg-parsechangelog | sed -n 's/Version: //p')
sver=$(echo "$changever" | sed -re 's/^[0-9]+://p')
upver=$(echo "$sver" | sed -re 's/-[^-]*$//')
# If the version has no Debian component, do nothing.
if [ "x$sver" = "x$upver" ]; then exit; fi
# If an orig file already exists, do nothing.
tarfile=${pkgname}_$upver.orig.tar.gz
if [ -e "../$tarfile" ]; then exit; fi
aptorig=$(find ${DEBATHENA_APT}*/pool -name $tarfile | head -1)
if [ -n "$aptorig" ]; then
echo "Copying existing $aptorig to original source"
cp "$aptorig" "../$tarfile"
else
echo "Creating original source archive"
dirname=$(basename $(pwd))
(cd .. && tar --exclude=.svn --exclude=debian -czf "$tarfile" "$dirname")
fi