2013-03-26 20:51:03 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# consolidate-repos.sh
|
|
|
|
#
|
|
|
|
# Create new repo directory under /var/www/repo.consolidated
|
|
|
|
# containing every deb and every rpm under /var/www/ with proper
|
|
|
|
# repo metadata for Debian and Ubuntu
|
|
|
|
#
|
|
|
|
|
|
|
|
source_dir=/var/www
|
|
|
|
|
|
|
|
repodir=/var/www/repo.consolidated
|
|
|
|
|
|
|
|
gpg_recip='<richard@10gen.com>'
|
|
|
|
|
|
|
|
echo "Using directory: $repodir"
|
|
|
|
|
|
|
|
mkdir -p "$repodir"
|
|
|
|
|
|
|
|
echo "Scanning and copying package files from $source_dir"
|
|
|
|
echo ". = skipping existing file, @ = copying file"
|
2013-12-20 22:29:41 +01:00
|
|
|
for package in $(find "$source_dir/" -not \( -path "$repodir" -prune \) -not -path \*enterprise\* -and \( -name \*.rpm -o -name \*.deb -o -name Release \))
|
2013-03-26 20:51:03 +01:00
|
|
|
do
|
2013-12-20 22:29:41 +01:00
|
|
|
new_package_location="$repodir$(echo "$package" | sed 's/\/var\/www\/[^\/]*//;')"
|
2013-03-26 20:51:03 +01:00
|
|
|
|
|
|
|
# skip if the directory structure looks weird
|
|
|
|
#
|
2013-12-20 22:29:41 +01:00
|
|
|
if echo "$new_package_location" | grep -q /repo/
|
2013-03-26 20:51:03 +01:00
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# skip if it's already there
|
|
|
|
#
|
2013-12-20 22:29:41 +01:00
|
|
|
if [ -e "$new_package_location" -a "$(basename "$package")" != "Release" ]
|
2013-03-26 20:51:03 +01:00
|
|
|
then
|
|
|
|
echo -n .
|
|
|
|
else
|
2013-12-20 22:29:41 +01:00
|
|
|
mkdir -p "$(dirname "$new_package_location")"
|
2013-03-26 20:51:03 +01:00
|
|
|
echo -n @
|
|
|
|
cp "$package" "$new_package_location"
|
|
|
|
fi
|
2013-12-20 22:29:41 +01:00
|
|
|
done
|
2013-03-26 20:51:03 +01:00
|
|
|
echo
|
|
|
|
|
|
|
|
# packages are in place, now create metadata
|
|
|
|
#
|
|
|
|
for debian_dir in "$repodir"/ubuntu-* "$repodir"/debian-*
|
|
|
|
do
|
|
|
|
cd "$debian_dir"
|
2013-11-30 17:42:52 +01:00
|
|
|
for arch_dir in dists/dist/10gen/*
|
2013-03-26 20:51:03 +01:00
|
|
|
do
|
|
|
|
echo "Generating Packages file under $debian_dir/$arch_dir"
|
|
|
|
dpkg-scanpackages --multiversion "$arch_dir" > "$arch_dir"/Packages
|
|
|
|
gzip -9c "$arch_dir"/Packages > "$arch_dir"/Packages.gz
|
|
|
|
done
|
|
|
|
|
2013-12-20 22:29:41 +01:00
|
|
|
release_dir="$debian_dir"/dists/dist
|
|
|
|
echo "Generating Release file under $release_dir"
|
|
|
|
cd $release_dir
|
|
|
|
tempfile=$(mktemp /tmp/ReleaseXXXXXX)
|
|
|
|
tempfile2=$(mktemp /tmp/ReleaseXXXXXX)
|
|
|
|
mv Release $tempfile
|
|
|
|
head -9 $tempfile > $tempfile2
|
|
|
|
apt-ftparchive release . >> $tempfile2
|
|
|
|
cp $tempfile2 Release
|
|
|
|
chmod 644 Release
|
|
|
|
rm Release.gpg
|
|
|
|
echo "Signing Release file"
|
|
|
|
gpg -r "$gpg_recip" --no-secmem-warning -abs --output Release.gpg Release
|
2013-03-26 20:51:03 +01:00
|
|
|
done
|
|
|
|
|
2014-08-20 23:17:06 +02:00
|
|
|
for rpm_dir in "$repodir"/redhat/os/* "$repodir"/suse/os/*
|
2013-03-26 20:51:03 +01:00
|
|
|
do
|
2014-08-20 23:17:06 +02:00
|
|
|
echo "Generating rpm repo metadata under $redhat_dir"
|
|
|
|
cd "$rpm_dir"
|
2013-03-26 20:51:03 +01:00
|
|
|
createrepo .
|
|
|
|
done
|