-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize the repository code to make it a little bit more package-l…
…ike (#66)
- Loading branch information
1 parent
e8e43a4
commit 4c94953
Showing
19 changed files
with
223 additions
and
187 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
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
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
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
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
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
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
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
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
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
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,32 @@ | ||
module RootfsUtils | ||
|
||
using ArgParse: ArgParse | ||
using Base.BinaryPlatforms | ||
using Dates | ||
using Pkg | ||
using Pkg.Artifacts | ||
using SHA | ||
using Scratch | ||
using Test | ||
using ghr_jll | ||
|
||
export AlpinePackage | ||
export alpine_bootstrap | ||
export chroot | ||
export debootstrap | ||
export parse_build_args | ||
export test_sandbox | ||
export upload_rootfs_image_github_actions | ||
|
||
include("types.jl") | ||
|
||
include("build/alpine.jl") | ||
include("build/args.jl") | ||
include("build/common.jl") | ||
include("build/debian.jl") | ||
include("build/utils.jl") | ||
|
||
include("run/args.jl") | ||
include("run/test.jl") | ||
|
||
end # module |
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,44 @@ | ||
function repository_arg(repo) | ||
if startswith(repo, "https://") | ||
return "--repository=$(repo)" | ||
end | ||
return "--repository=http://dl-cdn.alpinelinux.org/alpine/$(repo)/main" | ||
end | ||
|
||
function alpine_bootstrap(f::Function, name::String; release::VersionNumber=v"3.13.5", variant="minirootfs", | ||
packages::Vector{AlpinePackage}=AlpinePackage[], force::Bool=false) | ||
return create_rootfs(name; force) do rootfs | ||
rootfs_url = "https://github.com/alpinelinux/docker-alpine/raw/v$(release.major).$(release.minor)/x86_64/alpine-$(variant)-$(release)-x86_64.tar.gz" | ||
@info("Downloading Alpine rootfs", url=rootfs_url) | ||
rm(rootfs) | ||
Pkg.Artifacts.download_verify_unpack(rootfs_url, nothing, rootfs; verbose=true) | ||
|
||
# Call user callback, if requested | ||
f(rootfs) | ||
|
||
# Remove special `dev` files, take ownership, force symlinks to be relative, etc... | ||
rootfs_info = """ | ||
rootfs_type=alpine | ||
release=$(release) | ||
variant=$(variant) | ||
packages=$(join([pkg.name for pkg in packages], ",")) | ||
build_date=$(Dates.now()) | ||
""" | ||
cleanup_rootfs(rootfs; rootfs_info) | ||
|
||
# Generate one `apk` invocation per repository | ||
repos = unique([pkg.repo for pkg in packages]) | ||
for repo in repos | ||
apk_args = ["/sbin/apk", "add", "--no-chown"] | ||
if repo !== nothing | ||
push!(apk_args, repository_arg(repo)) | ||
end | ||
for pkg in filter(pkg -> pkg.repo == repo, packages) | ||
push!(apk_args, pkg.name) | ||
end | ||
chroot(rootfs, apk_args...) | ||
end | ||
end | ||
end | ||
# If no user callback is provided, default to doing nothing | ||
alpine_bootstrap(name::String; kwargs...) = alpine_bootstrap(p -> nothing, name; kwargs...) |
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 @@ | ||
function parse_build_args(args::AbstractVector) | ||
settings = ArgParse.ArgParseSettings() | ||
ArgParse.@add_arg_table! settings begin | ||
"--arch" | ||
required=true | ||
end | ||
parsed_args = ArgParse.parse_args(args, settings) | ||
arch = parsed_args["arch"]::String | ||
return (; arch) | ||
end |
Oops, something went wrong.