Skip to content

Commit

Permalink
restructure directories, update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanis committed May 10, 2024
1 parent fbac4f3 commit a3ab7d5
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 322 deletions.
89 changes: 7 additions & 82 deletions cableos/Makefile
Original file line number Diff line number Diff line change
@@ -1,72 +1,3 @@
#!/usr/bin/make -f

include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
export PACKER_LOG

SERIES ?= bullseye
BOOT ?= uefi
ARCH ?= amd64
TIMEOUT ?= 1h

ifeq ($(strip $(SERIES)),buster)
VERSION = 10
else ifeq ($(strip $(SERIES)),bullseye)
VERSION = 11
else ifeq ($(strip $(SERIES)),bookworm)
VERSION = 12
else
VERSION = 11
endif

# Safeguard
ifeq ($(strip $(ARCH)),arm64)
boot = uefi
endif

.PHONY: all clean

all: cableos

$(eval $(call check_packages_deps,cloud-image-utils ovmf,cloud-image-utils ovmf))

lint:
packer validate .
packer fmt -check -diff .

format:
packer fmt .

OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS.fd
cp -v $< $@

debian: check-deps clean
${PACKER} init . && ${PACKER} build \
-var debian_series=${SERIES} \
-var debian_version=${VERSION} \
-var architecture=${ARCH} \
-var boot_mode=${BOOT} \
-var timeout=${TIMEOUT} .

clean:
${RM} -rf output-* debian-custom-*.gz \
seeds-cloudimg.iso \
OVMF_VARS.fd \
AAVMF_VARS.fd

