File: get_orig.sh

package info (click to toggle)
clamav 0.101.4+dfsg-0+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,564 kB
  • sloc: ansic: 158,978; sh: 8,178; cpp: 5,173; makefile: 2,088; yacc: 1,351; lex: 714; python: 120; perl: 17
file content (84 lines) | stat: -rwxr-xr-x 1,584 bytes parent folder | download | duplicates (7)
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
#!/bin/bash

DEBIAN_DIR=$(dirname $0)
CUR_DIR=$PWD

read_dom () {
	local IFS=\>
	read -d \< ENTITY CONTENT
	local RET=$?
	TAG_NAME=${ENTITY%% *}
	ATTRIBUTES=${ENTITY#* }
	return $RET
}

UPS_VER=""
UPS_FILE=""
DEB_VER=""
TAG_NAME=""
ATTRIBUTE=""

echo "Checking…"
cd "$DEBIAN_DIR"/../
while read_dom
do
	if [ "$TAG_NAME" = "upstream-version" ]
	then
		UPS_VER="$CONTENT"
	fi
	if [ "$TAG_NAME" = "debian-mangled-uversion" ]
	then
		DEB_VER="$CONTENT"
	fi
	if [ "$TAG_NAME" = "upstream-url" ]
	then
		UPS_FILE="${CONTENT##*/}"
	fi
done < <(uscan --dehs --report)

echo "Debian: $DEB_VER, upstream $UPS_VER"

if [ "$DEB_VER" = "$UPS_VER" ]
then
	echo "same version, no action"
fi

echo upstream looks newer, fetching $UPS_VER
uscan --force-download --destdir "$CUR_DIR"
RET=$?
cd "$CUR_DIR"
if [ ! -f "$UPS_FILE" ]
then	
	echo "uscan should download ${UPS_FILE} but it did not."
	exit 1
fi
if [ ! -f clamav_${UPS_VER}.orig.tar.gz ]
then
	echo "repacking…"
	mk-origtargz --copy --copyright $DEBIAN_DIR/copyright --package clamav -v ${UPS_VER} ${UPS_FILE}
	if [ ! -f clamav_${UPS_VER}.orig.tar.gz ]
	then
		echo "Repacked and I am still missing"
		echo "clamav_${UPS_VER}.orig.tar.gz."
		exit 1
	fi
fi

if [ $RET -eq 1 ]
then
	echo "Seems that you are up-to-date"
	exit 0
fi

if [ $RET -ne 0 ]
then
	echo "uscan terminated with non-zero exit code $RET."
	exit 1
fi

tmpdir="$(mktemp -d repack_dir_XXXXXX)"

mv clamav_${UPS_VER}.orig.tar.gz $tmpdir/clamav-${UPS_VER}.tar.gz
echo "Running split-tarball.sh $tmpdir ${UPS_VER}"
$DEBIAN_DIR/split-tarball.sh $tmpdir ${UPS_VER}
rm -r $tmpdir