[Lunar-commits] r27003 - in lunar/trunk: bin var/lib/lunar/functions

Auke Kok sofar at lunar-linux.org
Mon Dec 10 20:41:12 CET 2007


Author: sofar
Date: 2007-12-10 20:41:12 +0100 (Mon, 10 Dec 2007)
New Revision: 27003

Modified:
   lunar/trunk/bin/lvu
   lunar/trunk/var/lib/lunar/functions/config.lunar
Log:
lvu submit changes - make real git patches instead. 

Some whitespace in user variables can break our config system.


Modified: lunar/trunk/bin/lvu
===================================================================
--- lunar/trunk/bin/lvu	2007-12-01 07:33:07 UTC (rev 27002)
+++ lunar/trunk/bin/lvu	2007-12-10 19:41:12 UTC (rev 27003)
@@ -792,9 +792,9 @@
   # as good as it gets
   if [ "$ZLOCAL_OVERRIDES" != "on" ]; then
     message "You can't submit non-zlocal modules. Turn on ZLOCAL_OVERRIDES"
-	message "and do \`lvu edit \$MODULE; lin moonbase\`"
-	message "so that module changes can be tracked properly!"
-	exit 1
+    message "and do \`lvu edit \$MODULE; lin moonbase\`"
+    message "so that module changes can be tracked properly!"
+    exit 1
   fi
   if [ -z "$1" ]; then
     message "submit requires a single module name."
@@ -804,13 +804,20 @@
     message "submit requires curl, please \`lin curl\`"
     exit 1
   fi
-  if [ -z "$ADMIN" -o "$ADMIN" == "$USER" ]; then
+  if [ -z "$ADMIN" -o "$ADMIN" == "$USER" -o "$ADMIN" == "root" ]; then
     message "Please set ADMIN to your e-mail address: lunar set ADMIN \"me at my.mail.domain\""
     exit 1
   fi
+  if [ -z "$REALNAME" ]; then
+    REALNAME="getent passwd $USER | cut -d: -f5 | cut -d, -f1"
+    if [ -z "$G_REALNAME" ]; then
+      message "Please set REALNAME to your real name: lunar set REALNAME \"John Notdoe\""
+      exit 1
+    fi
+  fi
   if ! run_details "$1" ; then
-      message "submit requires an existing module"
-      exit 1
+    message "submit requires an existing module"
+    exit 1
   else
     if echo $SECTION | grep -q '^zlocal' ; then
       ZLOCAL_OVERRIDES=off SECTION=$(find_section $1)
@@ -824,17 +831,23 @@
       exit 1
     fi
     TMP_MSG=$(temp_create "submission")
+    TMP_MSG2=$(temp_create "submission")
     (
+      echo "$1: "
       echo ""
-      echo "# type a changelog message here"
-      echo "# all lines starting with '#' will be removed"
+      echo ""
+      echo "# type a changelog message here. The first line should start with"
+      echo "# the module name and summarize your change. All lines starting with '#'"
+      echo "# will be removed automatically"
     ) > $TMP_MSG
     edit_file $TMP_MSG
     sed -i '/^#/d' $TMP_MSG
     (
+      head -n 1 $TMP_MSG
       echo ''
+      echo "From: $REALNAME <$ADMIN>"
+      tail +2 $TMP_MSG
       echo '---'
-      echo 'from:' $ADMIN
       echo 'module:' $1
       echo "id: $UNIQID"
       echo "lvu submit: $1"
@@ -845,14 +858,18 @@
       echo "glibc: $(installed_version glibc)"
       echo ''
       echo '---'
+      lvu diff $1 | diffstat -p1
+      echo ''
+      echo '---'
       lvu diff $1
-    ) >> $TMP_MSG
-    cat $TMP_MSG
+    ) >> $TMP_MSG2
+    cat $TMP_MSG2
     if query "Submit this module now?" y; then
-      curl -F file=@$TMP_MSG -F module=$1 -F id=$UNIQID "http://lunar-linux.org/submit.php"
+      curl -F file=@$TMP_MSG2 -F module=$1 -F id=$UNIQID "http://lunar-linux.org/submit.php"
+      temp_destroy $TMP_MSG2
       temp_destroy $TMP_MSG
     else
-      message "Submission aborted. your submission was saved as $TMP_MSG"
+      message "Submission aborted. your submission was saved as $TMP_MSG2"
     fi
   fi
 }

Modified: lunar/trunk/var/lib/lunar/functions/config.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/config.lunar	2007-12-01 07:33:07 UTC (rev 27002)
+++ lunar/trunk/var/lib/lunar/functions/config.lunar	2007-12-10 19:41:12 UTC (rev 27003)
@@ -20,31 +20,32 @@
 
 set_config()
 {
-	local LINE NEW
+	local LINE NEW FILE VAR
 	debug_msg "set_config ($@)"
 
 	LINE=$(grep -w "$2=.*" $1)
-	if [ "$1" == "$LOCAL_CONFIG" ] ; then
-		NEW=$(printf "%16s=%s" "$2" "$3")
+	FILE=$1
+	VAR=$2
+	shift 2
+	if [ "$FILE" == "$LOCAL_CONFIG" ] ; then
+		NEW="$(printf "%16s" "$VAR")=\"$@\""
 	else
-		NEW="$2=\"$3\""
+		NEW="$VAR=\"$@\""
 	fi
 
 	# on-demand creation
-	if [ ! -f $1 ] ; then
-		touch $1
+	if [ ! -f $FILE ] ; then
+		touch $FILE
 	fi
 
-	lock_file $1 &&
+	lock_file $FILE &&
 	if [ -n "$LINE" ] ; then
 		# make sure we escape those ':' characters:
 		LINE=$(echo $LINE | sed 's/:/\\:/g')
-		NEW=$(echo $NEW | sed 's/:/\\:/g')
-		sedit "s:$LINE:$NEW:" $1
-	else
-		echo "$NEW" >> $1
+		sedit "/[^ ]$VAR=/d" $FILE
 	fi
-	unlock_file $1
+	echo "$NEW" >> $FILE
+	unlock_file $FILE
 }
 
 
@@ -77,7 +78,10 @@
 set_local_config()
 {
 	debug_msg "set_local_config ($@)"
-	set_config "$LOCAL_CONFIG" "$1" "$2"
+	local VAR
+	VAR=$1
+	shift
+	set_config "$LOCAL_CONFIG" "$VAR" "$@"
 }
 
 



More information about the Lunar-commits mailing list