summaryrefslogtreecommitdiffstats
path: root/scripts/ipkg-check-equal
blob: f4deb5795ba2e25b3ff651c47509270fc705ddb6 (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
#!/bin/bash
#
# usage: ipkg-check-equal <first.ipk> <second.ipk>

PTXDIST_TOPDIR=`pwd`
TMPDIR=`mktemp -d /tmp/ptxdist.XXXXXX`
IPKG1=$1
IPKG2=$2

if [ ! -f "$IPKG1" ]; then
	echo -e "\nError: couldn't find $IPKG1\n"
	exit 1
fi

if [ ! -f "$IPKG2" ]; then
	echo -e "\nError: couldn't find $IPKG2\n"
	exit 1
fi

mkdir -p ${TMPDIR}/first/data
mkdir -p ${TMPDIR}/first/control
pushd ${TMPDIR}/first > /dev/null
ar x $IPKG1
cd data    && tar -zxf ../data.tar.gz;    cd ..
cd control && tar -zxf ../control.tar.gz; cd ..
sed -i 's/^Version:.*//' control/control
find data    -type f | xargs md5sum | awk '{printf("%s ", $2); print $1}' | sort -u > data.md5
find control -type f | xargs md5sum | awk '{printf("%s ", $2); print $1}' | sort -u > control.md5
popd > /dev/null

mkdir -p ${TMPDIR}/second/data
mkdir -p ${TMPDIR}/second/control
pushd ${TMPDIR}/second > /dev/null
ar x $IPKG2
cd data    && tar -zxf ../data.tar.gz;    cd ..
cd control && tar -zxf ../control.tar.gz; cd ..
sed -i 's/^Version:.*//' control/control
find data    -type f | xargs md5sum | awk '{printf("%s ", $2); print $1}' | sort -u > data.md5
find control -type f | xargs md5sum | awk '{printf("%s ", $2); print $1}' | sort -u > control.md5
popd > /dev/null

diff -u ${TMPDIR}/first/data.md5 ${TMPDIR}/second/data.md5
DIFF_DATA=$?

diff -u ${TMPDIR}/first/control.md5 ${TMPDIR}/second/control.md5 
DIFF_CONTROL=$?

rm -fr ${TMPDIR}

if [ "$DIFF_DATA" = "0" ] && [ "$DIFF_CONTROL" = "0" ]; then
	exit 0
fi

exit 1