blob: 6c59b8a92c7949000d3e93786b74aaeffede220b (
plain)
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
|
#!/bin/bash
# (C) 2015-2020 Christoph Berg <myon@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
set -eu
# basic variables
template_dir="/usr/share/postgresql-common/dh_make_pgxs/debian"
DIRECTORY="$(basename $PWD)"
NAME="${DIRECTORY%-*}" # Upstream name
VERSION="${DIRECTORY##*-}"
URL="https://FIXME/$NAME"
# options
while getopts "fh:n:v:" opt ; do
case $opt in
f) FORCE=yes ;;
h) URL="$OPTARG" ;;
n) NAME="$OPTARG" ;;
v) VERSION="$OPTARG" ;;
*) exit 5 ;;
esac
done
shift $((OPTIND - 1)) # shift away args
# more variables
SOURCE="${NAME//_/-}" # Debian name
EXTNAME="$(echo $SOURCE | sed -e 's/^\(postgresql\|pgsql\|pg\)-//')" # binary package name suffix
DHVERSION="$(dpkg-query --showformat '${Version}' --show debhelper)"
COMPAT="${DHVERSION%%.*}"
STANDARDS_VERSION="$(apt-cache show debian-policy | sed -n 's/Version: \(.*\)\..*/\1/p' | head -n1)"
USERNAME=${LOGNAME:-${USER:-root}}
MAINTAINER_NAME=$(getent passwd $USERNAME | cut -d : -f 5 | sed -e 's/,.*//')
: ${DEBEMAIL:=$USERNAME@localhost}
YEAR=$(date +%Y)
echo "Upstream (-n): $NAME"
echo "Version (-v): $VERSION"
echo "Source: $SOURCE ($VERSION-1)"
echo "Binaries: postgresql-PGVERSION-$EXTNAME ($VERSION-1)"
echo "Uploader: $MAINTAINER_NAME <$DEBEMAIL>"
echo "Homepage (-h): $URL"
echo
if [ -t 0 ]; then
echo -n "Press Enter to continue, ^C to abort "
read
fi
# install files
install_dir ()
{
local directory="debian/$1"
#[ -z "$directory" ] && return
[ -d "$directory" ] && return
echo "Creating $directory/"
mkdir "$directory"
}
install_template ()
{
local template="$1"
if [ "${FORCE:-}" ] || ! [ -e debian/$template ]; then
echo "Installing debian/$template"
sed -e "s/@COMPAT@/$COMPAT/g" \
-e "s/@EXTNAME@/$EXTNAME/g" \
-e "s/@NAME@/$NAME/g" \
-e "s/@STANDARDS_VERSION@/$STANDARDS_VERSION/g" \
-e "s/@SOURCE@/$SOURCE/g" \
-e "s/@MAINTAINER_NAME@/$MAINTAINER_NAME/g" \
-e "s/@DEBEMAIL@/$DEBEMAIL/g" \
-e "s;@URL@;$URL;g" \
-e "s/@YEAR@/$YEAR/g" \
"$template_dir/$template" > "debian/$template"
if [ -x $template_dir/$template ]; then
chmod +x "debian/$template"
fi
else
echo "Keeping existing debian/$template"
fi
}
mkdir -p debian
for template in $(find $template_dir -mindepth 1 | sort); do
case $template in
*.swp|*~) continue ;; # skip vim stuff
esac
basename=${template##$template_dir/}
if [ -d $template ]; then
install_dir "$basename"
else
install_template "$basename"
fi
done
if [ "$COMPAT" -lt "12" ]; then
sed -i -e "s/debhelper-compat[^,]*/debhelper (>= $COMPAT)/" debian/control*
echo "$COMPAT" > debian/compat
fi
echo "Updating debian/control from debian/control.in"
pg_buildext updatecontrol
if [ "${FORCE:-}" ] || ! [ -e debian/changelog ]; then
rm -f debian/changelog
echo "Creating debian/changelog"
if [ -x /usr/bin/dch ]; then
dch --create --package "$SOURCE" --newversion "$VERSION-1"
else
cat > debian/changelog <<-EOT
$SOURCE ($VERSION-1) UNRELEASED; urgency=medium
* Initial release. (Closes: #XXXXXX)
-- $MAINTAINER_NAME <$DEBEMAIL> $(date -R)
EOT
fi
else
echo "Keeping existing debian/changelog"
fi
|