Skip to content

Instantly share code, notes, and snippets.

@herpiko
Created April 25, 2017 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herpiko/3f28bde80fb6d19138eab12cd52a8dc7 to your computer and use it in GitHub Desktop.
Save herpiko/3f28bde80fb6d19138eab12cd52a8dc7 to your computer and use it in GitHub Desktop.
Package diff : cdimage package list vs Debian snapshot repository
#!/bin/bash
TIMESTAMP=$1
SCORE=0
mkdir -p tmp
rm -rf tmp/*
echo Fetching snapshot $1 / main ...
wget -O tmp/main-packages.gz http://snapshot.debian.org/archive/debian/$1/dists/sid/main/binary-amd64/Packages.gz
gunzip -c tmp/main-packages.gz > tmp/main-packages.txt
rm -rf tmp/main-packages.gz
echo Fetching snapshot $1 / contrib ...
wget -O tmp/contrib-packages.gz http://snapshot.debian.org/archive/debian/$1/dists/sid/contrib/binary-amd64/Packages.gz
gunzip -c tmp/contrib-packages.gz > tmp/contrib-packages.txt
rm -rf tmp/contrib-packages.gz
echo Fetching snapshot $1 / non-free ...
wget -O tmp/non-free-packages.gz http://snapshot.debian.org/archive/debian/$1/dists/sid/non-free/binary-amd64/Packages.gz
gunzip -c tmp/non-free-packages.gz > tmp/non-free-packages.txt
rm -rf tmp/non-free-packages.gz
cat tmp/main-packages.txt tmp/contrib-packages.txt tmp/non-free-packages.txt | sed -n -e '/Package:\|Version:/p' | sed ':a;N;$!ba;s/\nVersion://g' | sed 's/Package: //g' > tmp/all-packages.txt
if [ "$(wc -l tmp/all-packages.txt | cut -d' ' -f1)" -lt 1 ];then
echo "Packages log is empty. Please try another timestamp."
exit 1;
fi
while read str; do
read -ra arr <<< "$str"
#arr=($str)
PKG=${arr[0]}
TAMBORA_VER=${arr[1]}
SID_PKG=$(cat tmp/all-packages.txt | grep "^$PKG " | cut -d' ' -f1)
SID_VER=$(cat tmp/all-packages.txt | grep "^$PKG " | cut -d' ' -f2)
echo -n "compare for $PKG $TAMBORA_VER vs $SID_PKG $SID_VER"
if [ "x$SID_PKG" == "x$PKG" ];then
if [ "x$SID_VER" == "x$TAMBORA_VER" ];then
SCORE=$((SCORE+1))
echo " MATCHED"
else
echo " MEH"
fi
fi
done <$2
rm -rf *-$1.result
touch $SCORE-$1.result
echo ""
echo "Score : $SCORE of $(wc -l $2 | cut -d' ' -f1)"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment