retrieve source packages via grml-live using SOURCES class
authorMichael Prokop <mika@grml.org>
Fri, 25 Nov 2011 18:18:47 +0000 (19:18 +0100)
committerMichael Prokop <mika@grml.org>
Sat, 26 Nov 2011 10:50:18 +0000 (11:50 +0100)
12 files changed:
docs/grml-live.txt
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_ETCH
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_LENNY
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_SID
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_SQUEEZE
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_STABLE
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_TESTING
etc/grml/fai/config/files/etc/apt/sources.list.d/debian.list/DEBIAN_WHEEZY
etc/grml/fai/config/files/etc/apt/sources.list.d/grml-stable.list/GRMLBASE
etc/grml/fai/config/files/etc/apt/sources.list.d/grml-testing.list/GRMLBASE
etc/grml/fai/config/scripts/GRMLBASE/03-get-sources [new file with mode: 0755]
grml-live

index 966f8ac..02b3265 100644 (file)
@@ -358,6 +358,9 @@ official grml release
 * REMOVE_DOCS: get rid of documentation directories (like /usr/share/doc,
 /usr/share/man/, /usr/share/info,...)
 
+* SOURCES: retrieve Debian source packages after installation. Files will be
+placed in the output directory under grml_sources.
+
 * XORG: providing important packages for use with a base grml-featured X.org
 setup
 
index 06ce943..1ece67b 100644 (file)
@@ -1,6 +1,6 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ etch main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ etch main contrib non-free
+  deb-src http://cdn.debian.net/debian/ etch main contrib non-free
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ etch main contrib non-free
index 08a2a79..b6ced67 100644 (file)
@@ -1,10 +1,10 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ lenny main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ lenny main contrib non-free
+  deb-src http://cdn.debian.net/debian/ lenny main contrib non-free
 
 # security updates:
   deb     http://security.debian.org/ lenny/updates main contrib
-#  deb-src http://security.debian.org/ lenny/updates main contrib
+  deb-src http://security.debian.org/ lenny/updates main contrib
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ lenny main contrib non-free
index cfef9b3..332a6e7 100644 (file)
@@ -1,6 +1,6 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ sid main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ sid main contrib non-free
+  deb-src http://cdn.debian.net/debian/ sid main contrib non-free
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ sid main contrib non-free
index 47615c9..88e6d57 100644 (file)
@@ -1,10 +1,10 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ squeeze main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ squeeze main contrib non-free
+  deb-src http://cdn.debian.net/debian/ squeeze main contrib non-free
 
 # security updates:
   deb     http://security.debian.org/ squeeze/updates main contrib
-#  deb-src http://security.debian.org/ squeeze/updates main contrib
+  deb-src http://security.debian.org/ squeeze/updates main contrib
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ squeeze main contrib non-free
index 0537b6f..f3c816c 100644 (file)
@@ -1,10 +1,10 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ stable main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ stable main contrib non-free
+  deb-src http://cdn.debian.net/debian/ stable main contrib non-free
 
 # security updates:
   deb     http://security.debian.org/ stable/updates main contrib
-#  deb-src http://security.debian.org/ stable/updates main contrib
+  deb-src http://security.debian.org/ stable/updates main contrib
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ stable main contrib non-free
index 84ee17a..33dc13e 100644 (file)
@@ -1,10 +1,10 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ testing main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ testing main contrib non-free
+  deb-src http://cdn.debian.net/debian/ testing main contrib non-free
 
 # security updates:
   deb     http://security.debian.org/ testing/updates main contrib
-#  deb-src http://security.debian.org/ testing/updates main contrib
+  deb-src http://security.debian.org/ testing/updates main contrib
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ testing main contrib non-free
index ca044c4..d850455 100644 (file)
@@ -1,10 +1,10 @@
 # official debian repository (mirror selected via geo-ip):
   deb     http://cdn.debian.net/debian/ wheezy main contrib non-free
-#  deb-src http://cdn.debian.net/debian/ wheezy main contrib non-free
+  deb-src http://cdn.debian.net/debian/ wheezy main contrib non-free
 
 # security updates:
   deb     http://security.debian.org/ wheezy/updates main contrib
-#  deb-src http://security.debian.org/ wheezy/updates main contrib
+  deb-src http://security.debian.org/ wheezy/updates main contrib
 
 # official debian repository:
 #  deb     http://ftp.debian.org/debian/ wheezy main contrib non-free
