Skip to contentSkip to conversation

btrfs-progs: Add uninstall targets to Makefiles

PATCH New Nils Steinger 3 participants 10 messages Jun 20, 2014 – Jul 25, 2014

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

PATCH 1/1 btrfs-progs: Add uninstall targets to Makefiles

I compiled and installed the btrfs-progs from the git repo on several systems, but later decided to switch back to the version from Debian's package repository.
The Makefile did not contain an 'uninstall' target to complement 'install', so I created one that reverses all changes made by 'install' (both in the main and Documentation Makefiles).

Nils Steinger (1):
btrfs-progs: Add uninstall targets to Makefiles.

 Documentation/Makefile | 4 ++++
 Makefile               | 9 +++++++++
 2 files changed, 13 insertions(+)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 btrfs-progs: Add uninstall targets to Makefiles.

---
 Documentation/Makefile | 4 ++++
 Makefile               | 9 +++++++++
 2 files changed, 13 insertions(+)
Documentation/Makefile +4 -0
index 45299bb..5c9780b 100644
@@ -76,6 +76,10 @@ install-man: man
 	$(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
 	$(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)
 
+uninstall:
+	cd $(DESTDIR)$(man8dir); rm -f btrfs-check.8.gz $(GZ_MAN8)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
+
 clean:
 	$(RM) *.xml *.xml+ *.8 *.8.gz
 
Makefile +9 -0
index 76565e8..4cafa37 100644
@@ -257,6 +257,15 @@ $(INSTALLDIRS):
 	@echo "Making install in $(patsubst install-%,%,$@)"
 	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
 
+uninstall:
+	$(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+	cd $(DESTDIR)$(incdir); rm -f $(headers)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+	cd $(DESTDIR)$(libdir); rm -f $(lib_links)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
+	cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)
+
 ifneq ($(MAKECMDGOALS),clean)
 -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
 endif
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH] btrfs-progs: Add uninstall targets to Makefiles.

Hi Nils,

Quoted 11 lines · Nils Steinger
---
  Documentation/Makefile | 4 ++++
  Makefile               | 9 +++++++++
  2 files changed, 13 insertions(+)
Documentation/Makefile +0 -0
index 45299bb..5c9780b 100644

Documentation/Makefile install-man: man · line 82

