mirror of
https://github.com/containers/podman.git
synced 2025-06-06 15:00:40 +08:00
Improve DESTDIR/PREFIX/ETCDIR handling
- PREFIX is now passed saved in the binary at build-time so that default paths match installation paths. - ETCDIR is also overridable in a similar way. - DESTDIR is now applied on top of PREFIX for install/uninstall steps. Previously, a DESTDIR=/foo PREFIX=/bar make would install into /bar, rather than /foo/bar. Signed-off-by: Lawrence Chan <element103@gmail.com>
This commit is contained in:
70
Makefile
70
Makefile
@ -1,5 +1,5 @@
|
|||||||
GO ?= go
|
GO ?= go
|
||||||
DESTDIR ?= /
|
DESTDIR ?=
|
||||||
EPOCH_TEST_COMMIT ?= 90e3c9002b2293569e0cec168a30ecb962b00034
|
EPOCH_TEST_COMMIT ?= 90e3c9002b2293569e0cec168a30ecb962b00034
|
||||||
HEAD ?= HEAD
|
HEAD ?= HEAD
|
||||||
CHANGELOG_BASE ?= HEAD~
|
CHANGELOG_BASE ?= HEAD~
|
||||||
@ -10,12 +10,12 @@ GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|||||||
GIT_BRANCH_CLEAN ?= $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
|
GIT_BRANCH_CLEAN ?= $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
|
||||||
LIBPOD_IMAGE ?= libpod_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
|
LIBPOD_IMAGE ?= libpod_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
|
||||||
LIBPOD_INSTANCE := libpod_dev
|
LIBPOD_INSTANCE := libpod_dev
|
||||||
PREFIX ?= ${DESTDIR}/usr/local
|
PREFIX ?= /usr/local
|
||||||
BINDIR ?= ${PREFIX}/bin
|
BINDIR ?= ${PREFIX}/bin
|
||||||
LIBEXECDIR ?= ${PREFIX}/libexec
|
LIBEXECDIR ?= ${PREFIX}/libexec
|
||||||
MANDIR ?= ${PREFIX}/share/man
|
MANDIR ?= ${PREFIX}/share/man
|
||||||
SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
|
SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
|
||||||
ETCDIR ?= ${DESTDIR}/etc
|
ETCDIR ?= /etc
|
||||||
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
|
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
|
||||||
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
|
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
|
||||||
BUILDTAGS ?= \
|
BUILDTAGS ?= \
|
||||||
@ -51,7 +51,11 @@ COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
|
|||||||
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
|
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
|
||||||
BUILD_INFO ?= $(shell date +%s)
|
BUILD_INFO ?= $(shell date +%s)
|
||||||
LIBPOD := ${PROJECT}/libpod
|
LIBPOD := ${PROJECT}/libpod
|
||||||
LDFLAGS_PODMAN ?= $(LDFLAGS) -X $(LIBPOD).gitCommit=$(GIT_COMMIT) -X $(LIBPOD).buildInfo=$(BUILD_INFO)
|
LDFLAGS_PODMAN ?= $(LDFLAGS) \
|
||||||
|
-X $(LIBPOD).gitCommit=$(GIT_COMMIT) \
|
||||||
|
-X $(LIBPOD).buildInfo=$(BUILD_INFO) \
|
||||||
|
-X $(LIBPOD).installPrefix=$(PREFIX) \
|
||||||
|
-X $(LIBPOD).etcDir=$(ETCDIR)
|
||||||
ISODATE ?= $(shell date --iso-8601)
|
ISODATE ?= $(shell date --iso-8601)
|
||||||
#Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too.
|
#Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too.
|
||||||
LIBSECCOMP_COMMIT := release-2.3
|
LIBSECCOMP_COMMIT := release-2.3
|
||||||
@ -262,54 +266,54 @@ changelog: ## Generate changelog
|
|||||||
install: .gopathok install.bin install.remote install.man install.cni install.systemd ## Install binaries to system locations
|
install: .gopathok install.bin install.remote install.man install.cni install.systemd ## Install binaries to system locations
|
||||||
|
|
||||||
install.remote:
|
install.remote:
|
||||||
install ${SELINUXOPT} -d -m 755 $(BINDIR)
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
|
||||||
install ${SELINUXOPT} -m 755 bin/podman-remote $(BINDIR)/podman-remote
|
install ${SELINUXOPT} -m 755 bin/podman-remote $(DESTDIR)$(BINDIR)/podman-remote
|
||||||
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(BINDIR)/podman bin/podman-remote
|
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman-remote
|
||||||
|
|
||||||
install.bin:
|
install.bin:
|
||||||
install ${SELINUXOPT} -d -m 755 $(BINDIR)
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
|
||||||
install ${SELINUXOPT} -m 755 bin/podman $(BINDIR)/podman
|
install ${SELINUXOPT} -m 755 bin/podman $(DESTDIR)$(BINDIR)/podman
|
||||||
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(BINDIR)/podman bin/podman
|
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman
|
||||||
|
|
||||||
install.man: docs
|
install.man: docs
|
||||||
install ${SELINUXOPT} -d -m 755 $(MANDIR)/man1
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1
|
||||||
install ${SELINUXOPT} -d -m 755 $(MANDIR)/man5
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man5
|
||||||
install ${SELINUXOPT} -m 644 $(filter %.1,$(MANPAGES)) -t $(MANDIR)/man1
|
install ${SELINUXOPT} -m 644 $(filter %.1,$(MANPAGES)) -t $(DESTDIR)$(MANDIR)/man1
|
||||||
install ${SELINUXOPT} -m 644 $(filter %.5,$(MANPAGES)) -t $(MANDIR)/man5
|
install ${SELINUXOPT} -m 644 $(filter %.5,$(MANPAGES)) -t $(DESTDIR)$(MANDIR)/man5
|
||||||
install ${SELINUXOPT} -m 644 docs/links/*1 -t $(MANDIR)/man1
|
install ${SELINUXOPT} -m 644 docs/links/*1 -t $(DESTDIR)$(MANDIR)/man1
|
||||||
|
|
||||||
install.config:
|
install.config:
|
||||||
install ${SELINUXOPT} -d -m 755 $(SHAREDIR_CONTAINERS)
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(SHAREDIR_CONTAINERS)
|
||||||
install ${SELINUXOPT} -m 644 libpod.conf $(SHAREDIR_CONTAINERS)/libpod.conf
|
install ${SELINUXOPT} -m 644 libpod.conf $(DESTDIR)$(SHAREDIR_CONTAINERS)/libpod.conf
|
||||||
install ${SELINUXOPT} -m 644 seccomp.json $(SHAREDIR_CONTAINERS)/seccomp.json
|
install ${SELINUXOPT} -m 644 seccomp.json $(DESTDIR)$(SHAREDIR_CONTAINERS)/seccomp.json
|
||||||
|
|
||||||
install.completions:
|
install.completions:
|
||||||
install ${SELINUXOPT} -d -m 755 ${BASHINSTALLDIR}
|
install ${SELINUXOPT} -d -m 755 ${DESTDIR}${BASHINSTALLDIR}
|
||||||
install ${SELINUXOPT} -m 644 completions/bash/podman ${BASHINSTALLDIR}
|
install ${SELINUXOPT} -m 644 completions/bash/podman ${DESTDIR}${BASHINSTALLDIR}
|
||||||
install ${SELINUXOPT} -d -m 755 ${ZSHINSTALLDIR}
|
install ${SELINUXOPT} -d -m 755 ${DESTDIR}${ZSHINSTALLDIR}
|
||||||
install ${SELINUXOPT} -m 644 completions/zsh/_podman ${ZSHINSTALLDIR}
|
install ${SELINUXOPT} -m 644 completions/zsh/_podman ${DESTDIR}${ZSHINSTALLDIR}
|
||||||
|
|
||||||
install.cni:
|
install.cni:
|
||||||
install ${SELINUXOPT} -d -m 755 ${ETCDIR}/cni/net.d/
|
install ${SELINUXOPT} -d -m 755 ${DESTDIR}${ETCDIR}/cni/net.d/
|
||||||
install ${SELINUXOPT} -m 644 cni/87-podman-bridge.conflist ${ETCDIR}/cni/net.d/87-podman-bridge.conflist
|
install ${SELINUXOPT} -m 644 cni/87-podman-bridge.conflist ${DESTDIR}${ETCDIR}/cni/net.d/87-podman-bridge.conflist
|
||||||
|
|
||||||
install.docker: docker-docs
|
install.docker: docker-docs
|
||||||
install ${SELINUXOPT} -d -m 755 $(BINDIR) $(MANDIR)/man1
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
|
||||||
install ${SELINUXOPT} -m 755 docker $(BINDIR)/docker
|
install ${SELINUXOPT} -m 755 docker $(DESTDIR)$(BINDIR)/docker
|
||||||
install ${SELINUXOPT} -m 644 docs/docker*.1 -t $(MANDIR)/man1
|
install ${SELINUXOPT} -m 644 docs/docker*.1 -t $(DESTDIR)$(MANDIR)/man1
|
||||||
|
|
||||||
install.systemd:
|
install.systemd:
|
||||||
install ${SELINUXOPT} -m 755 -d ${SYSTEMDDIR} ${TMPFILESDIR}
|
install ${SELINUXOPT} -m 755 -d ${DESTDIR}${SYSTEMDDIR} ${DESTDIR}${TMPFILESDIR}
|
||||||
install ${SELINUXOPT} -m 644 contrib/varlink/io.podman.socket ${SYSTEMDDIR}/io.podman.socket
|
install ${SELINUXOPT} -m 644 contrib/varlink/io.podman.socket ${DESTDIR}${SYSTEMDDIR}/io.podman.socket
|
||||||
install ${SELINUXOPT} -m 644 contrib/varlink/io.podman.service ${SYSTEMDDIR}/io.podman.service
|
install ${SELINUXOPT} -m 644 contrib/varlink/io.podman.service ${DESTDIR}${SYSTEMDDIR}/io.podman.service
|
||||||
install ${SELINUXOPT} -m 644 contrib/varlink/podman.conf ${TMPFILESDIR}/podman.conf
|
install ${SELINUXOPT} -m 644 contrib/varlink/podman.conf ${DESTDIR}${TMPFILESDIR}/podman.conf
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
for i in $(filter %.1,$(MANPAGES)); do \
|
for i in $(filter %.1,$(MANPAGES)); do \
|
||||||
rm -f $(MANDIR)/man1/$$(basename $${i}); \
|
rm -f $(DESTDIR)$(MANDIR)/man1/$$(basename $${i}); \
|
||||||
done; \
|
done; \
|
||||||
for i in $(filter %.5,$(MANPAGES)); do \
|
for i in $(filter %.5,$(MANPAGES)); do \
|
||||||
rm -f $(MANDIR)/man5/$$(basename $${i}); \
|
rm -f $(DESTDIR)$(MANDIR)/man5/$$(basename $${i}); \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: .gitvalidation
|
.PHONY: .gitvalidation
|
||||||
|
@ -42,11 +42,13 @@ const (
|
|||||||
SQLiteStateStore RuntimeStateStore = iota
|
SQLiteStateStore RuntimeStateStore = iota
|
||||||
// BoltDBStateStore is a state backed by a BoltDB database
|
// BoltDBStateStore is a state backed by a BoltDB database
|
||||||
BoltDBStateStore RuntimeStateStore = iota
|
BoltDBStateStore RuntimeStateStore = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
// SeccompDefaultPath defines the default seccomp path
|
// SeccompDefaultPath defines the default seccomp path
|
||||||
SeccompDefaultPath = "/usr/share/containers/seccomp.json"
|
SeccompDefaultPath = installPrefix + "/share/containers/seccomp.json"
|
||||||
// SeccompOverridePath if this exists it overrides the default seccomp path
|
// SeccompOverridePath if this exists it overrides the default seccomp path
|
||||||
SeccompOverridePath = "/etc/crio/seccomp.json"
|
SeccompOverridePath = etcDir + "/crio/seccomp.json"
|
||||||
|
|
||||||
// ConfigPath is the path to the libpod configuration file
|
// ConfigPath is the path to the libpod configuration file
|
||||||
// This file is loaded to replace the builtin default config before
|
// This file is loaded to replace the builtin default config before
|
||||||
@ -54,11 +56,11 @@ const (
|
|||||||
// If it is not present, the builtin default config is used instead
|
// If it is not present, the builtin default config is used instead
|
||||||
// This path can be overridden when the runtime is created by using
|
// This path can be overridden when the runtime is created by using
|
||||||
// NewRuntimeFromConfig() instead of NewRuntime()
|
// NewRuntimeFromConfig() instead of NewRuntime()
|
||||||
ConfigPath = "/usr/share/containers/libpod.conf"
|
ConfigPath = installPrefix + "/share/containers/libpod.conf"
|
||||||
// OverrideConfigPath is the path to an override for the default libpod
|
// OverrideConfigPath is the path to an override for the default libpod
|
||||||
// configuration file. If OverrideConfigPath exists, it will be used in
|
// configuration file. If OverrideConfigPath exists, it will be used in
|
||||||
// place of the configuration file pointed to by ConfigPath.
|
// place of the configuration file pointed to by ConfigPath.
|
||||||
OverrideConfigPath = "/etc/containers/libpod.conf"
|
OverrideConfigPath = etcDir + "/containers/libpod.conf"
|
||||||
|
|
||||||
// DefaultInfraImage to use for infra container
|
// DefaultInfraImage to use for infra container
|
||||||
DefaultInfraImage = "k8s.gcr.io/pause:3.1"
|
DefaultInfraImage = "k8s.gcr.io/pause:3.1"
|
||||||
@ -300,7 +302,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) {
|
|||||||
TmpDir: "",
|
TmpDir: "",
|
||||||
MaxLogSize: -1,
|
MaxLogSize: -1,
|
||||||
NoPivotRoot: false,
|
NoPivotRoot: false,
|
||||||
CNIConfigDir: "/etc/cni/net.d/",
|
CNIConfigDir: etcDir + "/cni/net.d/",
|
||||||
CNIPluginDir: []string{"/usr/libexec/cni", "/usr/lib/cni", "/usr/local/lib/cni", "/opt/cni/bin"},
|
CNIPluginDir: []string{"/usr/libexec/cni", "/usr/lib/cni", "/usr/local/lib/cni", "/opt/cni/bin"},
|
||||||
InfraCommand: DefaultInfraCommand,
|
InfraCommand: DefaultInfraCommand,
|
||||||
InfraImage: DefaultInfraImage,
|
InfraImage: DefaultInfraImage,
|
||||||
|
@ -15,6 +15,12 @@ var (
|
|||||||
// BuildInfo is the time at which the binary was built
|
// BuildInfo is the time at which the binary was built
|
||||||
// It will be populated by the Makefile.
|
// It will be populated by the Makefile.
|
||||||
buildInfo string
|
buildInfo string
|
||||||
|
// InstallPrefix is the prefix where podman will be installed.
|
||||||
|
// It will be populated by the Makefile.
|
||||||
|
installPrefix string = "/usr/local"
|
||||||
|
// EtcDir is the sysconfdir where podman should look for system config files.
|
||||||
|
// It will be populated by the Makefile.
|
||||||
|
etcDir string = "/etc"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Version is an output struct for varlink
|
//Version is an output struct for varlink
|
||||||
|
Reference in New Issue
Block a user