index 63b4222..b30b65b 100644 (file)
@@ -1,3 +1,3 @@
 # stable Grml repository:
   deb     http://deb.grml.org/ grml-stable  main
-#  deb-src http://deb.grml.org/ grml-stable  main
+  deb-src http://deb.grml.org/ grml-stable  main
index 860d528..dad1c90 100644 (file)
@@ -1,3 +1,3 @@
 # testing/developer Grml repository:
   deb     http://deb.grml.org/ grml-testing main
-#  deb-src http://deb.grml.org/ grml-testing main
+  deb-src http://deb.grml.org/ grml-testing main
diff --git a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources
new file mode 100755 (executable)
index 0000000..140faf1
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/03-get-sources
+# Purpose:       download sources of Debian packages
+# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
+# Bug-Reports:   see http://grml.org/bugs/
+# License:       This file is licensed under the GPL v2 or any later version.
+################################################################################
+
+[ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
+[ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
+
+if ifclass SOURCES ; then
+  echo "Class SOURCES set, retrieving source packages."
+else
+  echo "Class SOURCES not set, nothing to do."
+  exit 0
+fi
+
+set -u
+
+PACKAGE_LIST=$(mktemp)
+
+bailout() {
+  rm -f "${target}/grml-live/sources/errors.log"
+  rm -f "$PACKAGE_LIST"
+}
+
+$ROOTCMD dpkg-query -W -f='${Package}\n' > "${PACKAGE_LIST}"
+
+if ! [ -r "${PACKAGE_LIST}" ] ; then
+  echo "Can not read ${PACKAGE_LIST}, can not download source packages as requested." >&2
+  bailout
+  exit 1
+else
+  mkdir -p "${target}"/grml-live/sources
+
+  # needs to be done for each package to get:
+  # | Picking 'acpi-support' as source package instead of 'acpi-fakekey'
+  # instead of:
+  # | E: Unable to find a source package for acpi-fakekey
+  for package in $(grep -v '^#' ${PACKAGE_LIST}) ; do
+    cat << EOT | chroot "$target" /bin/bash
+cd /grml-live/sources
+apt-get --download-only source "$package" 2>>/grml-live/sources/errors.log
+EOT
+  done
+
+  if grep -q . "${target}/grml-live/sources/errors.log" ; then
+    echo "Errors noticed while retrieving sources:" >&2
+    cat "${target}/grml-live/sources/errors.log" >&2
+    bailout
+    exit 1
+  fi
+
+fi
+
+bailout
+
+## END OF FILE #################################################################
+# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
index 362f88c..04b30bb 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -149,6 +149,7 @@ umount_all() {
    umount $CHROOT_OUTPUT/sys  2>/dev/null || /bin/true
    umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
    umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
+   umount "${CHROOT_OUTPUT}/grml-live/sources/" 2>/dev/null || /bin/true
    [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
 }
 # }}}
@@ -538,9 +539,14 @@ $GRML_LIVE_SOURCES" | \
 else
   cat >> "$SOURCES_LIST_OUTPUT" << EOF
 # generated by grml-live
-deb http://deb.grml.org/            grml-stable  main
-deb http://deb.grml.org/            grml-testing main
-deb http://cdn.debian.net/debian $SUITE  main contrib non-free
+deb     http://deb.grml.org/            grml-stable  main
+deb-src http://deb.grml.org/            grml-stable  main
+
+deb     http://deb.grml.org/            grml-testing main
+deb-src http://deb.grml.org/            grml-testing main
+
+deb     http://cdn.debian.net/debian $SUITE  main contrib non-free
+deb-src http://cdn.debian.net/debian $SUITE  main contrib non-free
 EOF
 fi
 
@@ -626,6 +632,9 @@ else
          mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
       fi
 
+      mkdir -p "${OUTPUT}/grml_sources/" "${CHROOT_OUTPUT}/grml-live/sources/"
+      mount --bind "${OUTPUT}/grml_sources/" "${CHROOT_OUTPUT}/grml-live/sources/"
+
       # tell dpkg to use "unsafe io" during the build
       [ -d "$CHROOT_OUTPUT/etc/dpkg/dpkg.cfg.d" ] || mkdir -p "$CHROOT_OUTPUT/etc/dpkg/dpkg.cfg.d"
       echo force-unsafe-io > "$CHROOT_OUTPUT/etc/dpkg/dpkg.cfg.d/unsafe-io"