+# restore original grml sources.list file:
+if [ -r $target/etc/apt/sources.list.d/grml.unused ] ; then
+ mv $target/etc/apt/sources.list.d/grml.unused $target/etc/apt/sources.list.d/grml.list
+fi
+
+GRML_SOURCES_LIST="$target/etc/apt/sources.list.d/grml.list"
+DEBIAN_SOURCES_LIST="$target/etc/apt/sources.list.d/debian.list"
+
+[ -d $target/etc/apt/sources.list.d ] || mkdir $target/etc/apt/sources.list.d
+
+# remove any existing sources.list and inform user about the new
+# /etc/apt/sources.list.d/ setup:
+cat > $target/etc/apt/sources.list << EOF
+##### IMPORTANT NOTE ##############################################
+# The configuration file /etc/apt/sources.list has been split
+# into structured files in /etc/apt/sources.list.d/ - check out:
+#
+# /etc/apt/sources.list.d/grml.list for the grml related repositories
+# /etc/apt/sources.list.d/debian.list for official Debian repositories
+#
+# If you're looking for the "old" /etc/apt/sources.list file or
+# need some further repositories please take a look at the file
+# /etc/apt/sources.list.grml
+##### IMPORTANT NOTE ##############################################
+EOF
+
+# retrieve build information ($SUITE):
+if [ -r $target/etc/grml_live_version ] ; then
+ . $target/etc/grml_live_version
+fi
+
+# if we stil do not know which Debian suite we are building assume "stable"
+[ -n "$SUITE" ] || SUITE="stable"
+
+# configure official Debian repositories:
+cat > "$DEBIAN_SOURCES_LIST" << EOF
+# official debian repository:
+ deb http://cdn.debian.net/debian/ $SUITE main contrib non-free
+ deb-src http://cdn.debian.net/debian/ $SUITE main contrib non-free
+EOF
+
+# configure grml-stable repository:
+cat > "$GRML_SOURCES_LIST" << EOF
+# stable grml repository:
+ deb http://deb.grml.org/ grml-stable main
+ deb-src http://deb.grml.org/ grml-stable main
+EOF
+
+ENABLE_GRML_TESTING=false
+# if we have a devel-version or a daily snapshot enable grml-testing by default:
+if [ -n "$GRML_NAME" -o -n "$RELEASENAME" ] ; then
+ if echo "$GRML_NAME" "$RELEASENAME" | grep -e devel -e autobuild 1>/dev/null ; then
+ ENABLE_GRML_TESTING=true
+ fi
+fi
+
+if $ENABLE_GRML_TESTING ; then
+ cat >> "$GRML_SOURCES_LIST" << EOF
+# testing/developer grml repository:
+ deb http://deb.grml.org/ grml-testing main
+ deb-src http://deb.grml.org/ grml-testing main
+EOF
+else # no devel/daily build:
+ cat >> "$GRML_SOURCES_LIST" << EOF
+# testing/developer grml repository:
+# deb http://deb.grml.org/ grml-testing main
+# deb-src http://deb.grml.org/ grml-testing main
+EOF
+fi