From e99c33833ec0327e1c071efd526f86afc5e7bf69 Mon Sep 17 00:00:00 2001
From: Mike Hibler <mike@flux.utah.edu>
Date: Tue, 25 Jul 2006 16:44:31 +0000
Subject: [PATCH] Add client-tarball target to create a tarball of
 scripts/binaries to install on an existing image.  Implemented by doing a
 client-install into an empty directory via DESTDIR.

---
 GNUmakefile.in                     | 20 +++++++++++++++++++-
 event/program-agent/GNUmakefile.in |  1 +
 tmcd/freebsd/init/4/GNUmakefile.in |  2 +-
 tmcd/freebsd/init/5/GNUmakefile.in |  2 +-
 tmcd/freebsd/init/6/GNUmakefile.in |  2 +-
 tmcd/freebsd/init/GNUmakefile.in   | 13 ++++++++-----
 6 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 80e6bb9a9c..a0ea206a04 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -36,7 +36,7 @@ install:
 	@echo "Choose tipserv-install for dedicated tip server machines."
 
 #
-# For installation on boss node (okay, paper).
+# For installation on boss node
 # 
 boss-install:	install-schemacheck install-sitevarscheck install-dbfillcheck \
 		install-subdirs install-mkdirs install-setbuildinfo
@@ -130,6 +130,7 @@ tipserv-install:
 
 client-mkdirs:
 	-mkdir -p $(DESTDIR)$(CLIENT_BINDIR)
+	-mkdir -p $(DESTDIR)$(CLIENT_MANDIR)
 
 client:
 	@$(MAKE) -C lib/libtb client
@@ -158,6 +159,23 @@ endif
 	@$(MAKE) -C sensors client-install
 	@$(MAKE) -C tmcd client-install
 
+TARBALLDESTDIR = /var/tmp/emulab-client
+
+client-tarball:
+	@if [ `id -u` -ne 0 ]; then \
+	    echo '*** Must run as root!'; \
+	    false; \
+	fi
+	@if [ -d "$(TARBALLDESTDIR)" ]; then \
+	    echo "$(TARBALLDESTDIR) already exists."; \
+	    echo "Remove it and try again."; \
+	    false; \
+	fi
+	echo "Building and installing client-side in $(TARBALLDESTDIR)..."
+	DESTDIR=$(TARBALLDESTDIR) $(MAKE) client-install
+	echo "Creating tarball..."
+	tar czf emulab-client.tar.gz -C $(TARBALLDESTDIR) .
+
 destdircheck:
 	@if [ -z "$(DESTDIR)" ]; then \
 	    echo "You must define DESTDIR for this target!"; \
diff --git a/event/program-agent/GNUmakefile.in b/event/program-agent/GNUmakefile.in
index 1d578fb3ab..6714485a03 100644
--- a/event/program-agent/GNUmakefile.in
+++ b/event/program-agent/GNUmakefile.in
@@ -58,6 +58,7 @@ client: $(PROGRAMS)
 client-install: client
 	$(INSTALL_PROGRAM) program-agent$(EXE) $(DESTDIR)$(CLIENT_BINDIR)/program-agent$(EXE)
 	chmod u+s-w $(DESTDIR)$(CLIENT_BINDIR)/program-agent
+	-mkdir -p $(DESTDIR)$(CLIENT_MANDIR)/man8
 	$(INSTALL) -m 644 $(SRCDIR)/program-agent.8 $(DESTDIR)$(CLIENT_MANDIR)/man8/program-agent.8
 
 clean:
diff --git a/tmcd/freebsd/init/4/GNUmakefile.in b/tmcd/freebsd/init/4/GNUmakefile.in
index 01db0e84b0..6bbb123cfe 100644
--- a/tmcd/freebsd/init/4/GNUmakefile.in
+++ b/tmcd/freebsd/init/4/GNUmakefile.in
@@ -22,7 +22,7 @@ init: init.c pathnames.h
 install:
 
 client-install: client
-	install -s -o root -g wheel -m 500 -fschg -b -B.bak init /sbin/init
+	install -s -o root -g wheel -m 500 -fschg -b -B.bak init $(DESTDIR)/sbin/init
 
 clean:	
 	rm -f *.o core init
diff --git a/tmcd/freebsd/init/5/GNUmakefile.in b/tmcd/freebsd/init/5/GNUmakefile.in
index 0b68e02645..a4f319e492 100644
--- a/tmcd/freebsd/init/5/GNUmakefile.in
+++ b/tmcd/freebsd/init/5/GNUmakefile.in
@@ -22,7 +22,7 @@ init: init.c pathnames.h
 install:
 
 client-install: client
-	install -s -o root -g wheel -m 500 -fschg -b -B.bak init /sbin/init
+	install -s -o root -g wheel -m 500 -fschg -b -B.bak init $(DESTDIR)/sbin/init
 
 clean:	
 	rm -f *.o core init
diff --git a/tmcd/freebsd/init/6/GNUmakefile.in b/tmcd/freebsd/init/6/GNUmakefile.in
index 2decfbb763..b0f62e06aa 100644
--- a/tmcd/freebsd/init/6/GNUmakefile.in
+++ b/tmcd/freebsd/init/6/GNUmakefile.in
@@ -22,7 +22,7 @@ init: init.c pathnames.h
 install:
 
 client-install: client
-	install -s -o root -g wheel -m 500 -fschg -b -B.bak init /sbin/init
+	install -s -o root -g wheel -m 500 -fschg -b -B.bak init $(DESTDIR)/sbin/init
 
 clean:	
 	rm -f *.o core init
diff --git a/tmcd/freebsd/init/GNUmakefile.in b/tmcd/freebsd/init/GNUmakefile.in
index 2e39a2cb01..52fc594705 100644
--- a/tmcd/freebsd/init/GNUmakefile.in
+++ b/tmcd/freebsd/init/GNUmakefile.in
@@ -14,15 +14,15 @@ include $(OBJDIR)/Makeconf
 FBSDVERSION   := $(shell uname -v | sed -e 's/FreeBSD \([0-9]\).*/FreeBSD\1/')
 
 ifeq ($(FBSDVERSION),FreeBSD4)
-SUBDIR	       = 4
+FSUBDIR	       = 4
 endif
 ifeq ($(FBSDVERSION),FreeBSD5)
-SUBDIR	       = 5
+FSUBDIR	       = 5
 endif
 ifeq ($(FBSDVERSION),FreeBSD6)
-SUBDIR	       = 6
+FSUBDIR	       = 6
 endif
-SUBDIRS	       = $(SUBDIR)
+SUBDIRS	       = $(FSUBDIR)
 
 all:
 
@@ -30,8 +30,11 @@ include $(TESTBED_SRCDIR)/GNUmakerules
 
 install:
 
+client-mkdirs:
+	-mkdir -p $(DESTDIR)/sbin
+
 client:		client-subdirs
-client-install: client client-install-subdirs
+client-install: client client-mkdirs client-install-subdirs
 
 clean:		clean-subdirs
 distclean:	distclean-subdirs
-- 
GitLab