Skip to contentSkip to conversation

storage-fixup: a Makefile

PATCH Applied Kel Modderman 2 participants 4 messages Oct 28, 2008 – Nov 17, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/5 storage-fixup: a Makefile

Add a Makefile for convenience of installation and preparing dist. tarball.

This could be handy for distributions/admins who want to deploy this workaround in a package.

---

Makefile new file +33 -0
@@ -0,0 +1,33 @@
+#!/usr/bin/make -f
+
+NAME    := storage-fixup
+FILES   := $(NAME) $(NAME).conf $(NAME).8 LICENSE Makefile
+VERSION := $(shell /bin/bash ./$(NAME) -V)
+BINDIR  := /usr/sbin
+ETCDIR  := /etc
+MANDIR  := /usr/share/man/man8
+MKDIR   := mkdir -p
+INSTALL := install
+
+all:
+	$(info Nothing to be done, ready for "$(MAKE) install" ...)
+
+%.gz: %
+	gzip -9 < $< > $@
+
+install: $(NAME).8.gz
+	$(MKDIR) $(DESTDIR)$(BINDIR)
+	$(INSTALL) -t $(DESTDIR)$(BINDIR) -m 755 $(NAME)
+	$(MKDIR) $(DESTDIR)$(ETCDIR)
+	$(INSTALL) -t $(DESTDIR)$(ETCDIR) -m 644 $(NAME).conf
+	$(MKDIR) $(DESTDIR)$(MANDIR)
+	$(INSTALL) -t $(DESTDIR)$(MANDIR) -m 644 $(NAME).8.gz
+
+clean:
+	$(RM) $(NAME).8.gz
+
+dist: clean
+	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
+		$(FILES) | tar -C.. -xf -
+	tar -czvf ../$(NAME)-$(VERSION).tar.gz -C.. $(NAME)-$(VERSION)/
+	$(RM) -r ../$(NAME)-$(VERSION)/

---

#1 lore raw

Makefile line 33

Quoted 5 lines · Kel Modderman
Makefile new file +5 -0
+dist: clean
+	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
+		$(FILES) | tar -C.. -xf -
+	tar -czvf ../$(NAME)-$(VERSION).tar.gz -C.. $(NAME)-$(VERSION)/
+	$(RM) -r ../$(NAME)-$(VERSION)/

Why untar and tar again?

Signature · 1 line
tejun
#2 lore raw
Quoted 9 lines · On Wednesday 12 November 2008 15:28:31 Tejun Heo wrote:

Makefile line 33

Quoted 5 lines · Kel Modderman
Makefile new file +5 -0
+dist: clean
+	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
+		$(FILES) | tar -C.. -xf -
+	tar -czvf ../$(NAME)-$(VERSION).tar.gz -C.. $(NAME)-$(VERSION)/
+	$(RM) -r ../$(NAME)-$(VERSION)/

Why untar and tar again?

Don't have a reason. This is probably better:
---
dist: clean

	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
		$(FILES) | gzip > ../$(NAME)-$(VERSION).tar.gz

---

Thanks, Kel.

#3 lore raw
Quoted 10 lines · Kel Modderman
Quoted 8 lines · On Wednesday 12 November 2008 15:28:31 Tejun Heo wrote:

Makefile line 33

Quoted 5 lines · Kel Modderman
Makefile new file +5 -0
+dist: clean
+	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
+		$(FILES) | tar -C.. -xf -
+	tar -czvf ../$(NAME)-$(VERSION).tar.gz -C.. $(NAME)-$(VERSION)/
+	$(RM) -r ../$(NAME)-$(VERSION)/

Why untar and tar again?

Quoted 5 lines

Don't have a reason. This is probably better:
---
dist: clean

	git-archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD \
		$(FILES) | gzip > ../$(NAME)-$(VERSION).tar.gz

Updated to create tarball in the source directory as you never know you'll have write access to .. && git-archive doesn't mind having extra files lying around anyway.

Thanks.

Signature · 1 line
tejun