From aa42717ba0a6ee114b79fd8a62c00c974072c024 Mon Sep 17 00:00:00 2001
From: rbalocca <rbalocca@vyatta.com>
Date: Mon, 7 Jul 2008 14:43:15 -0700
Subject: Fix for bug http://bugzilla.vyatta.com/show_bug.cgi?id=2807

---
 templates/system/package/repository/node.def | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'templates/system/package/repository/node.def')

diff --git a/templates/system/package/repository/node.def b/templates/system/package/repository/node.def
index 8d753918..9c7697f8 100644
--- a/templates/system/package/repository/node.def
+++ b/templates/system/package/repository/node.def
@@ -2,15 +2,22 @@ tag:
 
 type: txt
 
-help: Set name of a debian archive
+help: Set the name of a debian archive
 
 commit:expression: $VAR(./url/) != ""; "Must configure the repository URL"
 commit:expression: $VAR(./distribution/) != ""; "Must configure the repository distribution"
 commit:expression: $VAR(./components/) != ""; "Must configure the repository components"
 
-update: sudo sh -c "touch /etc/apt/sources.list && \
-sed -i '\\!# $VAR(@) #!d' /etc/apt/sources.list && \
-echo \"deb $VAR(url/@)/ $VAR(distribution/@) $VAR(components/@) # $VAR(@) #\" >> /etc/apt/sources.list"
+update: sudo bash -c "set -x; touch /etc/apt/sources.list && \
+	sed -i '\\!# $VAR(@) #!d' /etc/apt/sources.list && \
+	echo \"deb $VAR(url/@) $VAR(distribution/@) $VAR(components/@) # $VAR(@) #\" >> /tmp/$$-sources.list && \
+	if [ $VAR(password/@) ] || [ $VAR(username/@) ]; \
+	then \
+		sed -i "s!://.*@!://!" /tmp/$$-sources.list; \
+		sed -i "s!://!://$VAR(username/@):$VAR(password/@)@!" /tmp/$$-sources.list; \
+	fi && \
+	cat /tmp/$$-sources.list>>/etc/apt/sources.list ; \
+	rm -f /tmp/$$-sources.list"
 
 delete: sudo sh -c "touch /etc/apt/sources.list && \
 sed -i '\\!# $VAR(@) #!d' /etc/apt/sources.list"
-- 
cgit v1.2.3

