Skip to content

Commit

Permalink
Don't use "mkdir" during install
Browse files Browse the repository at this point in the history
lahwran just showed up on irc and told us that he installed znc, but znc failed
to find any modules. The reason for this was his umask 077 which means that
"make install" installed stuff so that only root can access it.

The solution is do use "install -d" since that makes sure to ignore the
currently set umask.

However, google finds results which say that "install -d" might mess with stuff
of pre-existing directories when it shouldn't, so we must first test if the
directory already exists before calling install. Obviously, this makes our
Makefile a lot more readable. :-(

I didn't have time to test this properly, so stuff might break.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Nov 3, 2011
1 parent 73b980b commit a08ec52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ src/%.o: src/%.cpp Makefile
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MMD -MF .depend/$*.dep

install: znc $(LIBZNC)
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(includedir)/znc
mkdir -p $(DESTDIR)$(PKGCONFIGDIR)
mkdir -p $(DESTDIR)$(MODDIR)
mkdir -p $(DESTDIR)$(DATADIR)
test -d $(DESTDIR)$(bindir) || $(INSTALL) -d $(DESTDIR)$(bindir)
test -d $(DESTDIR)$(includedir)/znc || $(INSTALL) -d $(DESTDIR)$(includedir)/znc
test -d $(DESTDIR)$(PKGCONFIGDIR) || $(INSTALL) -d $(DESTDIR)$(PKGCONFIGDIR)
test -d $(DESTDIR)$(MODDIR) || $(INSTALL) -d $(DESTDIR)$(MODDIR)
test -d $(DESTDIR)$(DATADIR) || $(INSTALL) -d $(DESTDIR)$(DATADIR)
cp -R $(srcdir)/webskins $(DESTDIR)$(DATADIR)
find $(DESTDIR)$(DATADIR)/webskins -type d -exec chmod 0755 '{}' \;
find $(DESTDIR)$(DATADIR)/webskins -type f -exec chmod 0644 '{}' \;
Expand All @@ -119,7 +119,7 @@ install: znc $(LIBZNC)
$(INSTALL_DATA) znc.pc $(DESTDIR)$(PKGCONFIGDIR)
@$(MAKE) -C modules install DESTDIR=$(DESTDIR);
if test -n "$(LIBZNC)"; then \
mkdir -p $(DESTDIR)$(LIBZNCDIR) || exit 1 ; \
test -d $(DESTDIR)$(LIBZNCDIR) || $(INSTALL) -d $(DESTDIR)$(LIBZNCDIR) || exit 1 ; \
$(INSTALL_PROGRAM) $(LIBZNC) $(DESTDIR)$(LIBZNCDIR) || exit 1 ; \
fi
@$(MAKE) -C man install DESTDIR=$(DESTDIR)
Expand Down
2 changes: 1 addition & 1 deletion man/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ clean:
-rm -f $(MAN1)

install: $(MAN1)
mkdir -p $(DESTDIR)$(mandir)/man1
test -d $(DESTDIR)$(mandir)/man1 || $(INSTALL) -d $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(MAN1) $(DESTDIR)$(mandir)/man1

uninstall:
Expand Down
8 changes: 3 additions & 5 deletions modules/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ install: all install_datadir

install_datadir:
rm -rf $(DESTDIR)$(DATADIR)/modules
mkdir -p $(DESTDIR)$(MODDIR)
mkdir -p $(DESTDIR)$(DATADIR)/modules
test -d $(DESTDIR)$(MODDIR) || $(INSTALL) -d $(DESTDIR)$(MODDIR)
test -d $(DESTDIR)$(DATADIR)/modules || $(INSTALL) -d $(DESTDIR)$(DATADIR)/modules
rm -rf $(DESTDIR)$(MODDIR)/*.so
mkdir -p $(DESTDIR)$(DATADIR)/modules
cp -R $(srcdir)/data/* $(DESTDIR)$(DATADIR)/modules
if test "@EXTRA@" = "yes" ; then \
cp -R $(srcdir)/extra/data/* $(DESTDIR)$(DATADIR)/modules ; \
Expand All @@ -116,8 +115,7 @@ clean:
rm -rf $(CLEAN)

%.o: %.cpp Makefile
@mkdir -p .depend
@mkdir -p extra
@mkdir -p .depend extra
$(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
$(Q)$(CXX) $(MODFLAGS) -c -o $@ $< $($(notdir $(basename $@))CXXFLAGS) -MMD -MF .depend/$(notdir $@).dep

Expand Down

0 comments on commit a08ec52

Please sign in to comment.