Skip to content

Commit

Permalink
add apt_cdn for template expansion for sources.list
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Sep 6, 2017
1 parent 277b017 commit 85eb564
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions examples/simple/class/DEBIAN.var
Expand Up @@ -13,3 +13,5 @@ MODULESLIST="usbhid psmouse"

# if you want to use the faiserver as APT proxy
#APTPROXY=http://faiserver:3142

apt_cdn=http://deb.debian.org
6 changes: 3 additions & 3 deletions examples/simple/files/etc/apt/sources.list/GCE
@@ -1,6 +1,6 @@
deb http://deb.debian.org/debian {release} main contrib non-free
deb http://deb.debian.org/debian {release}-backports main
deb http://deb.debian.org/debian-security {release}/updates main contrib non-free
deb {apt_cdn}/debian {release} main contrib non-free
deb {apt_cdn}/debian {release}-backports main
deb {apt_cdn}/debian-security {release}/updates main contrib non-free

deb http://packages.cloud.google.com/apt cloud-sdk-{release} main
deb http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-{release} main
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/files/etc/apt/sources.list/GNOME
@@ -1,2 +1,2 @@
deb http://deb.debian.org/debian stretch main contrib non-free
deb http://deb.debian.org/debian-security stretch/updates main contrib non-free
deb {apt_cdn}/debian stretch main contrib non-free
deb {apt_cdn}/debian-security stretch/updates main contrib non-free
12 changes: 9 additions & 3 deletions examples/simple/files/etc/apt/sources.list/preinst
@@ -1,7 +1,7 @@
#! /bin/bash

# replace {release} in a sources.list template with the value of $release

# replace {apt_cdn} with the value of $apt_cdn

# $1 is the class name used
# $2 is the path to the file copied
Expand All @@ -11,7 +11,13 @@ grep -q '{' $2 || exit 0

if [ -z "$release" ]; then
echo "\$release is undefined. No substitution performed in $2."
exit 0
else
sed -i -e "s/{release}/$release/g" $2
fi

if [ -z "$apt_cdn" ]; then
echo "\$apt_cdn not defined. not substituting in $2."
else
sed -i -e "s#{apt_cdn}#$apt_cdn#g" $2
fi

sed -i -e "s/{release}/$release/g" $2

0 comments on commit 85eb564

Please sign in to comment.