[debian-lan-devel] [SCM] Debian-LAN development and packaging branch, master, updated. 0.5-12-g569e78e

Andreas B. Mundt andi.mundt at web.de
Fri Apr 13 08:58:09 UTC 2012


The following commit has been merged in the master branch:
commit 569e78e64cf144698d58f4687096898e38a95a0c
Author: Andreas B. Mundt <andi.mundt at web.de>
Date:   Thu Apr 12 19:53:55 2012 +0200

    Add local APT repository for customized site-specific packages.
    
    This commit integrates a signed local APT repository ready to serve
    the Debian LAN.  Packages just need to be copied into the repository.
    The release file is created and signed by a supplied script.  Clients
    fetch the public key on softupdate and automatically add the
    repository to their sources.list after that.

diff --git a/fai/config/class/CLIENT_A.var b/fai/config/class/CLIENT_A.var
index 5e36bec..7a5d399 100644
--- a/fai/config/class/CLIENT_A.var
+++ b/fai/config/class/CLIENT_A.var
@@ -14,6 +14,10 @@ TIMEZONE=Europe/Berlin
 # pw is "fai":
 ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
 
+## URL of the local site's APT repository.
+## Set empty to skip this feature.
+APT_URL="http://mainserver/debian/"
+
 # MODULESLIST contains modules that will be loaded by the new system,
 # not during installation these modules will be written to /etc/modules
 # If you need a module during installation, add it to $kernelmodules
diff --git a/fai/config/class/SERVER_A.var b/fai/config/class/SERVER_A.var
index 01c5407..9049dc9 100644
--- a/fai/config/class/SERVER_A.var
+++ b/fai/config/class/SERVER_A.var
@@ -54,6 +54,10 @@ RANGE="10.0.1.10 10.0.1.200"
 WS_RANGE="50 149"
 DL_RANGE="150 249"
 
+## Local APT repository for the site (accessible via http).
+## Set empty to skip this feature.
+APT_REPO_DIR="/var/www/debian"
+
 # MODULESLIST contains modules that will be loaded by the new system,
 # not during installation these modules will be written to /etc/modules
 # If you need a module during installation, add it to $kernelmodules
diff --git a/fai/config/files/etc/apt/sources.list/SERVER_A b/fai/config/files/etc/apt/sources.list/SERVER_A
index 042ce2f..583d5c8 100644
--- a/fai/config/files/etc/apt/sources.list/SERVER_A
+++ b/fai/config/files/etc/apt/sources.list/SERVER_A
@@ -1,3 +1,6 @@
 deb http://mainserver:3142/cdn.debian.net/debian/ squeeze main
 deb http://mainserver:3142/security.debian.org/ stable/updates main
 deb http://mainserver:3142/ftp.debian.org/debian/ squeeze-updates main
+
+## Backports repository:
+#deb http://backports.debian.org/debian-backports squeeze-backports main
diff --git a/fai/config/files/etc/fai/apt/sources.list/SERVER_A b/fai/config/files/etc/fai/apt/sources.list/SERVER_A
index 042ce2f..583d5c8 100644
--- a/fai/config/files/etc/fai/apt/sources.list/SERVER_A
+++ b/fai/config/files/etc/fai/apt/sources.list/SERVER_A
@@ -1,3 +1,6 @@
 deb http://mainserver:3142/cdn.debian.net/debian/ squeeze main
 deb http://mainserver:3142/security.debian.org/ stable/updates main
 deb http://mainserver:3142/ftp.debian.org/debian/ squeeze-updates main