CUSTOM_PKGS:=${wildcard packages/*.deb}

packages/custom-packages.tar.gz: ${CUSTOM_PKGS}
ifeq ($(strip $(CUSTOM_PKGS)),)
tar czf $@ -C packages -T /dev/null
else
tar czf $@ -C packages ${notdir $^}
endif

.INTERMEDIATE: OVMF_VARS.fd packages/custom-packages.tar.gz \
seeds-cloudimg.iso

include ../scripts/check.mk

Expand All @@ -83,22 +14,16 @@ export PACKER_LOG

.PHONY: all clean

all: cableos.tar.gz
all: cableos-installer.qcow2
$(eval $(call check_packages_deps))

deps: check-deps clean
${PACKER} init . deps.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} deps.pkr.hcl

debirf.tar.gz: check-deps clean
# ${PACKER} build template.json
${PACKER} init . cableos.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} cableos.pkr.hcl



cableos.tar.gz: check-deps clean
cableos-installer.qcow2: check-deps clean
# ${PACKER} build template.json
${PACKER} init . debirf.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} debirf.pkr.hcl
${PACKER} init . build.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} build.pkr.hcl

# cableos-installer.tar.gz: check-deps clean
# # ${PACKER} build template.json
# ${PACKER} init . build.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} build.pkr.hcl

clean:
${RM} -rf output-cableos cableos.tar.gz output-debirf debirf.tar.gz
${RM} -rf output-images/cableos-installer.qcow2 cableos-installer.tar.gz
File renamed without changes.
43 changes: 20 additions & 23 deletions cableos/build.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// Define Packer Source for QEMU
source "qemu" "debirf-live" {
iso_url = var.debirf_live_bullseye_amd64_iso
checksum_type = var.checksum_type
iso_checksum = "md5:1234567890abcdef1234567890abcdef"
checksum_type = var.debirf_checksum
iso_url = "/boot-images/debirf-live_bullseye_amd64.iso"
iso_checksum = "none"
disk_size = 10240
output_directory = "output-debirf-live"
output_directory = "output-images"
vm_name = "debirf-live"
format = "qcow2"
accelerator = "kvm"
http_directory = "http"
boot_command = [
"<enter><wait>",
"linux /install/vmlinuz auto hostname=debirf-live <wait>",
"initrd /install/initrd.gz <wait>",
"linux /boot-images/vmlinuz-6.0.0-0.deb11.6-amd64 auto hostname=debirf-live <wait>",
"initrd /boot-images/debirf-live_bullseye_6.0.0-0.deb11.6-amd64.cgz <wait>",
"boot<enter>"
]
ssh_username = "root"
ssh_password = "root"
ssh_password = "install"
ssh_port = 22
ssh_wait_timeout = "10000s"
headless = false
Expand All @@ -30,36 +28,35 @@ build {
]

// Provisioners for installation and file extraction
provisioner "shell" {
inline = [
"sudo ostree-production install --source=Apollo.iso --destination=/",
"sudo cp /boot/vmlinuz* /vmlinuz",
"sudo cp /boot/initrd.img* /initrd.img"
]
}

provisioner "file" {
source = "/vmlinuz"
destination = "output-debirf-live/vmlinuz"
source = "/buildfiles/APOLLO_PLATFORM-release-3.21.3.0-7+auto15.iso",
destination = "/opt/APOLLO_PLATFORM-release-3.21.3.0-7+auto15.iso"
}

provisioner "file" {
source = "/initrd.img"
destination = "output-debirf-live/initrd.img"
source = "/buildfiles/startup.sh"
destination = "/etc/init.d/startup.sh",

}
provisioner "shell" {
inline = [
"echo 'Files copied successfully..'"
]
}

// Post-processors to create new images and prepare for MAAS

post-processor "qemu" {
only = ["qemu"]
output = "new.qcow"
output = "output-images/cableos-installer.qcow"
format = "qcow2"
disk_interface = "virtio"
}

post-processor "shell-local" {
inline = [
"qemu-img convert -f qcow2 -O raw new.qcow new.img",
"maas admin boot-resources create name=custom/new name_title='New Image' architecture=amd64/generic content@=new.img"
"qemu-img convert -f qcow2 -O raw cableos-installer.qcow cableos-installer.img",
"maas admin boot-resources create name=custom/cableos-installer name_title='CableOS Installation Image' architecture=amd64/generic content@=cableos-installer.img"
]
}
}
3 changes: 3 additions & 0 deletions cableos/buildfiles/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -ex
export APOLLO_PKG=APOLLO_PLATFORM-release-3.21.3.0-7+auto15.iso
ostree-production -D /dev/sda from /opt/${APOLLO_PKG}
16 changes: 0 additions & 16 deletions cableos/debirf/extract-initrd.pkr.hcl

This file was deleted.

Binary file removed cableos/debirf/minimal.tgz
Binary file not shown.
45 changes: 0 additions & 45 deletions cableos/debirf/minimal/debirf.conf

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/a0_motd

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/a0_prep-root

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/install-kernel

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/network

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/root-bashrc

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/z0_remove-locales

This file was deleted.

1 change: 0 additions & 1 deletion cableos/debirf/minimal/modules/z1_clean-root

This file was deleted.

Empty file added cableos/http/scratch/.gitignore
Empty file.
6 changes: 3 additions & 3 deletions cableos/build.json → cableos/scratch/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"http_directory": "http",
"boot_command": [
"<enter><wait>",
"linux /install/vmlinuz auto hostname=debirf-live <wait>",
"initrd /install/initrd.gz <wait>",
"linux /boot-images/vmlinuz-6.0.0-0.deb11.6-amd64 auto hostname=debirf-live <wait>",
"initrd /boot-images/debirf-live_bullseye_6.0.0-0.deb11.6-amd64.cgz <wait>",
"boot<enter>"
],
"ssh_username": "root",
"ssh_password": "root",
"ssh_password": "install",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"headless": false
Expand Down
File renamed without changes.
9 changes: 0 additions & 9 deletions cableos/scripts/apollo_install.sh

This file was deleted.

50 changes: 0 additions & 50 deletions cableos/variables.json

This file was deleted.

Loading

0 comments on commit a3ab7d5

Please sign in to comment.