summaryrefslogtreecommitdiff
path: root/buildscripts/consolidate-repos.sh
diff options
context:
space:
mode:
authorErnie Hershey <ernie.hershey@10gen.com>2013-03-26 15:51:03 -0400
committerErnie Hershey <ernie.hershey@10gen.com>2013-03-26 15:51:03 -0400
commit75d38d081ea7a38a4c254ba01a0d61a279746b21 (patch)
treee1be291b8fc811f9cf73e9fdbc48124e7d8a33bb /buildscripts/consolidate-repos.sh
parent1a8b7b4241cc17524a482e7caa7fbbba90cbabbc (diff)
downloadmongo-75d38d081ea7a38a4c254ba01a0d61a279746b21.tar.gz
SERVER-4808 Provide repo downloads of older versions of packages
This is used to consolidate multiple package versions into one repository directory.
Diffstat (limited to 'buildscripts/consolidate-repos.sh')
-rwxr-xr-xbuildscripts/consolidate-repos.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/buildscripts/consolidate-repos.sh b/buildscripts/consolidate-repos.sh
new file mode 100755
index 00000000000..91d80bf09bc
--- /dev/null
+++ b/buildscripts/consolidate-repos.sh
@@ -0,0 +1,86 @@
+#!/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"
+
+tempfile=`mktemp /tmp/consolidate-repos.XXXXXX`
+
+mkdir -p "$repodir"
+
+find "$source_dir" -name \*.rpm -o -name \*.deb -o -name Release | grep -v "$repodir" > "$tempfile"
+
+echo "Scanning and copying package files from $source_dir"
+echo ". = skipping existing file, @ = copying file"
+while read package
+do
+ new_package_location="$repodir`echo \"$package\" | sed 's/\/var\/www\/[^\/]*//;'`"
+
+ # skip if the directory structure looks weird
+ #
+ if [ "`echo \"$new_package_location\" | grep /repo/`" ]
+ then
+ continue
+ fi
+
+ # skip if it's already there
+ #
+ if [ -e "$new_package_location" -a "`basename \"$package\"`" != "Release" ]
+ then
+ echo -n .
+ else
+ mkdir -p "`dirname \"$new_package_location\"`"
+ echo -n @
+ cp "$package" "$new_package_location"
+ fi
+done < "$tempfile"
+echo
+
+# packages are in place, now create metadata
+#
+for debian_dir in "$repodir"/ubuntu-* "$repodir"/debian-*
+do
+ cd "$debian_dir"
+ for arch_dir in dists/dist/10gen/*
+ 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
+
+ for release_dir in "$debian_dir"/dists/dist
+ do
+ 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
+ done
+done
+
+for redhat_dir in "$repodir"/redhat/os/*
+do
+ echo "Generating redhat repo metadata under $redhat_dir"
+ cd "$redhat_dir"
+ createrepo .
+done
+
+