From 0aee0b1f9e3ffce613a01318cd7e7351025cff0c Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Wed, 7 Oct 2015 17:02:21 -0700 Subject: [PATCH 1/2] add script to generate index listing for the repo if say hosted on s3 Signed-off-by: Jessica Frazelle --- hack/make/generate-index-listing | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 hack/make/generate-index-listing diff --git a/hack/make/generate-index-listing b/hack/make/generate-index-listing new file mode 100755 index 0000000000..1808ce9caa --- /dev/null +++ b/hack/make/generate-index-listing @@ -0,0 +1,74 @@ +#!/bin/bash +set -e + +# This script generates index files for the directory structure +# of the apt and yum repos + +: ${DOCKER_RELEASE_DIR:=$DEST} +APTDIR=$DOCKER_RELEASE_DIR/apt +YUMDIR=$DOCKER_RELEASE_DIR/yum + +if [ ! -d $APTDIR ] && [ ! -d $YUMDIR ]; then + echo >&2 'release-rpm or release-deb must be run before generate-index-listing' + exit 1 +fi + +create_index() { + local directory=$1 + local original=$2 + local cleaned=${directory#$original} + + # the index file to create + local index_file="${directory}/index" + + # cd into dir & touch the index file + cd $directory + touch $index_file + + # print the html header + cat <<-EOF > "$index_file" + + + Index of ${cleaned}/ + +

Index of ${cleaned}/


+
../
+	EOF
+
+	# start of content output
+	(
+	# change IFS locally within subshell so the for loop saves line correctly to L var
+	IFS=$'\n';
+
+	# pretty sweet, will mimick the normal apache output
+	for L in $(find -L . -mount -depth -maxdepth 1 -type f ! -name 'index' -printf "%-44f@_@%Td-%Tb-%TY %Tk:%TM  @%f@\n"|sort|sed 's,\([\ ]\+\)@_@,\1,g');
+	do
+		# file
+		F=$(sed -e 's,^.*@\([^@]\+\)@.*$,\1,g'<<<"$L");
+
+		# file with file size
+		F=$(du -bh $F | cut -f1);
+
+		# output with correct format
+		sed -e 's,\ @.*$, '"$F"',g'<<<"$L";
+	done;
+	) >> $index_file;
+
+	# now output a list of all directories in this dir (maxdepth 1) other than '.' outputting in a sorted manner exactly like apache
+	find -L . -mount -depth -maxdepth 1 -type d ! -name '.' -printf "%-43f@_@%Td-%Tb-%TY %Tk:%TM  -\n"|sort -d|sed 's,\([\ ]\+\)@_@,/\1,g' >> $index_file
+
+	# print the footer html
+	echo "

" >> $index_file + +} + +get_dirs() { + local directory=$1 + + for d in `find ${directory} -type d`; do + create_index $d $directory + done +} + +get_dirs $APTDIR +get_dirs $YUMDIR From 96559aaef22923c9c0d3d75e21e0c85f5b5ad47c Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Wed, 7 Oct 2015 17:02:51 -0700 Subject: [PATCH 2/2] add clean apt db to release script Signed-off-by: Jessica Frazelle --- hack/make/release-deb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/make/release-deb b/hack/make/release-deb index 3fcbf369e3..9353683da2 100755 --- a/hack/make/release-deb +++ b/hack/make/release-deb @@ -124,13 +124,15 @@ for dir in contrib/builder/deb/*/; do -name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist" done +# clean the databases +apt-ftparchive clean "$APTDIR/conf/apt-ftparchive.conf" # run the apt-ftparchive commands so we can have pinning apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf" for dir in contrib/builder/deb/*/; do version="$(basename "$dir")" - codename="${version//debootstrap-}" + codename="${version//debootstrap-}" apt-ftparchive \ -o "APT::FTPArchive::Release::Codename=$codename" \