Skip to content

Instantly share code, notes, and snippets.

@Guibod
Created May 27, 2014 13:35
Show Gist options
  • Save Guibod/4cabb408856a4396755d to your computer and use it in GitHub Desktop.
Save Guibod/4cabb408856a4396755d to your computer and use it in GitHub Desktop.
#!/bin/bash
# This file watch APT for changes in stable / main
# that are added for ALL architecture but not i386 and amd64
# This is a bug from deb-s3, that need every build to provide
# -a amd64, as they push file to s3 repository.
#
# check: https://github.com/krobertson/deb-s3/issues/20
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m' # No Color
BUCKET=mybucketname
DIST=stable
COMPONENT=main
# Get fresh main ALL arch packages
fetch_file -o binary-all.list s3://$BUCKET/dists/$DIST/$COMPONENT/binary-all/Packages
fetch_file -o binary-i386.list s3://$BUCKET/dists/$DIST/$COMPONENT/binary-i386/Packages
fetch_file -o binary-amd64.list s3://$BUCKET/dists/$DIST/$COMPONENT/binary-amd64/Packages
count=$(grep 'Package:' binary-all.list | wc -l)
i=0
for package in $(grep 'Package:' binary-all.list | cut -d" " -f2)
do
((i++))
echo -ne "${green}$package (${i} / ${count})"
data=$(grep "Package: ${package}\$" binary-all.list -A15)
all_filename=$(echo "$data" | grep 'Filename:'| cut -d" " -f2)
all_version=$(echo "$data" | grep 'Version:'| cut -d" " -f2)
all_sha1=$(echo "$data" | grep 'SHA1:'| cut -d" " -f2)
echo -ne " (${all_version})${NC}\n"
data=$(grep "Package: ${package}\$" binary-i386.list -A15)
i386_filename=$(echo "$data" | grep 'Filename:'| cut -d" " -f2)
i386_version=$(echo "$data" | grep 'Version:'| cut -d" " -f2)
i386_sha1=$(echo "$data" | grep 'SHA1:'| cut -d" " -f2)
i386_do=
if [[ -z "$i386_sha1" ]] || [[ "${i386_sha1}" != "${all_sha1}" ]]
then
i386_do="yes"
fi
data=$(grep "Package: ${package}\$" binary-amd64.list -A15)
amd64_filename=$(echo "$data" | grep 'Filename:'| cut -d" " -f2)
amd64_version=$(echo "$data" | grep 'Version:'| cut -d" " -f2)
amd64_sha1=$(echo "$data" | grep 'SHA1:'| cut -d" " -f2)
amd64_do=
if [[ -z "$amd64_sha1" ]] || [[ "${amd64_sha1}" != "${all_sha1}" ]]
then
amd64_do="yes"
fi
if [[ -z "$amd64_do" ]] && [[ -z "$i386_do" ]]
then
echo "Matching SHA1, for both amd64 and i386 ($all_sha1)"
continue
else
echo "Expected SHA1: $all_sha1"
echo "i386 SHA1: $i386_sha1"
echo "amd64 SHA1: $amd64_sha1"
fi
echo "fetching s3://$BUCKET/$all_filename..."
fetch_file -o package.deb s3://$BUCKET/$all_filename
echo "uploading..."
if [[ -n "$i386_do" ]]
then
/var/lib/gems/1.9.1/bin/deb-s3 upload --bucket $BUCKET --visibility=private --arch=i386 package.deb
fi
if [[ -n "$amd64_do" ]]
then
/var/lib/gems/1.9.1/bin/deb-s3 upload --bucket $BUCKET --visibility=private --arch=amd64 package.deb
fi
rm package.deb
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment