From e75b256a3964c51a70c89f7d1c312e56a945cd2a Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Sun, 21 Feb 2021 15:51:59 +0000 Subject: [PATCH] Initial Commit --- Jenkinsfile | 89 ++++++++++++++++++++++++++++++++ debian.yaml | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 Jenkinsfile create mode 100644 debian.yaml diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b0a8cb9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,89 @@ +pipeline { + agent { label 'LXCBuilder' } + parameters { + booleanParam defaultValue: true, description: 'Builds Default images', name: 'BuildDefault' + booleanParam defaultValue: false, description: 'Builds Extra images', name: 'BuildExtra' + } + options { + skipDefaultCheckout() + buildDiscarder(logRotator(numToKeepStr: '2', artifactNumToKeepStr: '1')) + } + stages { + stage('Prepare') { + steps { + // Cleanup before starting + cleanWs() + // Checkout the repository + checkout scm + // Get distrobuilder + copyArtifacts filter: 'bin/distrobuilder', fingerprintArtifacts: true, flatten: true, projectName: '/Public/DistroBuilder/BuildConfig=BrampCustom', selector: lastSuccessful() + // Setup Env + sh '''mkdir $WORKSPACE/REL''' + } + } + stage("Image Configs") { + matrix { + axes { + axis { + name 'ImgRelease' + values 'buster' + } + axis { + name 'ImgVariant' + values 'Default-minmal', 'Default-default' + } + } + // //Exclude unwanted conbinatinations + // excludes { + // exclude { + // axis { + // name 'ImgRelease' + // values 'edge' + // } + // axis { + // name 'ImgVariant' + // //use notValues to invert + // values 'Extra-extended' + // } + // } + // } + stages { + stage('Build image') { + when { + //ImgTypeTest + anyOf { + allOf { + expression { return (env.ImgVariant).startsWith('Default-') } + environment name: 'BuildDefault', value: 'true' + } + allOf { + expression { return (env.ImgVariant).startsWith('Extra-') } + environment name: 'BuildExtra', value: 'true' + } + } + } + steps { + // Build script + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh '''echo "$(date) Do Build for $ImgRelease - $ImgVariant" + ImgVariantName=${ImgVariant#Default-} && ImgVariantName=${ImgVariantName#Extra-} + sudo $WORKSPACE/distrobuilder build-lxc Debian.yaml $WORKSPACE/REL/$ImgRelease-$ImgVariant/ -o image.release=$ImgRelease -o image.variant=$ImgVariantName + sudo chown jenkins:jenkins -R $WORKSPACE/REL + mv $WORKSPACE/REL/$ImgRelease-$ImgVariant/rootfs.tar.xz Debian-$ImgRelease-$ImgVariant.tar.xz + ''' + } + } + } + } + } + } + stage('Finish') { + steps { + // Save generated files + archiveArtifacts artifacts: '*.tar.xz', followSymlinks: false + // Cleaning WorkSpace + //cleanWs() + } + } + } +} \ No newline at end of file diff --git a/debian.yaml b/debian.yaml new file mode 100644 index 0000000..942125d --- /dev/null +++ b/debian.yaml @@ -0,0 +1,143 @@ +image: + distribution: "debian" + +source: + downloader: debootstrap + url: http://192.168.2.83/deb.debian.org/debian + keys: + - 0x126C0D24BD8A2942CC7DF8AC7638D0442B90D010 + - 0xA1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553 + - 0x6D33866EDD8FFA41C0143AEDDCC9EFBF77E11517 + - 0x80D15823B7FD1561F9F7BCDDDC30D7C23CBBABEE + variant: minbase + +targets: + lxc: + create-message: |- + You just created a {{ 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/debian.common.conf + + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/debian.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_personality }} + +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: dump + +- path: /var/lib/dbus/machine-id + generator: remove + +- 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 + + source /etc/network/interfaces.d/* + types: + - container + +packages: + manager: apt + update: true + cleanup: true + sets: + - packages: + - dialog + - ifupdown + - init + - iproute2 + - iputils-ping + - isc-dhcp-client + - locales + - netbase + - net-tools + - openssh-client + - procps + action: install + - packages: + - nano + action: install + variants: + - default + + repositories: + - name: sources.list + url: |- + deb http://deb.debian.org/debian {{ image.release }} main + {% if image.release != "sid" and image.release != "bullseye" and not (image.release == "wheezy" and image.architecture_mapped == "powerpc") and not (image.release == "wheezy" and image.architecture_mapped == "s390x") %}deb http://security.debian.org/debian-security {{ image.release }}/updates main{% endif %} + +actions: +- trigger: post-unpack + action: |- + #!/bin/sh + echo 'Acquire::http::Proxy "http://192.168.2.83:80";' > /etc/apt/apt.conf.d/01prox + echo '#Acquire::http::Proxy "http://192.168.200.60:80";' >> /etc/apt/apt.conf.d/01prox + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + + # Disable networkd (unused) + systemctl mask systemd-networkd.service + systemctl mask systemd-networkd.socket + systemctl mask systemd-networkd-wait-online.service + + # Make sure the locale is built and functional + echo en_US.UTF-8 UTF-8 >> /etc/locale.gen + locale-gen en_US.UTF-8 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