Fixed DESTDIR make install/uninstall and break immediately on errors

This commit is contained in:
Olof hagsand 2017-11-22 22:21:12 +01:00
parent 496754f5c5
commit 96a7ec86f0
16 changed files with 115 additions and 39 deletions

View file

@ -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.

View file

@ -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) $@

View file

@ -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); \

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -89,7 +89,7 @@ install: $(APPL)
install-include:
uninstall:
rm -f $(wwwdir)/$(APPL)
rm -f $(DESTDIR)$(wwwdir)/$(APPL)
.SUFFIXES:
.SUFFIXES: .c .o

View file

@ -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)

View file

@ -52,8 +52,10 @@ install: clixonrc
install -m 755 clixonrc $(DESTDIR)$(sysconfdir)
install-include:
rm -f $(DESTDIR)$(sysconfdir)/clixonrc
uninstall:
depend:

View file

@ -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); \

View file

@ -48,7 +48,7 @@ install-include:
install -m 644 *.h $(DESTDIR)$(includedir)/clixon
uninstall:
rm -f $(includedir)/clixon
rm -rf $(DESTDIR)$(includedir)/clixon
clean:

View file

@ -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 -

View file

@ -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
}

67
test/test_install.sh Executable file
View file

@ -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

View file

@ -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: