File: changelogs.example

package info (click to toggle)
reprepro 4.2.0-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,016 kB
  • ctags: 3,674
  • sloc: ansic: 46,905; sh: 13,899; pascal: 160; makefile: 159; python: 138
file content (192 lines) | stat: -rwxr-xr-x 5,047 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/sh
# This is an example script that can be hooked into reprepro
# to generate a hierachy like packages.debian.org/changelogs/
# All you have to do is to copy it into you conf/ directory,
# and add the following to any distribution in conf/distributions
# you want to have changelogs and copyright files extracted:
#Log:
# --type=dsc changelogs.example
# (note the space at the beginning of the second line).
# This will cause this script to extract changelogs for all
# newly added source packages. (To generate them for already
# existing packages, call "reprepro rerunnotifiers").

# DEPENDENCIES: dpkg >= 1.13.9

if test "x${REPREPRO_OUT_DIR:+set}" = xset ; then
	# Note: due to cd, REPREPRO_*_DIR will no longer
	# be usable. And only things relative to outdir will work...
	# (as the filekeys given to this are, though for changesfiles
	# and CAUSING_FILE it would be different)
	cd "${REPREPRO_OUT_DIR}" || exit 1
else
	cat "This script is written for reprepro 3.5.1 upwoards" >&2
	cat "for an older version, disable that warning and add" >&2
	cat "a proper cd or always use from the basedir" >&2
	exit 1
fi

# You will either always have to call it with the basedir as
# your current directory, use reprepro >= 3.5.1
# or uncomment and edit the following to be your base directory.

# cd /path/to/your/repository

# place where the changelogs should be put into:

CHANGELOGDIR=changelogs

# Set to avoid using some predefined TMPDIR or even /tmp as
# tempdir:

# TMPDIR=/var/cache/whateveryoucreated

addsource() {
	DSCFILE="$1"
	CANONDSCFILE="$(readlink --canonicalize "$DSCFILE")"
	TARGETDIR="$CHANGELOGDIR"/"$(echo $DSCFILE | sed -e 's/\.dsc$//')"
	SUBDIR="$(basename $TARGETDIR)"
	BASEDIR="$(dirname $TARGETDIR)"
	if ! [ -d "$TARGETDIR" ] ; then
		echo "extract $CANONDSCFILE information to $TARGETDIR"
		mkdir -p -- "$TARGETDIR"
		EXTRACTDIR="$(mktemp -d)"
		(cd -- "$EXTRACTDIR" && dpkg-source --no-copy -x "$CANONDSCFILE" > /dev/null)
		install -D -- "$EXTRACTDIR"/*/debian/copyright "$TARGETDIR/copyright"
		install -D -- "$EXTRACTDIR"/*/debian/changelog "$TARGETDIR/changelog"
		chmod -R u+rwX -- "$EXTRACTDIR"
		rm -r -- "$EXTRACTDIR"
	fi
	if [ -L "$BASEDIR"/current."$CODENAME" ] ; then
		# should not be there, just to be sure
		rm -f -- "$BASEDIR"/current."$CODENAME"
	fi
	# mark this as needed by this distribution
	ln -s -- "$SUBDIR" "$BASEDIR/current.$CODENAME"
	JUSTADDED="$TARGETDIR"
}
delsource() {
	DSCFILE="$1"
	TARGETDIR="$CHANGELOGDIR"/"$(echo $DSCFILE | sed -e 's/\.dsc$//')"
	SUBDIR="$(basename $TARGETDIR)"
	BASEDIR="$(dirname $TARGETDIR)"
	if [ "x$JUSTADDED" = "x$TARGETDIR" ] ; then
		exit 0
	fi
#	echo "delete, basedir=$BASEDIR targetdir=$TARGETDIR, dscfile=$DSCFILE, "
 	if [ "x$(readlink "$BASEDIR/current.$CODENAME")" = "x$SUBDIR" ] ; then
 		rm -- "$BASEDIR/current.$CODENAME"
 	fi
 	NEEDED=0
 	for c in "$BASEDIR"/current.* ; do
 		if [ "x$(readlink -- "$c")" = "x$SUBDIR" ] ; then
 			NEEDED=1
 		fi
 	done
 	if [ "$NEEDED" -eq 0 -a -d "$TARGETDIR" ] ; then
 		rm -r -- "$TARGETDIR"
		# to remove the directory if now empty
		rmdir --ignore-fail-on-non-empty -- "$BASEDIR"
 	fi
}

ACTION="$1"
CODENAME="$2"
PACKAGETYPE="$3"
if [ "x$PACKAGETYPE" != "xdsc" ] ; then
# the --type=dsc should cause this to never happen, but better safe than sorry.
	exit 1
fi
COMPONENT="$4"
ARCHITECTURE="$5"
if [ "x$ARCHITECTURE" != "xsource" ] ; then
	exit 1
fi
NAME="$6"
shift 6
JUSTADDED=""
if [ "x$ACTION" = "xadd" -o "x$ACTION" = "xinfo" ] ; then
	VERSION="$1"
	shift
	if [ "x$1" != "x--" ] ; then
		exit 2
	fi
	shift
	while [ "$#" -gt 0 ] ; do
		case "$1" in
			*.dsc)
				addsource "$1"
				;;
			--)
				exit 2
				;;
		esac
		shift
	done
elif [ "x$ACTION" = "xremove" ] ; then
	OLDVERSION="$1"
	shift
	if [ "x$1" != "x--" ] ; then
		exit 2
	fi
	shift
	while [ "$#" -gt 0 ] ; do
		case "$1" in
			*.dsc)
				delsource "$1"
				;;
			--)
				exit 2
				;;
		esac
		shift
	done
elif [ "x$ACTION" = "xreplace" ] ; then
	VERSION="$1"
	shift
	OLDVERSION="$1"
	shift
	if [ "x$1" != "x--" ] ; then
		exit 2
	fi
	shift
	while [ "$#" -gt 0 -a "x$1" != "x--" ] ; do
		case "$1" in
			*.dsc)
				addsource "$1"
			;;
		esac
		shift
	done
	if [ "x$1" != "x--" ] ; then
		exit 2
	fi
	shift
	while [ "$#" -gt 0 ] ; do
		case "$1" in
			*.dsc)
				delsource "$1"
				;;
			--)
				exit 2
				;;
		esac
		shift
	done
fi

exit 0
# Copyright 2007,2008 Bernhard R. Link <brlink@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1301  USA