[lxc-devel] [distrobuilder/master] Add Linux Mint example
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Wed May 9 12:13:00 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 309 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180509/21d9d057/attachment.bin>
-------------- next part --------------
From 5ad5059cbcfa2a85f4fb66d3e9f99107cc37a26c Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomashipp at gmail.com>
Date: Wed, 9 May 2018 12:29:44 +0200
Subject: [PATCH 1/2] debootstrap: Add option to ignore image.release
Signed-off-by: Thomas Hipp <thomashipp at gmail.com>
---
shared/definition.go | 15 ++++++++-------
sources/debootstrap.go | 14 +++++++++++++-
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/shared/definition.go b/shared/definition.go
index d3fd8d6..78b33ec 100644
--- a/shared/definition.go
+++ b/shared/definition.go
@@ -42,13 +42,14 @@ type DefinitionImage struct {
// A DefinitionSource specifies the download type and location
type DefinitionSource struct {
- Downloader string `yaml:"downloader"`
- URL string `yaml:"url,omitempty"`
- Keys []string `yaml:"keys,omitempty"`
- Keyserver string `yaml:"keyserver,omitempty"`
- Variant string `yaml:"variant,omitempty"`
- Suite string `yaml:"suite,omitempty"`
- AptSources string `yaml:"apt_sources,omitempty"`
+ Downloader string `yaml:"downloader"`
+ URL string `yaml:"url,omitempty"`
+ Keys []string `yaml:"keys,omitempty"`
+ Keyserver string `yaml:"keyserver,omitempty"`
+ Variant string `yaml:"variant,omitempty"`
+ Suite string `yaml:"suite,omitempty"`
+ AptSources string `yaml:"apt_sources,omitempty"`
+ IgnoreRelease bool `yaml:"ignore_release,omitempty"`
}
// A DefinitionTargetLXCConfig represents the config part of the metadata.
diff --git a/sources/debootstrap.go b/sources/debootstrap.go
index f7fbb14..a636193 100644
--- a/sources/debootstrap.go
+++ b/sources/debootstrap.go
@@ -41,7 +41,19 @@ func (s *Debootstrap) Run(definition shared.Definition, rootfsDir string) error
args = append(args, "--keyring", keyring)
}
- args = append(args, definition.Image.Release, rootfsDir)
+ // If source.ignore_release is set, debootstrap will not use image.release
+ // but source.suite as the release. This is important for derivatives which
+ // don't have own sources, e.g. Linux Mint.
+ if definition.Source.IgnoreRelease {
+ // If source.suite is set, use it when calling debootstrap
+ if definition.Source.Suite != "" {
+ args = append(args, definition.Source.Suite, rootfsDir)
+ } else {
+ args = append(args, definition.Image.Release, rootfsDir)
+ }
+ } else {
+ args = append(args, definition.Image.Release, rootfsDir)
+ }
if definition.Source.URL != "" {
args = append(args, definition.Source.URL)
From 3b512eea398ad2ea3f5adfaebed975a690b1d1a1 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomashipp at gmail.com>
Date: Wed, 9 May 2018 14:08:02 +0200
Subject: [PATCH 2/2] doc: Add example for Linux Mint
Signed-off-by: Thomas Hipp <thomashipp at gmail.com>
---
doc/examples/mint | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 168 insertions(+)
create mode 100644 doc/examples/mint
diff --git a/doc/examples/mint b/doc/examples/mint
new file mode 100644
index 0000000..d52f6e8
--- /dev/null
+++ b/doc/examples/mint
@@ -0,0 +1,168 @@
+image:
+ distribution: Mint
+ release: sylvia
+ description: Mint {{ image.release }}
+ architecture: amd64
+
+source:
+ downloader: debootstrap
+ url: http://us.archive.ubuntu.com/ubuntu
+ keys:
+ - 0x790BC7277767219C42C86F933B4FE6ACC0B21F32
+ keyserver: keyserver.ubuntu.com
+ suite: xenial
+ ignore_release: true
+
+ apt_sources: |-
+ deb http://packages.linuxmint.com {{ image.release }} main upstream import backport
+ deb {{ source.url }} {{ source.suite }} main restricted universe multiverse
+ deb {{ source.url }} {{ source.suite }}-updates main restricted universe multiverse
+ deb http://security.ubuntu.com/ubuntu {{ source.suite }}-security main restricted universe multiverse
+
+targets:
+ lxc:
+ create-message: |
+ You just created an {{ image.description }} container.
+
+ To enable SSH, run: apt install openssh-server
+ No default root or user password are set by LXC.
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+ - path: /etc/resolvconf/resolv.conf.d/original
+ generator: remove
+
+ - path: /etc/resolvconf/resolv.conf.d/tail
+ generator: remove
+
+ - path: /etc/machine-id
+ generator: remove
+
+ - path: /etc/netplan/10-lxc.yaml
+ generator: dump
+ content: |-
+ network:
+ ethernets:
+ eth0: {dhcp4: true}
+ version: 2
+ releases:
+ - artful
+ - bionic
+
+ - path: /etc/network/interfaces
+ generator: dump
+ content: |-
+ # This file describes the network interfaces available on your system
+ # and how to activate them. For more information, see interfaces(5).
+
+ # The loopback network interface
+ auto lo
+ iface lo inet loopback
+
+ auto eth0
+ iface eth0 inet dhcp
+ releases:
+ - trusty
+ - xenial
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
+
+packages:
+ manager: apt
+
+ # Do not update here. Updates will take place in the post-unpack action.
+ update: false
+ install:
+ - apt-transport-https
+ - language-pack-en
+ - openssh-client
+ - vim
+
+actions:
+ - trigger: post-unpack
+ action: |-
+ #!/bin/sh
+ set -eux
+
+ apt-key adv --keyserver keyserver.ubuntu.com --recv 0xA6616109451BBBF2
+ apt-get update
+ apt-get install -y --allow-unauthenticated linuxmint-keyring
+ apt-get dist-upgrade -y --allow-unauthenticated || true
+ apt-get -f install -y
+ apt-get dist-upgrade -y --allow-unauthenticated
+
+ - trigger: post-update
+ action: |-
+ #!/bin/sh
+ set -eux
+
+ # Create the ubuntu user account
+ getent group sudo >/dev/null 2>&1 || groupadd --system sudo
+ useradd --create-home -s /bin/bash -G sudo -U ubuntu
+
+ - trigger: post-packages
+ action: |-
+ #!/bin/sh
+ set -eux
+
+ # Make sure the locale is built and functional
+ locale-gen en_US.UTF-8
+ update-locale LANG=en_US.UTF-8
+
+ # Cleanup underlying /run
+ mount -o bind / /mnt
+ rm -rf /mnt/run/*
+ umount /mnt
+
+ # Cleanup temporary shadow paths
+ rm /etc/*-
+
+mappings:
+ architecture_map: debian
More information about the lxc-devel
mailing list