Skip to content

Commit

Permalink
New upstream version 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
obbardc committed Nov 24, 2023
1 parent 385804e commit a02045f
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
- { name: "uml", backend: "--fakemachine-backend=uml" }
test:
- { name: "recipes", case: "recipes" }
- { name: "escaping", case: "escaping", variables: " -t escaped:\\$ba\\'d\\$gers\\ snakes" }
- { name: "debian (amd64)", case: "debian", variables: "-t architecture:amd64" }
- { name: "debian (arm64)", case: "debian", variables: "-t architecture:arm64" }
- { name: "debian (armhf)", case: "debian", variables: "-t architecture:armhf" }
Expand Down
14 changes: 13 additions & 1 deletion actions/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ Comments are allowed and should be prefixed with '#' symbol.
# Use value of variable 'Var' defined above
property2: {{$Var}}
Mandatory properties for receipt:
The following custom template functions are available
- sector: Returns the argument * 512 (convential sector size) e.g. `{{ sector 64 }}`
- escape: Shell escape the argument `{{ escape $var }}`
Mandatory properties for recipe:
- architecture -- target architecture
Expand Down Expand Up @@ -74,6 +80,7 @@ import (
"fmt"
"github.com/go-debos/debos"
"gopkg.in/yaml.v2"
"github.com/alessio/shellescape"
"path"
"text/template"
"log"
Expand Down Expand Up @@ -145,6 +152,10 @@ func sector(s int) int {
return s * 512
}

func escape(s string) string {
return shellescape.Quote(s)
}

func DumpActionStruct(iface interface{}) string {
var a []string

Expand Down Expand Up @@ -231,6 +242,7 @@ func (r *Recipe) Parse(file string, printRecipe bool, dump bool, templateVars ..
t := template.New(path.Base(file))
funcs := template.FuncMap{
"sector": sector,
"escape": escape,
}
t.Funcs(funcs)

Expand Down
4 changes: 2 additions & 2 deletions cmd/debos/debos.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ func main() {
args = append(args, "--artifactdir", context.Artifactdir)

for k, v := range options.TemplateVars {
args = append(args, "--template-var", fmt.Sprintf("%s:\"%s\"", k, v))
args = append(args, "--template-var", fmt.Sprintf("%s:%s", k, v))
}

for k, v := range options.EnvironVars {
args = append(args, "--environ-var", fmt.Sprintf("%s:\"%s\"", k, v))
args = append(args, "--environ-var", fmt.Sprintf("%s:%s", k, v))
}

m.AddVolume(context.RecipeDir)
Expand Down
42 changes: 6 additions & 36 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG GOPATH=/usr/local/go

### first stage - builder ###
FROM debian:bullseye-slim as builder
FROM debian:bookworm-slim as builder

ARG DEBIAN_FRONTEND
ARG GOPATH
Expand All @@ -26,24 +26,8 @@ COPY . $GOPATH/src/github.com/go-debos/debos
WORKDIR $GOPATH/src/github.com/go-debos/debos/cmd/debos
RUN go install ./...

# Pull the latest archlinux-keyring, since the one in Debian is outdated
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1026080
RUN apt-get update && \
apt-get install -y --no-install-recommends \
pkgconf \
python3-all \
sq \
systemd && \
rm -rf /var/lib/apt/lists/*

RUN git clone https://gitlab.archlinux.org/archlinux/archlinux-keyring && \
cd archlinux-keyring && \
git checkout -B latest-release 20221213 && \
make build && \
make PREFIX=/usr KEYRING_TARGET_DIR=/usr/share/keyrings/ DESTDIR=/arch-keyring install

### second stage - runner ###
FROM debian:bullseye-slim as runner
FROM debian:bookworm-slim as runner

ARG DEBIAN_FRONTEND
ARG GOPATH
Expand Down Expand Up @@ -96,26 +80,16 @@ RUN apt-get update && \
rsync \
systemd \
systemd-container \
systemd-resolved \
u-boot-tools \
unzip \
user-mode-linux \
xfsprogs \
xz-utils \
zip && \
rm -rf /var/lib/apt/lists/*

# Enable backports for the Arch dependencies
RUN echo "deb http://ftp.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list

# NOTE: Explicitly install arch-install-scripts from backports. The normal one
# lacks pactrap.
# Install Arch dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
zip \
makepkg \
pacman-package-manager && \
apt-get install -y --no-install-recommends \
-t bullseye-backports \
pacman-package-manager \
archlinux-keyring \
arch-install-scripts && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -127,8 +101,4 @@ RUN for arch in aarch64 alpha arm armeb cris hexagon hppa m68k microblaze mips m

COPY --from=builder $GOPATH/bin/debos /usr/local/bin/debos

# Pull the latest archlinux-keyring, since the one in Debian is outdated
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1026080
COPY --from=builder /arch-keyring/ /

ENTRYPOINT ["/usr/local/bin/debos"]
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/go-debos/debos
go 1.15

require (
github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 // indirect
github.com/alessio/shellescape v1.4.2
github.com/docker/go-units v0.5.0
github.com/go-debos/fakemachine v0.0.6
github.com/google/uuid v1.3.1
github.com/go-debos/fakemachine v0.0.7
github.com/google/uuid v1.4.0
github.com/jessevdk/go-flags v1.5.0
github.com/sjoerdsimons/ostree-go v0.0.0-20201014091107-8fae757256f8
github.com/stretchr/testify v1.8.2
gopkg.in/freddierice/go-losetup.v1 v1.0.0-20170407175016-fc9adea44124
gopkg.in/yaml.v2 v2.4.0
)

require github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 // indirect
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 h1:SCbEWT58NSt7d2mcFdvxC9uyrdcTfvBbPLThhkDmXzg=
github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774/go.mod h1:6/0dYRLLXyJjbkIPeeGyoJ/eKOSI0eU6eTlCBYibgd0=
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/go-debos/fakemachine v0.0.6 h1:OTIxPdiCFkYmkDlC2EzI3sJoWS23KO72YktLTZSSgUg=
github.com/go-debos/fakemachine v0.0.6/go.mod h1:b2FvxH5PpsHHDpfaXDglLD/r7kyIAp2JslxSxb0thUU=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/go-debos/fakemachine v0.0.7-0.20231110164520-5b4b7a21f3f6 h1:SEK7MCa4Ea9JisNgcDbMdK0TMczXLGZPiXtJJkNxY2g=
github.com/go-debos/fakemachine v0.0.7-0.20231110164520-5b4b7a21f3f6/go.mod h1:FJxCgej/pEl7zHZ4xUrVncvjAQ2oMyQ/zQcMKpjST2o=
github.com/go-debos/fakemachine v0.0.7 h1:TyAnZZvlfyWSzT93gMNgMfHijL9guVoNt40IaHV/Xuk=
github.com/go-debos/fakemachine v0.0.7/go.mod h1:FJxCgej/pEl7zHZ4xUrVncvjAQ2oMyQ/zQcMKpjST2o=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/klauspost/compress v1.15.3 h1:wmfu2iqj9q22SyMINp1uQ8C2/V4M1phJdmH9fG4nba0=
Expand Down
20 changes: 20 additions & 0 deletions tests/escaping/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# expected to be run with -t escaled:\$bad\'ge\$rs or similar to verify passing
# variables onwards
{{ $escaped := or .escaped "$mu'room$" }}
architecture: amd64

actions:
- action: run
description: test escaping
chroot: false
command: echo {{ escape $escaped }} > test.a
- action: run
description: test escaping
chroot: false
command: |-
cat << 'EOF' > test.b
{{ $escaped }}
EOF
- action: run
chroot: false
command: diff -u test.a test.b

0 comments on commit a02045f

Please sign in to comment.