From b28d3e3c6ef9e4f099a4932246771796bd07dbd5 Mon Sep 17 00:00:00 2001
From: Christopher Spinrath <admin@spinrath.net>
Date: Thu, 27 Aug 2015 17:50:04 +0200
Subject: [PATCH] rootfs_remaster: generate apt/sources.list

Since lipck knows the release it can do it and nobody will miss
to edit the static sources.list again (in particular, this sucks
when trying out new releases)
---
 Makefile                        | 9 +++++++++
 config/Makefile.conf.defaults   | 2 ++
 contrib/rootfs/lip_sources.list | 6 ------
 scripts/rootfs_remaster.sh      | 4 ----
 4 files changed, 11 insertions(+), 10 deletions(-)
 delete mode 100644 contrib/rootfs/lip_sources.list

diff --git a/Makefile b/Makefile
index 8d7867e..eed2e46 100644
--- a/Makefile
+++ b/Makefile
@@ -178,6 +178,15 @@ $(call gentargets,$(STATE_DIR)/rootfs_prepared) : $(call archdir,%)$(STATE_DIR)/
 rootfs_remaster : $(ARCH_DIR)$(STATE_DIR)/rootfs_remastered
 $(call gentargets,$(STATE_DIR)/rootfs_remastered) : $(call archdir,%)$(STATE_DIR)/rootfs_extracted | $(APT_CACHE_DIR)
 	$(MAKE) ARCH=$* rootfs_prepare
+ifneq($(strip $(APT_SOURCE_URL_OVERRIDE)),)
+	#override apt sources list
+	echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE) main restricted universe multiverse" \
+		> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
+        echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE)-security main restricted universe multiverse" \
+                >> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
+        echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE)-updates main restricted universe multiverse" \
+                >> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
+endif
 	mkdir -p "$(call archdir,$*)$(LXC_DIR)"
 	lxc-execute --name "lipck_remaster_$*" -P "$(call archdir,$*)$(LXC_DIR)" -f "$(CURDIR)/config/lxc_common.conf" \
 	-s lxc.arch="$*" -s lxc.rootfs="$(call archdir,$*)$(ROOTFS)" \
diff --git a/config/Makefile.conf.defaults b/config/Makefile.conf.defaults
index 6fdb847..cafd98b 100644
--- a/config/Makefile.conf.defaults
+++ b/config/Makefile.conf.defaults
@@ -27,6 +27,8 @@ ISO_VERSION=14.04.2
 ISO_FLAVOR=kubuntu
 ISO_PATTERN_FLAGS=
 
+APT_SOURCE_URL_OVERRIDE=http://ftp.halifax.rwth-aachen.de/ubuntu/
+
 IMAGE_DIR=$(WORKSPACE)/image_files/
 IMAGE_GIT_URL=https://www.fsmpi.rwth-aachen.de/git/lipstick
 IMAGE_GIT_BRANCH=ss15
diff --git a/contrib/rootfs/lip_sources.list b/contrib/rootfs/lip_sources.list
deleted file mode 100644
index 9ef2984..0000000
--- a/contrib/rootfs/lip_sources.list
+++ /dev/null
@@ -1,6 +0,0 @@
-deb http://ftp.halifax.rwth-aachen.de/ubuntu/ trusty main restricted universe multiverse
-deb http://security.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
-deb http://ftp.halifax.rwth-aachen.de/ubuntu/ trusty-updates main restricted universe multiverse
-
-#deb http://de.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
-#deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
diff --git a/scripts/rootfs_remaster.sh b/scripts/rootfs_remaster.sh
index 067aaa8..5406f92 100755
--- a/scripts/rootfs_remaster.sh
+++ b/scripts/rootfs_remaster.sh
@@ -42,10 +42,6 @@ fi
 
 function prepare_install()
 {
-	if [ -e "$CONTRIB_DIR/lip_sources.list" ]; then
-		cp -v "$CONTRIB_DIR/lip_sources.list" "/etc/apt/sources.list"
-	fi
-	
 	#uncomment if newest texlive is not part of your distribution
 	#add-apt-repository -y ppa:texlive-backports/ppa
 
-- 
GitLab