-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ add debian11, debian12, alpines
- Loading branch information
Showing
24 changed files
with
652 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
build/ | ||
context-windows/out/ | ||
context-windows/*.msi | ||
context-windows/rhsrvany.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# load targets config | ||
-include Makefile.distros | ||
|
||
# load variables and makefile config | ||
-include Makefile.config | ||
|
||
#------------------------------------------------------------------------------ | ||
# All, alliases | ||
#------------------------------------------------------------------------------ | ||
all: $(patsubst %, all-%, $(DISTROS)) | ||
@: | ||
|
||
# allow individual distribution targets (e.g., "make debian11") | ||
$(DISTROS): %: all-% ; | ||
|
||
# pattern rule for dependencies | ||
all-%: download-% installer-% customize-% | ||
@${INFO} "All done for ${*}" | ||
|
||
#------------------------------------------------------------------------------ | ||
# Download | ||
# - download to build/01_base/$DISTRO | ||
# - no file suffix, could be iso, qcow2 whatever | ||
# - TODO: add chesksum verfication somehow | ||
#------------------------------------------------------------------------------ | ||
download: $(patsubst %, download-%, $(DISTROS)) | ||
|
||
download-%: ${DIR_BASE}/%.img | ||
@${INFO} "Download ${*} done" | ||
|
||
${DIR_BASE}/%.img: validate-% | ||
@${INFO} "Starting $* download" | ||
curl -sS -L -f -o "$@" "${URL_${*}}" | ||
|
||
#------------------------------------------------------------------------------ | ||
# Install (optional) | ||
# - run distro installer if cloud/virt image is not available | ||
# - execute packer/$DISTRO/run.sh which runs packet | ||
# - or packer/skip.sh to only create target symlink to base image | ||
#------------------------------------------------------------------------------ | ||
installer: $(patsubst %, installer-%, $(DISTROS)) | ||
|
||
installer-%: ${DIR_INSTALL}/%.qcow2 | ||
@${INFO} "Installer ${*} done" | ||
|
||
${DIR_INSTALL}/%.qcow2: ${DIR_BASE}/%.img | ||
@${INFO} "Starting ${*} installer" | ||
@if [ -f "packer/${*}/run.sh" ]; then \ | ||
packer/${*}/run.sh ${*} ${@}; \ | ||
else \ | ||
packer/skip.sh ${*}; \ | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
# Customize | ||
# - execute customize/$DISTRO/run.sh which: | ||
# - run guestfish customzation scripts | ||
# - TODO: sysprep | ||
# - TODO: sparsify | ||
# - export final image | ||
#------------------------------------------------------------------------------ | ||
customize: $(patsubst %, customize-%, $(DISTROS)) | ||
|
||
customize-%: context-linux ${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2 | ||
@${INFO} "Customize $* done" | ||
|
||
${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2: ${DIR_INSTALL}/%.qcow2 | ||
@${INFO} "Starting $* customization" | ||
@guestfish/run.sh ${*} ${@} | ||
|
||
#------------------------------------------------------------------------------ | ||
# clean | ||
#------------------------------------------------------------------------------ | ||
clean: | ||
-rm -rf ${DIR_BASE}/* | ||
-rm -rf ${DIR_INSTALL}/* | ||
-rm -rf ${DIR_EXPORT}/* | ||
|
||
#------------------------------------------------------------------------------ | ||
# context-linux | ||
#------------------------------------------------------------------------------ | ||
context-linux: $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES)) | ||
@${INFO} "Generate context-linux done" | ||
|
||
context-linux/out/%: | ||
cd context-linux; ./generate-all.sh | ||
|
||
#------------------------------------------------------------------------------ | ||
# validate before download | ||
#------------------------------------------------------------------------------ | ||
validate-%: | ||
@if [[ ! "$(DISTROS)" == *"${*}"* ]]; then \ | ||
echo "[ERROR] Unknown distro ${*}"; \ | ||
exit 1; \ | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
# help | ||
#------------------------------------------------------------------------------ | ||
help: | ||
@echo 'Available distros:' | ||
@echo ' $(DISTROS)' | ||
@echo | ||
@echo 'Usage examples:' | ||
@echo ' make -- build all distros' | ||
@echo ' make download -- download all base images' | ||
@echo ' make installer -- run installer (unnecessary for some)' | ||
@echo ' make customize -- run customization (install context etc)' | ||
@echo | ||
@echo ' make <distro> -- build just one distro' | ||
@echo ' make download-<distro> -- download just one' | ||
@echo ' make installer-<distro> -- download just one' | ||
@echo ' make customize-<distro> -- download just one' | ||
@echo ' make context-linux -- build context linux packages' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# context version | ||
VERSION ?= 6.6.1 | ||
RELEASE ?= 1 | ||
|
||
# log | ||
VERBOSE ?= 1 | ||
PACKER_LOG ?= 1 | ||
LIBGUESTFS_DEBUG ?= 1 | ||
LIBGUESTFS_TRACE ?= 0 | ||
LIBGUESTFS_MEMSIZE ?= 3072 | ||
TTY ?= $(shell tty) | ||
|
||
# default directories | ||
DIR_BUILD ?= build | ||
DIR_BASE ?= $(DIR_BUILD)/01_base | ||
DIR_INSTALL ?= $(DIR_BUILD)/02_installer | ||
DIR_EXPORT ?= $(DIR_BUILD)/03_export | ||
DIR_PACKER ?= $(DIR_BUILD)/_packer | ||
|
||
# create them if not present | ||
$(shell \ | ||
mkdir -p ${DIR_BASE} \ | ||
mkdir -p ${DIR_INSTALL} \ | ||
mkdir -p ${DIR_EXPORT} \ | ||
) | ||
|
||
# # don't delete downloaded or installed images | ||
.SECONDARY: $(patsubst %, $(DIR_BASE)/%, $(DISTROS)) | ||
.SECONDARY: $(patsubst %, $(DIR_INSTALL)/%.qcow2, $(DISTROS)) | ||
|
||
.PHONY: context-linux download installer customize help | ||
|
||
# this needs to match context-linux/generate-all.sh products | ||
LINUX_CONTEXT_PACKAGES := one-context_${VERSION}-${RELEASE}.deb \ | ||
one-context-${VERSION}-${RELEASE}.el6.noarch.rpm \ | ||
one-context-${VERSION}-${RELEASE}.el7.noarch.rpm \ | ||
one-context-${VERSION}-${RELEASE}.el8.noarch.rpm \ | ||
one-context-${VERSION}-${RELEASE}.el9.noarch.rpm \ | ||
one-context-${VERSION}-${RELEASE}.suse.noarch.rpm \ | ||
one-context-${VERSION}_${RELEASE}.txz \ | ||
one-context-${VERSION}-alt${RELEASE}.noarch.rpm \ | ||
one-context-${VERSION}-r${RELEASE}.apk \ | ||
one-context-linux-${VERSION}-${RELEASE}.iso | ||
|
||
LINUX_CONTEXT_PACKAGES_FULL := $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES)) | ||
|
||
|
||
# discover some binaries | ||
QEMU_BINARY ?= $(shell \ | ||
for _qb in /usr/bin/qemu-system-x86_64 \ | ||
/usr/libexec/qemu-kvm \ | ||
/usr/bin/qemu-kvm; do \ | ||
\ | ||
if [ -e "$$_qb" ]; then \ | ||
echo $$_qb && exit; \ | ||
fi; \ | ||
done ) | ||
|
||
# logging func | ||
INFO=sh -c 'if [ $(VERBOSE) = 1 ]; then echo [INFO] $$1; fi' INFO | ||
|
||
# export all variables | ||
export | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DISTROS := alpine316 alpine317 debian11 debian12 | ||
|
||
# URLS | ||
URL_alpine316 ?= https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.7-x86_64.iso | ||
URL_alpine317 ?= https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-virt-3.17.5-x86_64.iso | ||
URL_debian11 ?= https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-amd64.qcow2 | ||
URL_debian11 ?= https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-amd64.qcow2 | ||
URL_debian12 ?= https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# one-apps | ||
Toolchain to build OpenNebula appliances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env sh | ||
|
||
# (Auto)Removes unneeded packages and upgrades | ||
# the distro. | ||
|
||
exec 1>&2 | ||
set -ex | ||
|
||
# Ensure packages needed for post-processing scripts do exist. | ||
apk --no-cache add bash curl gawk grep jq sed | ||
|
||
gawk -i inplace -f- /etc/apk/repositories <<'EOF' | ||
/community$/ && !/edge/ { gsub(/^#\s*/, "") } | ||
{ print } | ||
EOF | ||
|
||
apk update | ||
apk upgrade | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Updates various settings that require reboot. | ||
|
||
exec 1>&2 | ||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
gawk -i inplace -f- /etc/inittab <<'EOF' | ||
/^ttyS/ { $0 = "#" $0 } | ||
{ print } | ||
EOF | ||
|
||
gawk -i inplace -f- /boot/extlinux.conf <<'EOF' | ||
BEGIN { update = "TIMEOUT 3" } | ||
/^TIMEOUT\s/ { $0 = update; found = 1 } | ||
{ print } | ||
END { if (!found) print update >> FILENAME } | ||
EOF | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Downloads and installs the latest one-context package. | ||
|
||
exec 1>&2 | ||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
: "${CTX_SUFFIX:=.apk}" | ||
|
||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
if ! stat /context/one-context*$CTX_SUFFIX; then ( | ||
install -d /context/ && cd /context/ | ||
curl -fsSL https://api.github.com/repos/OpenNebula/addon-context-linux/releases \ | ||
| jq -r ".[0].assets[].browser_download_url | select(endswith(\"$CTX_SUFFIX\"))" \ | ||
| xargs -r -n1 curl -fsSLO | ||
) fi | ||
|
||
apk --no-cache add tzdata haveged open-vm-tools-plugins-all | ||
apk --no-cache add --allow-untrusted /context/one-context*$CTX_SUFFIX | ||
|
||
rc-update add qemu-guest-agent default | ||
rc-update add open-vm-tools default | ||
rc-update add haveged boot | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Configures critical settings for OpenSSH server. | ||
|
||
exec 1>&2 | ||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
gawk -i inplace -f- /etc/ssh/sshd_config <<'EOF' | ||
BEGIN { update = "PasswordAuthentication no" } | ||
/^[#\s]*PasswordAuthentication\s*/ { $0 = update; found = 1 } | ||
{ print } | ||
END { if (!found) print update >> FILENAME } | ||
EOF | ||
|
||
gawk -i inplace -f- /etc/ssh/sshd_config <<'EOF' | ||
BEGIN { update = "PermitRootLogin without-password" } | ||
/^[#\s]*PermitRootLogin\s*/ { $0 = update; found = 1 } | ||
{ print } | ||
END { if (!found) print update >> FILENAME } | ||
EOF | ||
|
||
gawk -i inplace -f- /etc/ssh/sshd_config <<'EOF' | ||
BEGIN { update = "UseDNS no" } | ||
/^[#\s]*UseDNS\s*/ { $0 = update; found = 1 } | ||
{ print } | ||
END { if (!found) print update >> FILENAME } | ||
EOF | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Cleans APK caches, removes temporary files / logs, | ||
# removes leftover / temporary unneeded packages. | ||
|
||
exec 1>&2 | ||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
rm -f /etc/motd | ||
|
||
rm -rf /var/cache/apk/* | ||
rm -rf /context/ | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
# | ||
echo 111 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# (Auto)Removes unneeded packages and upgrades | ||
# the distro. | ||
|
||
policy_rc_d_disable() (echo "exit 101" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d) | ||
policy_rc_d_enable() (echo "exit 0" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d) | ||
|
||
exec 1>&2 | ||
set -o errexit -o nounset -o pipefail | ||
set -x | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt-get update -y | ||
|
||
policy_rc_d_disable | ||
|
||
apt-get install -y --fix-broken | ||
|
||
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" | ||
|
||
# Ensure packages needed for post-processing scripts do exist. | ||
apt-get install -y curl gawk grep jq | ||
|
||
policy_rc_d_enable | ||
|
||
sync |
Oops, something went wrong.