diff --git a/CHANGELOG.md b/CHANGELOG.md index 91c245cd..a7fccfb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ plugin. The example application shows how. * Clixon can now be compiled and run on Apple Darwin. Thanks SUNET. ### Minor changes: +* Fixed DESTDIR make install/uninstall and break immediately on errors * Disabled key-value datastore. Enable with --with-keyvalue * Removed mandatory requirements for BACKEND, NETCONF, RESTCONF and CLI dirs. diff --git a/Makefile.in b/Makefile.in index 78e7791f..97e1f57b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -63,7 +63,7 @@ $(SUBDIRS): depend: for i in $(SUBDIRS) doc example docker; \ - do (cd $$i && $(MAKE) $(MFLAGS) depend); done + do (cd $$i && $(MAKE) $(MFLAGS) depend); done # template clixon.conf file clixon.conf.cpp: clixon.conf.cpp.cpp @@ -73,23 +73,23 @@ clixon.mk: clixon.mk.cpp $(CPP) -P -traditional-cpp -x assembler-with-cpp -Dprefix=$(prefix) -Dlocalstatedir=$(localstatedir) -Dsysconfdir=$(sysconfdir) -Ddatadir=$(datadir) -Dlibdir=$(libdir) $< > $@ install: clixon.conf.cpp clixon.mk + install -d -m 755 $(DESTDIR)$(datadir)/clixon install -m 755 clixon.conf.cpp $(DESTDIR)$(datadir)/clixon install -m 755 clixon.mk $(DESTDIR)$(datadir)/clixon for i in $(SUBDIRS) doc; \ - do (cd $$i && $(MAKE) $(MFLAGS) $@); done; \ - install -d -m 755 $(DESTDIR)$(datadir)/clixon + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \ echo "Install for compilation by: make install-include" install-include: for i in $(SUBDIRS) doc; \ - do (cd $$i && $(MAKE) $(MFLAGS) $@); done; \ + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done; \ echo "To install example app: cd example; make; make install" uninstall: for i in $(SUBDIRS) doc example docker; \ - do (cd $$i && $(MAKE) $(MFLAGS) $@); done; - rm -f $(datadir)/clixon/clixon.conf.cpp - rm -f $(datadir)/clixon/clixon.mk + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done; + rm -f $(DESTDIR)$(datadir)/clixon/clixon.conf.cpp + rm -f $(DESTDIR)$(datadir)/clixon/clixon.mk doc: cd $@; $(MAKE) $(MFLAGS) $@ diff --git a/apps/Makefile.in b/apps/Makefile.in index a67233bc..ae8b0a76 100644 --- a/apps/Makefile.in +++ b/apps/Makefile.in @@ -61,15 +61,15 @@ $(SUBDIRS): install-include: for i in $(SUBDIRS); \ - do (cd $$i ; $(MAKE) $(MFLAGS) $@); done; + do (cd $$i && $(MAKE) $(MFLAGS) $@||exit 1); done; install: for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done uninstall: for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done clean: for i in $(SUBDIRS); \ diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index f04dacdc..cbc2f059 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -107,9 +107,9 @@ install-lib: $(MYLIB) install -d $(DESTDIR)$(libdir)/clixon/plugins/backend uninstall: - rm -f $(sbindir)/$(APPL) - rm -f $(libdir)/$(MYLIB) - rm -f $(includedir)/clixon/* + rm -f $(DESTDIR)$(sbindir)/$(APPL) + rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* + rm -f $(DESTDIR)$(includedir)/clixon/* install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transaction.h install -d $(DESTDIR)$(includedir)/clixon diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 41afed5c..887ad08a 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -824,7 +824,7 @@ main(int argc, char **argv) if (yang_spec_main(h, stdout, printspec) < 0) goto done; - /* Set options: database dir aqnd yangspec (could be hidden in connect?)*/ + /* Set options: database dir and yangspec (could be hidden in connect?)*/ if (xmldb_setopt(h, "dbdir", clicon_xmldb_dir(h)) < 0) goto done; if (xmldb_setopt(h, "yangspec", clicon_dbspec_yang(h)) < 0) diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index e9e7c75d..42ffbcf2 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -108,9 +108,9 @@ install-include: clixon_cli.h clixon_cli_api.h install -m 644 $^ $(DESTDIR)$(includedir)/clixon uninstall: - rm -f $(bindir)/$(APPL) - rm -f $(libdir)/$(MYLIB) - rm -f $(includedir)/clixon/* + rm -f $(DESTDIR)$(bindir)/$(APPL) + rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* + rm -f $(DESTDIR)$(includedir)/clixon/* .SUFFIXES: .SUFFIXES: .c .o diff --git a/apps/netconf/Makefile.in b/apps/netconf/Makefile.in index 81e7cce6..31009f97 100644 --- a/apps/netconf/Makefile.in +++ b/apps/netconf/Makefile.in @@ -103,9 +103,9 @@ install-include: clixon_netconf.h install -m 644 $^ $(DESTDIR)$(includedir)/clixon uninstall: - rm -f $(bindir)/$(APPL) - rm -f $(libdir)/$(MYLIB) - rm -f $(includedir)/clixon/* + rm -f $(DESTDIR)$(bindir)/$(APPL) + rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* + rm -f $(DESTDIR)$(includedir)/clixon/* .SUFFIXES: .SUFFIXES: .c .o diff --git a/apps/restconf/Makefile.in b/apps/restconf/Makefile.in index ddc845d0..ca089853 100644 --- a/apps/restconf/Makefile.in +++ b/apps/restconf/Makefile.in @@ -89,7 +89,7 @@ install: $(APPL) install-include: uninstall: - rm -f $(wwwdir)/$(APPL) + rm -f $(DESTDIR)$(wwwdir)/$(APPL) .SUFFIXES: .SUFFIXES: .c .o diff --git a/datastore/Makefile.in b/datastore/Makefile.in index 8660a609..04591eb6 100644 --- a/datastore/Makefile.in +++ b/datastore/Makefile.in @@ -101,18 +101,18 @@ $(SUBDIRS): install-include: for i in $(SUBDIRS); \ - do (cd $$i ; $(MAKE) $(MFLAGS) $@); done; + do (cd $$i ; $(MAKE) $(MFLAGS) $@)||exit 1; done; install: $(APPL) install -d $(DESTDIR)$(bindir) install $(APPL) $(DESTDIR)$(bindir) for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done uninstall: - rm -f $(bindir)/$(APPL) + rm -f $(DESTDIR)$(bindir)/$(APPL) for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done clean: rm -f *.core $(APPL) $(APPOBJ) diff --git a/etc/Makefile.in b/etc/Makefile.in index e2b4db13..c6213afb 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -52,8 +52,10 @@ install: clixonrc install -m 755 clixonrc $(DESTDIR)$(sysconfdir) install-include: + rm -f $(DESTDIR)$(sysconfdir)/clixonrc uninstall: + depend: diff --git a/lib/Makefile.in b/lib/Makefile.in index 3d8fec1a..2bc0f9ef 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -55,20 +55,20 @@ $(SUBDIRS): (cd $@; $(MAKE) $(MFLAGS) all) install: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + for i in $(SUBDIRS); \ + do (cd $$i && $(MAKE) $(MFLAGS) $@); done install-include: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done; \ - (cd clixon; $(MAKE) $(MFLAGS) $@) + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \ + (cd clixon; $(MAKE) $(MFLAGS) $@) uninstall: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done config.status: configure - $(SHELL) config.status --recheck + $(SHELL) config.status --recheck clean: for i in $(SUBDIRS); \ diff --git a/lib/clixon/Makefile.in b/lib/clixon/Makefile.in index 8d4bf15a..a48f8c37 100644 --- a/lib/clixon/Makefile.in +++ b/lib/clixon/Makefile.in @@ -48,7 +48,7 @@ install-include: install -m 644 *.h $(DESTDIR)$(includedir)/clixon uninstall: - rm -f $(includedir)/clixon + rm -rf $(DESTDIR)$(includedir)/clixon clean: diff --git a/lib/src/Makefile.in b/lib/src/Makefile.in index 6ded16d8..67b1a086 100644 --- a/lib/src/Makefile.in +++ b/lib/src/Makefile.in @@ -187,7 +187,7 @@ install-lib: $(MYLIB) ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon.so uninstall: - rm -f $(libdir)/$(MYLIB) + rm -f $(DESTDIR)$(libdir)/$(MYLIBLINK)* TAGS: find . -name '*.[chyl]' -print | etags - diff --git a/test/lib.sh b/test/lib.sh index 46ee84c2..c9b8ac1f 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -1,13 +1,17 @@ #!/bin/bash testnr=0 -testnname= +testname= clixon_cf=/usr/local/etc/routing.xml # error and exit, arg is optional extra errmsg err(){ echo "Error in Test$testnr [$testname]:" - echo "Expected: $1" - echo "Received: $2" + if [ $# -gt 0 ]; then + echo "Expected: $1" + fi + if [ $# -gt 1 ]; then + echo "Received: $2" + fi exit $testnr } diff --git a/test/test_install.sh b/test/test_install.sh new file mode 100755 index 00000000..851eeae7 --- /dev/null +++ b/test/test_install.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Install test + +# include err() and new() functions +. ./lib.sh + +DIR=/tmp/clixoninstall + +new "Set up installdir $DIR" +rm -rf $DIR +mkdir $DIR + +new "Make DESTDIR install" +(cd ..; make DESTDIR=$DIR install) +if [ $? -ne 0 ]; then + err +fi + +new "Check installed files" +if [ ! -d $DIR/usr ]; then + err $DIR/usr +fi +if [ ! -d $DIR/www-data ]; then + err $DIR/www-data +fi +if [ ! -f $DIR/usr/local/share/clixon/clixon.mk ]; then + err $DIR/usr/local/share/clixon/clixon.mk +fi +if [ ! -f $DIR/usr/local/share/clixon/clixon.conf.cpp ]; then + err $DIR/usr/local/share/clixon/clixon.conf.cpp +fi +if [ ! -f $DIR/usr/local/share/clixon/clixon-config* ]; then + err $DIR/usr/local/share/clixon/clixon-config* +fi +if [ ! -h $DIR/usr/local/lib/libclixon.so ]; then + err $DIR/usr/local/lib/libclixon.so +fi +if [ ! -h $DIR/usr/local/lib/libclixon_backend.so ]; then + err $DIR/usr/local/lib/libclixon_backend.so +fi + +new "Make DESTDIR install include" +(cd ..; make DESTDIR=$DIR install-include) +if [ $? -ne 0 ]; then + err +fi +new "Check installed includes" +if [ ! -f $DIR/usr/local/include/clixon/clixon.h ]; then + err $DIR/usr/local/include/clixon/clixon.h +fi +new "Make DESTDIR uninstall" +(cd ..; make DESTDIR=$DIR uninstall) +if [ $? -ne 0 ]; then + err +fi + +new "Check remaining files" +f=$(find $DIR -type f) +if [ -n "$f" ]; then + err "$f" +fi + +new "Check remaining symlinks" +l=$(find $DIR -type l) +if [ -n "$l" ]; then + err "$l" +fi diff --git a/yang/Makefile.in b/yang/Makefile.in index 59bc5c6e..8642d2e4 100644 --- a/yang/Makefile.in +++ b/yang/Makefile.in @@ -54,7 +54,9 @@ distclean: clean rm -f Makefile *~ .depend install: $(YANGSPECS) - install -d $(DESTDIR)/yang + echo $(DESTDIR)$(datarootdir)/clixon/clixon.mk + echo $(DESTDIR)$(clixon_DATADIR) + install -d $(DESTDIR)$(clixon_DATADIR) install $(YANGSPECS) $(DESTDIR)$(clixon_DATADIR) uninstall: