Skip to content

Commit e2775d9

Browse files
committed
Add checks for podman.
Also added some scaffholding for docker support whenever that gets added to fpm.
1 parent 8b3d9ec commit e2775d9

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lib/fpm/package/curlbash.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
class FPM::Package::CurlBash < FPM::Package
32

43
option "--container-image", "IMAGE", "The container image to use when running the command", :default => "ubuntu:latest"
@@ -36,21 +35,32 @@ def input(entry)
3635
end
3736

3837
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
4050

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)
4452

53+
# Find out the identifier for the most latest image layer
4554
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|
4756
inspection = JSON.parse(stdout.read)
4857
stdout.close
4958
last_layer = inspection[0]["RootFS"]["Layers"][-1]
5059
end
5160

61+
# Convert the container to a image layer tarball.
5262
layerdir = build_path("layers")
53-
safesystem("podman", "save", "--format", "docker-dir", "--output", layerdir, name)
63+
safesystem(runtime, "save", "--format", "docker-dir", "--output", layerdir, name)
5464

5565
# Extract the last layer to the staging_path for packaging.
5666
safesystem("tar", "-C", staging_path, "-x",

0 commit comments

Comments
 (0)