diff options
author | Peter Jones <pjones@redhat.com> | 2008-06-05 14:01:43 -0400 |
---|---|---|
committer | Peter Jones <pjones@pjones2.localdomain> | 2008-06-05 14:01:43 -0400 |
commit | 494fcc58c247206d3d8ad8cb9f2755266e2ddab4 (patch) | |
tree | 0c0155db8bed6adde3198f31efc967af45c03fe5 | |
parent | 06e55abfc642438f2b0f6aefc7d556b47ad2b256 (diff) | |
download | anaconda-494fcc58c247206d3d8ad8cb9f2755266e2ddab4.tar.gz anaconda-494fcc58c247206d3d8ad8cb9f2755266e2ddab4.tar.xz anaconda-494fcc58c247206d3d8ad8cb9f2755266e2ddab4.zip |
Make "upd-updates /tmp/updates.img" update everything newer in the current
working directory /if/ it's a git+ssh checkout of anaconda.
-rwxr-xr-x | scripts/upd-updates | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/scripts/upd-updates b/scripts/upd-updates index 62c34057c..1d4f34a43 100755 --- a/scripts/upd-updates +++ b/scripts/upd-updates @@ -18,16 +18,29 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +isAnacondaGitDir() { + [ -f .git/config ] || return 1 + grep -q 'url = git+ssh://git\.fedoraproject\.org/git/hosted/anaconda\.git' .git/config +} + usage() { if [ $1 -ne 0 ]; then >&2 fi - echo "upd-updates <updates.img> <file0> [<file1> [...]]" + echo "upd-updates <updates.img> [<file0> [<file1> [...]]]" exit $1 } -[ -z "$1" -o -z "$2" ] && usage 1 +[ -z "$1" ] && usage 1 [ "$1" == "--help" ] && usage 0 +updateAll=no +if [ -z "$2" ]; then + if isAnacondaGitDir ; then + updateAll=yes + else + usage 1 + fi +fi TARGET="$1" ; shift @@ -41,17 +54,19 @@ if [ "$OK" == "no" ]; then exit 2 fi -n=1 -while [ -n "$(eval echo '${'$n'}')" ]; do - arg="$(eval echo '${'$n'}')" - [ ${arg} == "--help" -o ${arg} == "-h" ] && usage 0 - - if [ ! -r ${arg} ]; then - echo "upd-updates: cannot read ${arg}" 1>&2 - exit 3 - fi - n=$(($n + 1)) -done +if [ "$updateAll" == "no" ]; then + n=1 + while [ -n "$(eval echo '${'$n'}')" ]; do + arg="$(eval echo '${'$n'}')" + [ ${arg} == "--help" -o ${arg} == "-h" ] && usage 0 + + if [ ! -r ${arg} ]; then + echo "upd-updates: cannot read ${arg}" 1>&2 + exit 3 + fi + n=$(($n + 1)) + done +fi TMPDIR=$(mktemp -d) if [ ! -d ${TMPDIR} ]; then @@ -64,10 +79,23 @@ if [ -e "$TARGET" ]; then [ $? -eq 0 ] || exit 5 fi -echo ${@} | tr ' ' '\0' | tr -d '\n' | cpio --null -H newc --quiet -o | \ - ( cd $TMPDIR ; cpio -di --quiet -dm --unconditional ) - -[ $? -eq 0 ] || exit 6 +if [ "$updateAll" == "yes" ]; then + # this may do the wrong thing if we have two files named the same... + # so, uh, don't do that. + for oldfile in $(find "$TMPDIR" -type f) ; do + for newfile in $(find . -name $(basename $oldfile)) ; do + if [ "$oldfile" -ot "$newfile" ]; then + cp -av "$newfile" "$oldfile" + fi + done + done +else + echo ${@} | tr ' ' '\0' | tr -d '\n' | \ + cpio --null -H newc --quiet -o | \ + ( cd $TMPDIR ; cpio -di --quiet -dm --unconditional ) + + [ $? -eq 0 ] || exit 6 +fi (cd $TMPDIR ; find . -depth -print0 | cpio -H newc --quiet --null -o ) | \ gzip -9 > "$TARGET" |