summaryrefslogtreecommitdiffstats
path: root/docs/xz.example
blob: 2725bb00459a643b00ba3e38dd8795109e6a6423 (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
#!/bin/sh

# Copy this script to your conf/ dir as xz.sh, make it executable
# and add to some definition in conf/distributions
# DscIndices: Sources Release . .gz xz.sh
# DebIndices: Packages Release . .gz xz.sh
# UDebIndices: Packages . .gz xz.sh
# and you have .xz'd Packages and Sources.
# (alternatively, if you are very brave, put the full path to this file in there)

DIROFDIST="$1"
NEWNAME="$2"
OLDNAME="$3"
# this can be old($3 exists), new($2 exists) or change (both):
STATUS="$4"
BASENAME="`basename "$OLDNAME"`"

if [ "xPackages" = "x$BASENAME" ] || [ "xSources" = "x$BASENAME" ] ; then
	if [ "x$STATUS" = "xold" ] ; then
		if [ -f "$DIROFDIST/$OLDNAME.xz" ] ; then
			echo "$OLDNAME.xz" >&3
		else
			xz -c -- "$DIROFDIST/$OLDNAME" >"$DIROFDIST/$OLDNAME.xz.new" 3>/dev/null
			echo "$OLDNAME.xz.new" >&3
		fi
	else
		xz -c -- "$DIROFDIST/$NEWNAME" >"$DIROFDIST/$OLDNAME.xz.new" 3>/dev/null
		echo "$OLDNAME.xz.new" >&3
	fi
fi