From afa935ac9baf3bef8fcc1dff13750a409e5cda96 Mon Sep 17 00:00:00 2001 From: Karanbir Singh Date: Jun 07 2014 00:25:31 +0000 Subject: add the get_sources.sh file so people can get non-text sources --- diff --git a/README.md b/README.md index 4d1ae66..2a015a5 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Welcome to git.centos.org This git repo contains the following scripts that make interfacing with git.c.o, reimzul and nazar as easy as possible. +Tools: + * get_sources.sh: when run from inside a package git checkout, will download the relevant non-text sources from the lookaside cache and drop them into the SOURCES/ dir; note: it will generate 0 byte files in place, rather than download them. + Terms: * Nazar : the beanstalkd worker queue that runs most build and delivery services for various CentOS components diff --git a/get_sources.sh b/get_sources.sh new file mode 100755 index 0000000..4cb6c5a --- /dev/null +++ b/get_sources.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Script to parse the non-text sources metadata file and download +# the required files from the lookaside cache +# +# Please note: this script is non-destructive, it wont replace +# files that already exist, regardless of their state, allowing you +# to have work-in-progress content that wont get overwritten. +# +# Might want to drop this in ~/bin/ and chmod u+x it + + +pn=$(basename `pwd`) +f=.${pn}.metadata +if [ ! -e $f ] || [ ! -d .git ] || [ ! -d SOURCES ]; then + echo 'You need to run this from inside a sources git repo' + exit 1 +fi +br=$(cat .git/HEAD |awk -F'/' '{print $3}' ) +while read a ; do + fsha=$( echo $a | cut -f1 -d\ ) + fname=$( echo $a | cut -f2 -d\ ) + if [ $fsha = "da39a3ee5e6b4b0d3255bfef95601890afd80709" ]; then + # zero byte file + touch $fname + else + if [ ! -e ${fname} ]; then + curl https://git.centos.org/sources/${pn}/${br}/${fsha} -o ${fname} + else + echo "${fname} exists. skipping" + fi + fi +done < $f