[SCM] pkg-kde repository scripts branch, master, updated. f6ae4f8a61c7f93340c4cdcd5d5df2686dd20d9b

Modestas Vainius modax-guest at alioth.debian.org
Sat Nov 14 12:45:17 UTC 2009


The following commit has been merged in the master branch:
commit 376f07d789a1f0b44db278edbf2170fb737f0aa2
Author: Modestas Vainius <modestas at vainius.eu>
Date:   Sat Nov 14 14:32:14 2009 +0200

    create_repository: implement update of individual files.
---
 create-repository |   49 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/create-repository b/create-repository
index b060800..2e509b9 100755
--- a/create-repository
+++ b/create-repository
@@ -21,32 +21,49 @@ while getopts n:p:u: opt; do
 		\?) usage;;
 	esac
 done
+shift $(($OPTIND-1))
 
 if [ -z "$name" ] || [ -z "$path" ] || [ -z "$url" ]; then
 	echo "You must specify name, path and url" >&2
 	usage;
 fi
 
-if [ -e "$name" ]; then
+if ! ( [ -d "$name" ] && [ "$#" -gt 0 ] ) && [ -e "$name" ]; then
     echo "File or directory $name already exists." >&2
-    echo "Remove it before creating a new repository." >&2
+    echo "Remove it before creating a new repository from scratch." >&2
     exit 1
 fi
 
-mkdir "$name"
-for dir in $SUBDIRS; do
-    if [ ! -d "$name/$dir" ]; then
-        mkdir -p "$name/$dir"
-    fi
-done
+install_file() {
+	local src dst dir
+	src="$1"
+	dst="$2"
+	dir=`dirname "$dst"`
+	if [ ! -d "$dir" ]; then
+		mkdir -p "$dir"
+	fi
+	sed "$src" \
+		-e 's@${__REPOSITORY_NAME__}@'"$name"'@g' \
+		-e 's@${__REPOSITORY_PATH__}@'"$path"'@g' \
+		-e 's@${__REPOSITORY_URL__}@'"$url"'@g' \
+	> "$dst"
+}
 
-find $SUBDIRS -mindepth 1 -maxdepth 1 -name "`basename $0`" -o -type f -print | while read f; do
-    sed "$f" \
-        -e 's@${__REPOSITORY_NAME__}@'"$name"'@g' \
-        -e 's@${__REPOSITORY_PATH__}@'"$path"'@g' \
-        -e 's@${__REPOSITORY_URL__}@'"$url"'@g' \
-    > "$name/$f"
-done
+if [ "$#" -gt 0 ]; then
+	while [ "$#" -gt 0 ]; do
+		f="$1"; shift
+		if [ ! -f "$f" ]; then
+			echo "File '$f' does not exist" >&2
+			exit 2
+		fi
+		install_file "$f" "$name/$f"
+	done
+	echo "Files have been successfully updated in $name/" 2>&1
+else
+	find $SUBDIRS -mindepth 1 -maxdepth 1 -name "`basename $0`" -o -type f -print | while read f; do
+		install_file "$f" "$name/$f"
+	done
+	echo "Repository '$name' has been successfully created in $name/" 2>&1
+fi
 
-echo "Repository '$name' has been successfully created in $name/" 2>&1
 exit 0

-- 
pkg-kde repository scripts



More information about the pkg-kde-commits mailing list