Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #43 from smcv/paths

Make component naming and paths more flexible
  • Loading branch information...
commit fa4024e642ceceeaba21d34572e5570936368209 2 parents 118c5a7 + 56a638a
@xrmx xrmx authored
View
73 Makefile
@@ -4,12 +4,26 @@ PKG_TARBALL=$(PKG_NAME)-$(VER).tar.bz2
CC ?= gcc
CFLAGS ?= -g -Wall -O0
+CPPFLAGS ?=
+
+# Normally empty, but you can use program_prefix=mmeeks- or program_suffix=2
+# to install bootchart2 on a system that already has other projects that also
+# call themselves bootchart.
+PROGRAM_PREFIX ?=
+PROGRAM_SUFFIX ?=
+
+# Prefix for things that must reside on the root filesystem.
+# "" for e.g. Debian; /usr for distributions with /usr unification.
+EARLY_PREFIX ?=
BINDIR ?= /usr/bin
PYTHON ?= python
-DOCDIR ?= /usr/share/docs/bootchart
+DOCDIR ?= /usr/share/docs/$(PROGRAM_PREFIX)bootchart$(PROGRAM_SUFFIX)
MANDIR ?= /usr/share/man/man1
+# never contains /usr; typically /lib, /lib64 or e.g. /lib/x86_64-linux-gnu
LIBDIR ?= /lib
+PKGLIBDIR ?= $(EARLY_PREFIX)$(LIBDIR)/$(PROGRAM_PREFIX)bootchart$(PROGRAM_SUFFIX)
+
ifndef PY_LIBDIR
ifndef NO_PYTHON_COMPILE
PY_LIBDIR := $(shell $(PYTHON) -c "from distutils import sysconfig; print(sysconfig.get_config_var('DESTLIB'))")
@@ -19,7 +33,8 @@ endif
endif
PY_SITEDIR ?= $(PY_LIBDIR)/site-packages
LIBC_A_PATH = /usr$(LIBDIR)
-SYSTEMD_UNIT_DIR = $(LIBDIR)/systemd/system
+# Always lib, even on systems that otherwise use lib64
+SYSTEMD_UNIT_DIR = $(EARLY_PREFIX)/lib/systemd/system
COLLECTOR = \
collector/collector.o \
collector/output.o \
@@ -27,19 +42,47 @@ COLLECTOR = \
collector/tasks-netlink.o \
collector/dump.o
-all: bootchart-collector bootchartd pybootchartgui/main.py
+all: \
+ bootchart-collector \
+ bootchartd \
+ bootchart.service \
+ bootchart-done.service \
+ bootchart-done.timer \
+ pybootchartgui/main.py
%.o:%.c
- $(CC) $(CFLAGS) $(LDFLAGS) -pthread -DVERSION=\"$(VER)\" -c $^ -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) -pthread \
+ -DEARLY_PREFIX='"$(EARLY_PREFIX)"' \
+ -DLIBDIR='"$(LIBDIR)"' \
+ -DPKGLIBDIR='"$(PKGLIBDIR)"' \
+ -DPROGRAM_PREFIX='"$(PROGRAM_PREFIX)"' \
+ -DPROGRAM_SUFFIX='"$(PROGRAM_SUFFIX)"' \
+ -DVERSION='"$(VER)"' \
+ $(CPPFLAGS) \
+ -c $^ -o $@
+
+substitute_variables = \
+ sed -s \
+ -e "s:@LIBDIR@:$(LIBDIR):g" \
+ -e "s:@PKGLIBDIR@:$(PKGLIBDIR):" \
+ -e "s:@PROGRAM_PREFIX@:$(PROGRAM_PREFIX):" \
+ -e "s:@PROGRAM_SUFFIX@:$(PROGRAM_SUFFIX):" \
+ -e "s:@VER@:$(VER):"
bootchartd: bootchartd.in
- sed -s "s:@LIBDIR@:$(LIBDIR):g" $^ > $@
+ $(substitute_variables) $^ > $@
+
+%.service: %.service.in
+ $(substitute_variables) $^ > $@
+
+%.timer: %.timer.in
+ $(substitute_variables) $^ > $@
bootchart-collector: $(COLLECTOR)
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -Icollector -o $@ $^
pybootchartgui/main.py: pybootchartgui/main.py.in
- sed -s "s/@VER@/$(VER)/g" $^ > $@
+ $(substitute_variables) $^ > $@
py-install-compile: pybootchartgui/main.py
install -d $(DESTDIR)$(PY_SITEDIR)/pybootchartgui
@@ -50,27 +93,29 @@ py-install-compile: pybootchartgui/main.py
PYTHONOPTIMIZE=1 $(PYTHON) $(PY_LIBDIR)/py_compile.py *.py ); :
install-chroot:
- install -d $(DESTDIR)$(LIBDIR)/bootchart/tmpfs
+ install -d $(DESTDIR)$(PKGLIBDIR)/tmpfs
install-collector: all install-chroot
- install -m 755 -D bootchartd $(DESTDIR)/sbin/bootchartd
- install -m 644 -D bootchartd.conf $(DESTDIR)/etc/bootchartd.conf
- install -m 755 -D bootchart-collector $(DESTDIR)$(LIBDIR)/bootchart/bootchart-collector
+ install -m 755 -D bootchartd $(DESTDIR)$(EARLY_PREFIX)/sbin/$(PROGRAM_PREFIX)bootchartd$(PROGRAM_SUFFIX)
+ install -m 644 -D bootchartd.conf $(DESTDIR)/etc/$(PROGRAM_PREFIX)bootchartd$(PROGRAM_SUFFIX).conf
+ install -m 755 -D bootchart-collector $(DESTDIR)$(PKGLIBDIR)/$(PROGRAM_PREFIX)bootchart$(PROGRAM_SUFFIX)-collector
install-docs:
install -m 644 -D README $(DESTDIR)$(DOCDIR)/README
install -m 644 -D README.pybootchart $(DESTDIR)$(DOCDIR)/README.pybootchart
mkdir -p $(DESTDIR)$(MANDIR)
gzip -c bootchart2.1 > $(DESTDIR)$(MANDIR)/bootchart2.1.gz
- gzip -c bootchartd.1 > $(DESTDIR)$(MANDIR)/bootchartd.1.gz
+ gzip -c bootchartd.1 > $(DESTDIR)$(MANDIR)/$(PROGRAM_PREFIX)bootchartd$(PROGRAM_SUFFIX).1.gz
gzip -c pybootchartgui.1 > $(DESTDIR)$(MANDIR)/pybootchartgui.1.gz
install-service:
mkdir -p $(DESTDIR)$(SYSTEMD_UNIT_DIR)
install -m 0644 bootchart.service \
- bootchart-done.service \
- bootchart-done.timer \
- $(DESTDIR)$(SYSTEMD_UNIT_DIR)
+ $(DESTDIR)$(SYSTEMD_UNIT_DIR)/bootchart2.service
+ install -m 0644 bootchart-done.service \
+ $(DESTDIR)$(SYSTEMD_UNIT_DIR)/bootchart2-done.service
+ install -m 0644 bootchart-done.timer \
+ $(DESTDIR)$(SYSTEMD_UNIT_DIR)/bootchart2-done.timer
install: all py-install-compile install-collector install-service install-docs
View
4 bootchart-done.service → bootchart-done.service.in
@@ -14,8 +14,8 @@ Before=shutdown.target
[Service]
Type=oneshot
-ExecStart=/sbin/bootchartd stop
+ExecStart=@EARLY_PREFIX@/sbin/@PROGRAM_PREFIX@bootchartd@PROGRAM_SUFFIX@ stop
[Install]
-Also=bootchart.service
+Also=@PROGRAM_PREFIX@bootchart@PROGRAM_SUFFIX@.service
View
2  bootchart-done.timer → bootchart-done.timer.in
@@ -16,5 +16,5 @@ Before=shutdown.target
OnActiveSec=20s
[Install]
-Also=bootchart.service
+Also=@PROGRAM_PREFIX@bootchart@PROGRAM_SUFFIX@.service
View
4 bootchart.service → bootchart.service.in
@@ -8,13 +8,13 @@
[Unit]
Description=Collect Bootchart Data
DefaultDependencies=no
-Wants=bootchart-done.timer
+Wants=@PROGRAM_PREFIX@bootchart@PROGRAM_SUFFIX@-done.timer
Conflicts=shutdown.target
Before=basic.target shutdown.target
[Service]
Type=notify
-ExecStart=/sbin/bootchartd start
+ExecStart=@EARLY_PREFIX@/sbin/@PROGRAM_PREFIX@bootchartd@PROGRAM_SUFFIX@ start
RemainAfterExit=yes
[Install]
View
26 bootchartd.in
@@ -23,8 +23,11 @@
# our 'proc' without having to touch a (potentially) read-only
# file-system.
LIBDIR="@LIBDIR@"
-TMPFS="${LIBDIR}/bootchart/tmpfs"
-COLLECTOR_BIN="${LIBDIR}/bootchart/bootchart-collector"
+PKGLIBDIR="@PKGLIBDIR@"
+PROGRAM_PREFIX="@PROGRAM_PREFIX@"
+PROGRAM_SUFFIX="@PROGRAM_SUFFIX@"
+TMPFS="${PKGLIBDIR}/tmpfs"
+COLLECTOR_BIN="${PKGLIBDIR}/${PROGRAM_PREFIX}bootchart${PROGRAM_SUFFIX}-collector"
# some initrds don't have usleep etc.
USLEEP="$COLLECTOR_BIN --usleep"
@@ -56,9 +59,10 @@ EXIT_PROC="compiz \
xterm"
# Read configuration.
-CONF="/etc/bootchartd.conf"
-if [ -f $PWD/bootchartd.conf ]; then
- . $PWD/bootchartd.conf
+CONFBASE="${PROGRAM_PREFIX}bootchartd${PROGRAM_SUFFIX}"
+CONF="/etc/${CONFBASE}.conf"
+if [ -f $PWD/${CONFBASE}.conf ]; then
+ . $PWD/${CONFBASE}.conf
elif [ -f $CONF ]; then
. $CONF
else
@@ -193,10 +197,14 @@ if [ $$ -eq 1 ]; then
fi
if [ "${i%%=*}" = "init" ]; then
_init=${i#*=}
- if test "$_init" != "/sbin/bootchartd"; then
- init="$_init"
- break
- fi
+ case "$_init" in
+ (*/sbin/*bootchartd*)
+ ;;
+ (*)
+ init="$_init"
+ break
+ ;;
+ esac
fi
done
export PATH=$OLDPATH
View
5 collector/collector.c
@@ -657,8 +657,9 @@ enter_environment (int console_debug)
/* we need our tmpfs to look like this file-system,
so we can chroot into it if necessary */
- mkdir (TMPFS_PATH "/lib", 0777);
- mkdir (TMPFS_PATH "/lib/bootchart", 0777);
+ mkdir (TMPFS_PATH EARLY_PREFIX, 0777);
+ mkdir (TMPFS_PATH EARLY_PREFIX LIBDIR, 0777);
+ mkdir (TMPFS_PATH PKGLIBDIR, 0777);
if (symlink ("../..", TMPFS_PATH TMPFS_PATH)) {
if (errno != EEXIST) {
fprintf (stderr, "bootchart-collector failed to create a chroot at "
View
6 collector/common.h
@@ -35,10 +35,10 @@
#include <pthread.h>
/* Magic path we mount our tmpfs on, inside which we do everything */
-#define TMPFS_PATH "/lib/bootchart/tmpfs"
-#define PROC_PATH "/lib/bootchart/tmpfs/proc"
+#define TMPFS_PATH PKGLIBDIR "/tmpfs"
+#define PROC_PATH PKGLIBDIR "/tmpfs/proc"
/* where we lurk to get move mounted into the live system */
-#define MOVE_DEV_PATH "/dev/.bootchart"
+#define MOVE_DEV_PATH "/dev/." PROGRAM_PREFIX "bootchart" PROGRAM_SUFFIX
/* helpers */
#undef MAX
View
2  collector/dump.c
@@ -265,7 +265,7 @@ bootchart_find_running_pid (Arguments *opt_args)
continue;
link_target[len] = '\0';
- if (strstr (link_target, "bootchart-collector")) {
+ if (strstr (link_target, PROGRAM_PREFIX "bootchart" PROGRAM_SUFFIX "-collector")) {
FILE *argf;
int harmless = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.