Quoted 7 lines
Documentation/Makefile +4 -0
@@ -76,6 +76,10 @@ install-man: man
  	$(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
  	$(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)
 
+uninstall:
+	cd $(DESTDIR)$(man8dir); rm -f btrfs-check.8.gz $(GZ_MAN8)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
+

This code snippet looks good.

Quoted 8 lines
Documentation/Makefile +0 -0
  clean:
  	$(RM) *.xml *.xml+ *.8 *.8.gz
 
Makefile +0 -0
index 76565e8..4cafa37 100644

Makefile $(INSTALLDIRS): · line 264

Quoted 8 lines
Makefile +5 -0
@@ -257,6 +257,15 @@ $(INSTALLDIRS):
  	@echo "Making install in $(patsubst install-%,%,$@)"
  	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
 
+uninstall:
+	$(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+	cd $(DESTDIR)$(incdir); rm -f $(headers)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+	cd $(DESTDIR)$(libdir); rm -f $(lib_links)

You forgot to remove $(libs) here.

Thanks,
Satoru

Quoted 8 lines
Makefile +4 -0
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
+	cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)
+
  ifneq ($(MAKECMDGOALS),clean)
  -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
  endif
#3 lore raw

PATCH v2 1/1 btrfs-progs: Add uninstall targets to Makefiles.

---

v2: As Satoru Takeuchi pointed out, I forgot to remove $(libs) in the main Makefile.

 Documentation/Makefile | 4 ++++
 Makefile               | 9 +++++++++
 2 files changed, 13 insertions(+)
Documentation/Makefile +4 -0
index 45299bb..5c9780b 100644
@@ -76,6 +76,10 @@ install-man: man
 	$(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
 	$(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)
 
+uninstall:
+	cd $(DESTDIR)$(man8dir); rm -f btrfs-check.8.gz $(GZ_MAN8)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
+
 clean:
 	$(RM) *.xml *.xml+ *.8 *.8.gz
 
Makefile +9 -0
index 76565e8..fe6a2f8 100644
@@ -257,6 +257,15 @@ $(INSTALLDIRS):
 	@echo "Making install in $(patsubst install-%,%,$@)"
 	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
 
+uninstall:
+	$(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+	cd $(DESTDIR)$(incdir); rm -f $(headers)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+	cd $(DESTDIR)$(libdir); rm -f $(lib_links) $(libs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
+	cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)
+
 ifneq ($(MAKECMDGOALS),clean)
 -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
 endif
Signature · 1 line
1.9.1
Reviewed-by on v2 1/1
#4 lore raw

Re: [PATCH v2] btrfs-progs: Add uninstall targets to Makefiles.

Quoted 1 line · Nils Steinger
Quoted 45 lines

---

v2: As Satoru Takeuchi pointed out, I forgot to remove $(libs) in the main Makefile.

  Documentation/Makefile | 4 ++++
  Makefile               | 9 +++++++++
  2 files changed, 13 insertions(+)
Documentation/Makefile +4 -0
index 45299bb..5c9780b 100644
@@ -76,6 +76,10 @@ install-man: man
  	$(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
  	$(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)
 
+uninstall:
+	cd $(DESTDIR)$(man8dir); rm -f btrfs-check.8.gz $(GZ_MAN8)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
+
  clean:
  	$(RM) *.xml *.xml+ *.8 *.8.gz
 
Makefile +9 -0
index 76565e8..fe6a2f8 100644
@@ -257,6 +257,15 @@ $(INSTALLDIRS):
  	@echo "Making install in $(patsubst install-%,%,$@)"
  	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
 
+uninstall:
+	$(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+	cd $(DESTDIR)$(incdir); rm -f $(headers)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+	cd $(DESTDIR)$(libdir); rm -f $(lib_links) $(libs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
+	cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)
+
  ifneq ($(MAKECMDGOALS),clean)
  -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
  endif
#5 lore raw

Re: [PATCH v2] btrfs-progs: Add uninstall targets to Makefiles.

In reply to Nils Steinger

Makefile $(INSTALLDIRS): · line 267

Quoted 5 lines · Nils Steinger
Makefile +3 -0
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)

I don't think it's right to remove the systemwide directories: bindir, libdir and man8dir. There rest are btrfs subdirs (eg. incdir), that's fine.

#6 lore raw

Re: [PATCH v2] btrfs-progs: Add uninstall targets to Makefiles.

Quoted 10 lines · David Sterba

Makefile $(INSTALLDIRS): · line 267

Quoted 5 lines · Nils Steinger
Makefile +3 -0
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)

I don't think it's right to remove the systemwide directories: bindir, libdir and man8dir. There rest are btrfs subdirs (eg. incdir), that's fine.

On my system, man8dir didn't exist prior to the installation, so I thought it would be reasonable to have the uninstallation routine remove it. bindir and libdir will exist by default on most systems, so that's a different case…
So, should we really keep the directories around, even if they were created by the installation and are now empty (if they aren't, they won't be removed anyway)?

#7 lore raw

Re: [PATCH v2] btrfs-progs: Add uninstall targets to Makefiles.

Quoted 12 lines · Nils Steinger
Quoted 10 lines · David Sterba

Makefile $(INSTALLDIRS): · line 267

Quoted 5 lines · Nils Steinger
Makefile +3 -0
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir)
 
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir)

I don't think it's right to remove the systemwide directories: bindir, libdir and man8dir. There rest are btrfs subdirs (eg. incdir), that's fine.

Quoted 3 lines

On my system, man8dir didn't exist prior to the installation, so I thought it would be reasonable to have the uninstallation routine remove it.

According to the FHS [1] the manX directories do not have to exsit, so this part shall stay.

Quoted 5 lines

bindir and libdir will exist by default on most systems, so that's a different case…
So, should we really keep the directories around, even if they were created by the installation and are now empty (if they aren't, they won't be removed anyway)?

But we don't track if the directories were created by the installation or not. Normally the directories would exist anyway (/usr or /usr/local as prefix) and are expected to exist at the locations. Installation to arbitraty directory works, but managing the directories is IMO up to the user.

So are you ok with keeping bindir and libdir only (ie. removing only man8dir)?

Thanks.

[1] http://www.pathname.com/fhs/pub/fhs-2.3.html#USRSHAREMANMANUALPAGES
and then note #32

author
#8 lore raw

PATCH v3 1/1 btrfs-progs: Add uninstall targets to Makefiles.

From: Nils Steinger <[email protected]>

---

v2: As Satoru Takeuchi pointed out, I forgot to remove $(libs) in the main Makefile.

v3: David Sterba suggested not to remove the $(bindir) and $(libdir), since those might be needed by other programs, even if the btrfs uninstallation leaves them empty.

 Documentation/Makefile | 4 ++++
 Makefile               | 7 +++++++
 2 files changed, 11 insertions(+)
Documentation/Makefile +4 -0
index 45299bb..5c9780b 100644
@@ -76,6 +76,10 @@ install-man: man
 	$(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir)
 	$(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)
 
+uninstall:
+	cd $(DESTDIR)$(man8dir); rm -f btrfs-check.8.gz $(GZ_MAN8)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(man8dir)
+
 clean:
 	$(RM) *.xml *.xml+ *.8 *.8.gz
 
Makefile +7 -0
index 76565e8..de5bd9e 100644
@@ -257,6 +257,13 @@ $(INSTALLDIRS):
 	@echo "Making install in $(patsubst install-%,%,$@)"
 	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
 
+uninstall:
+	$(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+	cd $(DESTDIR)$(incdir); rm -f $(headers)
+	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+	cd $(DESTDIR)$(libdir); rm -f $(lib_links) $(libs)
+	cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+
 ifneq ($(MAKECMDGOALS),clean)
 -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
 endif
Signature · 1 line
1.9.1
#9 lore raw

Re: [PATCH v2] btrfs-progs: Add uninstall targets to Makefiles.

In reply to David Sterba

I apologize for the long hiatus.

Quoted 17 lines · David Sterba
Quoted 3 lines · Nils Steinger

On my system, man8dir didn't exist prior to the installation, so I thought it would be reasonable to have the uninstallation routine remove it.

According to the FHS [1] the manX directories do not have to exsit, so this part shall stay.

[1] http://www.pathname.com/fhs/pub/fhs-2.3.html#USRSHAREMANMANUALPAGES
and then note #32

Quoted 5 lines

bindir and libdir will exist by default on most systems, so that's a different case…
So, should we really keep the directories around, even if they were created by the installation and are now empty (if they aren't, they won't be removed anyway)?

Quoted 8 lines

But we don't track if the directories were created by the installation or not. Normally the directories would exist anyway (/usr or /usr/local as prefix) and are expected to exist at the locations. Installation to arbitraty directory works, but managing the directories is IMO up to the user.

So are you ok with keeping bindir and libdir only (ie. removing only man8dir)?

Yes, that should be sensible. I've updated my patch accordingly and resubmitted it few minutes ago.

Regards,
Nils