|
1 | | - |
2 | 1 | class FPM::Package::CurlBash < FPM::Package |
3 | 2 |
|
4 | 3 | option "--container-image", "IMAGE", "The container image to use when running the command", :default => "ubuntu:latest" |
@@ -36,21 +35,32 @@ def input(entry) |
36 | 35 | end |
37 | 36 |
|
38 | 37 | name = "whatever-#{$$}" |
39 | | - safesystem("podman", "image", "build", "-t", name, *build_flags) |
| 38 | + if program_exists?("podman") |
| 39 | + runtime = "podman" |
| 40 | + elsif program_exists?("docker") |
| 41 | + # Docker support isn't implemented yet. I don't expect it to be difficult, but |
| 42 | + # we need to check if the build, inspect, and save commands use the same syntax |
| 43 | + # At minimu, docker doesn't support the same flags as `podman image save` |
| 44 | + #runtime = "docker" |
| 45 | + logger.error("Docker executable found, but fpm doesn't support this yet. If you want this, file an issue? https://github.com/jordansissel/fpm/issues/new") |
| 46 | + raise FPM::Package::InvalidPackageConfiguration, "Missing 'podman' executable." |
| 47 | + else |
| 48 | + raise FPM::Package::InvalidPackageConfiguration, "Missing 'podman' executable." |
| 49 | + end |
40 | 50 |
|
41 | | - # Convert the container to a image layer tarball. |
42 | | - changes_tar = build_path("changes.tar") |
43 | | - safesystem("podman", "save", name, "-o", changes_tar) |
| 51 | + safesystem(runtime, "image", "build", "-t", name, *build_flags) |
44 | 52 |
|
| 53 | + # Find out the identifier for the most latest image layer |
45 | 54 | last_layer = nil |
46 | | - execmd(["podman", "inspect", name], :stdin => false, :stdout =>true) do |stdout| |
| 55 | + execmd([runtime, "inspect", name], :stdin => false, :stdout =>true) do |stdout| |
47 | 56 | inspection = JSON.parse(stdout.read) |
48 | 57 | stdout.close |
49 | 58 | last_layer = inspection[0]["RootFS"]["Layers"][-1] |
50 | 59 | end |
51 | 60 |
|
| 61 | + # Convert the container to a image layer tarball. |
52 | 62 | layerdir = build_path("layers") |
53 | | - safesystem("podman", "save", "--format", "docker-dir", "--output", layerdir, name) |
| 63 | + safesystem(runtime, "save", "--format", "docker-dir", "--output", layerdir, name) |
54 | 64 |
|
55 | 65 | # Extract the last layer to the staging_path for packaging. |
56 | 66 | safesystem("tar", "-C", staging_path, "-x", |
|
0 commit comments