9 Commits

Author SHA1 Message Date
da1fb2ae17 Makefile: fix lint rules 2024-05-10 14:57:10 +03:00
8a2713bd3b main.go: fix Sprintf -> Fprintf 2024-05-10 14:50:29 +03:00
5b65b37d81 release: do not sign 2024-05-10 14:49:45 +03:00
d806f056f3 release: fix shebang 2024-05-10 14:49:20 +03:00
ec89ce64bd README: project is somewhat maintained again 2024-05-10 14:48:16 +03:00
91b3730f0c main: errors to stderr 2024-05-10 14:38:29 +03:00
db45af6b9d add deprecation notice 2024-02-09 10:49:27 +02:00
Motiejus Jakštys
f0bebff6a1 README: remove Changelog 2023-05-19 15:06:50 +03:00
Motiejus Jakštys
e6d1a95c02 upgrade to go 1.20
use errors.Join
2023-05-19 15:05:21 +03:00
6 changed files with 20 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files)) SCRIPTS = $(shell awk '/#!\/usr\/bin\/env (ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
GODEPS = $(shell git ls-files '*.go' go.mod go.sum) GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
VSN ?= $(shell git describe --dirty) VSN ?= $(shell git describe --dirty)
@@ -14,7 +14,7 @@ test: coverage.out
.PHONY: lint .PHONY: lint
lint: lint:
go vet ./... go vet ./...
$(shell go env GOPATH)/bin/staticcheck -f stylish ./... staticcheck -f stylish ./...
shellcheck $(SCRIPTS) shellcheck $(SCRIPTS)
.INTERMEDIATE: coverage.out .INTERMEDIATE: coverage.out

View File

@@ -5,6 +5,15 @@ Undocker
Converts a Docker image (a bunch of layers) to a flattened "rootfs" tarball. Converts a Docker image (a bunch of layers) to a flattened "rootfs" tarball.
Project Status
--------------
The project was announced to be deprecated in the beginning of 2024, but the
maintainer has an interest in Docker ecosystem again, thus will maintain it
somewhat starting at mid-2024.
The author has some significant changes in mind, but the timeline is unknown.
Why? Why?
---- ----
@@ -79,13 +88,6 @@ Similar Projects
* [rootfs_builder](https://github.com/ForAllSecure/rootfs_builder) * [rootfs_builder](https://github.com/ForAllSecure/rootfs_builder)
Changelog
---------
**v1.0**
* initial release: `rootfs.Flatten` and a simple command-line application.
Contributions Contributions
------------- -------------

2
go.mod
View File

@@ -1,3 +1,3 @@
module git.jakstys.lt/motiejus/undocker module git.jakstys.lt/motiejus/undocker
go 1.16 go 1.20

13
main.go
View File

@@ -2,6 +2,7 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@@ -42,7 +43,7 @@ func main() {
c := &command{flattener: rootfs.Flatten, Stdout: os.Stdout} c := &command{flattener: rootfs.Flatten, Stdout: os.Stdout}
if err := c.execute(os.Args[1], os.Args[2]); err != nil { if err := c.execute(os.Args[1], os.Args[2]); err != nil {
fmt.Printf("Error: %v\n", err) fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1) os.Exit(1)
} }
os.Exit(0) os.Exit(0)
@@ -59,10 +60,7 @@ func (c *command) execute(infile string, outfile string) (_err error) {
return err return err
} }
defer func() { defer func() {
err := rd.Close() _err = errors.Join(_err, rd.Close())
if _err == nil {
_err = err
}
}() }()
var out io.Writer var out io.Writer
@@ -74,11 +72,10 @@ func (c *command) execute(infile string, outfile string) (_err error) {
return fmt.Errorf("create: %w", err) return fmt.Errorf("create: %w", err)
} }
defer func() { defer func() {
err := outf.Close()
if _err != nil { if _err != nil {
os.Remove(outfile) _err = errors.Join(_err, os.Remove(outfile))
} else { } else {
_err = err _err = errors.Join(_err, outf.Close())
} }
}() }()
out = outf out = outf

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
_err(){ >&2 echo "ERROR: $*"; exit 1; } _err(){ >&2 echo "ERROR: $*"; exit 1; }
@@ -22,4 +22,4 @@ last_tag=$(git tag | tail -1)
echo echo
echo Changelog since "$last_tag": echo Changelog since "$last_tag":
git log --pretty=format:"- [%an] %s" "$last_tag"..HEAD git log --pretty=format:"- [%an] %s" "$last_tag"..HEAD
} | git tag -u motiejus@jakstys.lt -F - "$1" } | git tag -F - "$1"

View File

@@ -144,11 +144,7 @@ func Flatten(rd io.ReadSeeker, w io.Writer) (_err error) {
tw := tar.NewWriter(w) tw := tar.NewWriter(w)
defer func() { defer func() {
// Avoiding use of multierr: if error is present, return _err = errors.Join(_err, tw.Close())
// that. Otherwise return whatever `Close` returns.
if err := tw.Close(); err != nil && _err == nil {
_err = err
}
}() }()
// iterate through all layers, all files, and write files. // iterate through all layers, all files, and write files.
for i, no := range layers { for i, no := range layers {