define-alpine/setup.lua

56 lines
1.4 KiB
Lua
Raw Normal View History

2022-06-18 00:06:19 +00:00
local utils = require("utils")
local alpine = require("alpine")
local alpine_base_version = "3.15"
local alpine_version = alpine_base_version..".0"
local packages = {
"alpine-baselayout",
-- "alpine-conf",
"apk-tools",
"busybox",
"libc-utils",
"alpine-keys",
}
local mounts = {
"tmpfs /tmp tmpfs defaults 0 0",
}
modules = {}
local root = "./root"
function add_packages(new_packages)
utils.table_concat(packages, new_packages)
end
function add_mount(new_mount)
table.insert(mounts, new_mount)
end
function add_file(path, content)
utils.expect_nil(alpine.write_file(root, path, content))
end
function add_symlink(path, target)
utils.expect_nil(alpine.symlink(root, path, target))
end
function chmod(path, perms)
utils.expect_nil(alpine.chmod(root, path, perms))
end
function mkdir(path)
utils.expect_nil(alpine.mkdir(root, path))
end
print("=> Initializing rootfs...")
utils.expect_nil(alpine.init_rootfs(root, alpine_base_version, alpine_version))
require("modules/kernel")
require("modules/runit")
print("=> Writing fstab...")
add_file("/etc/fstab", utils.join_table(mounts, "\n"))
print("=> Installing and upgrading packages...")
utils.expect_nil(alpine.make_world(root, packages))
print("=> Setting password...")
utils.expect_nil(alpine.set_password(root, "root", "12345678"))
print("=> Moving boot...")
utils.expect_nil(alpine.move_boot(root))
print("=> Making image...")
utils.expect_nil(alpine.make_squashfs(root, "image.squashfs"))