refine strategy to spot ip address, keep on calling guest_ipv4
[build.git] / partial-repo.sh
index 3af0134..89657c8 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/sh
-# $URL$
 
 COMMAND=$(basename $0)
 
@@ -9,22 +8,34 @@ function usage () {
     exit 1
 }
 
-[[ -n "$@" ]] || usage
+    OPTS=$(getopt -o "ih" -- "$@")
+    if [ $? != 0 ]; then usage; fi
+    eval set -- "$OPTS"
+    while true; do
+       case $1 in
+           -i) INCREMENTAL=true; shift;;
+           -h) usage;;
+            --) shift; break ;;
+       esac
+    done
 
 set -e 
 
-for repo in "$@" ; do
-    if [ ! -d $repo/RPMS ] ; then
-       echo could not find $repo/RPMS - ignored
+for rpms_dir in $(find "$@" -name RPMS) ; do
+    pushd $rpms_dir >& /dev/null
+    cd ..
+    echo "============================== Dealing with repo $(pwd)"
+    if [ -d PARTIAL-RPMS -a -n "$INCREMENTAL" ]; then
+       echo "$COMMAND - incremental mode"
+       echo "repo $rpms_dir already has a PARTIAL-RPMS - skipped"
+       popd >& /dev/null
        continue
     fi
-
-    cd $repo
-    echo "==================== Dealing with repo $repo"
     mkdir -p PARTIAL-RPMS
-    rsync --archive --verbose $(find RPMS -type f | egrep '/(bootcd|nodeimage|noderepo|slicerepo)-.*-.*-.*-.*rpm') PARTIAL-RPMS/
-    echo "==================== building packages index in $repo .."
+    echo "========== rsyncing relevant rpms into PARTIAL-RPMS"
+    rsync --archive --verbose $(find RPMS -type f | grep -E '/(bootcd|bootstrapfs|nodeimage|noderepo|slicerepo)-.*-.*-.*-.*rpm') PARTIAL-RPMS/
+    echo "========== building packages index (i.e. running createrepo) in $(pwd)/PARTIAL-RPMS"
     createrepo PARTIAL-RPMS
-    echo '==================== DONE'
-    cd - >& /dev/null
+    echo "========== DONE"
+    popd >& /dev/null
 done