+
+## Backports repository:
+#deb http://backports.debian.org/debian-backports squeeze-backports main
diff --git a/fai/config/scripts/CLIENT_A/30-APTrepository b/fai/config/scripts/CLIENT_A/30-APTrepository
new file mode 100755
index 0000000..50b283f
--- /dev/null
+++ b/fai/config/scripts/CLIENT_A/30-APTrepository
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Fetch public key for the local site's APT repository.
+#
+
+set -e
+
+if [ -z $APT_URL ] ; then
+    exit 0
+fi
+
+echo "Check if public key is available:"
+if $ROOTCMD wget -O /tmp/DebianLAN.pubkey $APT_URL/DebianLAN.pubkey ; then
+    echo -n "Run apt-key and add key: "
+    $ROOTCMD apt-key add /tmp/DebianLAN.pubkey
+    ## Key is available, add repository to sources.list:
+    $ROOTCMD ainsl $target/etc/apt/sources.list "## Local APT repository for site-specific packages:"
+    $ROOTCMD ainsl $target/etc/apt/sources.list "deb $APT_URL stable main"
+else
+    echo "No key available."
+fi
diff --git a/fai/config/scripts/SERVER_A/60-APTrepository b/fai/config/scripts/SERVER_A/60-APTrepository
new file mode 100755
index 0000000..ed6d797
--- /dev/null
+++ b/fai/config/scripts/SERVER_A/60-APTrepository
@@ -0,0 +1,116 @@
+#!/bin/bash
+#
+# Prepare anything needed to set up a local APT repository.
+# cf. <URL:http://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_small_public_package_archive>
+#
+
+set -e
+
+if [ -z $APT_REPO_DIR ] ; then
+    exit 0
+fi
+
+mkdir -p $target$APT_REPO_DIR/pool/main
+mkdir -p $target$APT_REPO_DIR/dists/stable/main/binary-i386
+mkdir -p $target$APT_REPO_DIR/dists/stable/main/binary-amd64
+mkdir -p $target$APT_REPO_DIR/dists/stable/main/source
+
+cat > $target$APT_REPO_DIR/dists/stable/main/binary-i386/Release << EOF
+Archive: stable
+Version: 6.0
+Component: main
+Origin: DebianLAN
+Label: DebianLAN
+Architecture: i386
+EOF
+
+sed "s/i386/amd64/" $target$APT_REPO_DIR/dists/stable/main/binary-i386/Release > \
+    $target$APT_REPO_DIR/dists/stable/main/binary-amd64/Release
+
+sed "s/i386/source/" $target$APT_REPO_DIR/dists/stable/main/binary-i386/Release > \
+    $target$APT_REPO_DIR/dists/stable/main/source/Release
+
+cat > $target$APT_REPO_DIR/aptftp.conf <<EOF
+APT::FTPArchive::Release {
+  Origin "DebianLAN";
+  Label "DebianLAN";
+  Suite "stable";
+  Architectures "i386 amd64 source";
+  Components "main";
+  Description "DebianLAN site specific packages";
+};
+EOF
+
+cat > $target$APT_REPO_DIR/aptgenerate.conf <<EOF
+Dir::ArchiveDir ".";
+Dir::CacheDir ".";
+TreeDefault::Directory "pool/";
+TreeDefault::SrcDirectory "pool/";
+Default::Packages::Extensions ".deb";
+Default::Packages::Compress ". gzip";
+Default::Sources::Compress "gzip";
+Default::Contents::Compress "gzip";
+
+BinDirectory "dists/stable/main/binary-amd64" {
+  Packages "dists/stable/main/binary-amd64/Packages";
+  Contents "dists/stable/Contents-amd64";
+  SrcPackages "dists/stable/main/source/Sources";
+};
+
+BinDirectory "dists/stable/main/binary-i386" {
+  Packages "dists/stable/main/binary-i386/Packages";
+  Contents "dists/stable/Contents-i386";
+  SrcPackages "dists/stable/main/source/Sources";
+};
+
+Tree "dists/stable" {
+  Sections "main";
+  Architectures "i386 amd64 source";
+};
+EOF
+
+cat > $target$DATADIR/GPGkey.conf <<EOF
+%echo Generating a key for APT signing ...
+Key-Type: DSA
+Key-Length: 1024
+Key-Usage: sign
+Name-Real: DebianLAN
+Name-Comment: ARCHIVE KEY
+Name-Email: root at mainserver.intern
+Expire-Date: 0
+%commit
+%echo done
+EOF
+
+cat > $target$APT_REPO_DIR/create_archive.sh <<EOF
+#!/bin/bash
+#
+#   HowTo set up a local package repository
+#   ---------------------------------------
+#
+#    * Drop all customized and needed packages into './pool/main/'.
+#
+#    * Execute this script or run the commands below manually.
+#
+
+set -e
+
+## Prepare GPG key:
+
+if [ ! -d /root/.gnupg/ ] ; then
+    gpg --batch --gen-key $DATADIR/GPGkey.conf
+    gpg --export --armor > DebianLAN.pubkey
+elif [ ! -e DebianLAN.pubkey ] ; then
+    gpg --export --armor > DebianLAN.pubkey
+fi
+
+## Create archive:
+
+apt-ftparchive generate -c=aptftp.conf aptgenerate.conf
+apt-ftparchive release  -c=aptftp.conf dists/stable > dists/stable/Release
+
+rm -f dists/stable/Release.gpg
+gpg -u DebianLAN -b -o dists/stable/Release.gpg dists/stable/Release
+EOF
+
+chmod 0700 $target$APT_REPO_DIR/create_archive.sh

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list