Add install script and rule v0.1.1
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 17 Oct 2017 11:52:56 +0000 (13:52 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 17 Oct 2017 11:52:56 +0000 (13:52 +0200)
.vscode/launch.json
Makefile
conf.d/etc/profile.d/xds-gdb.sh [new file with mode: 0644]
scripts/install.sh [new file with mode: 0755]

index d70ddec..5fc6380 100644 (file)
@@ -24,7 +24,7 @@
             "env": {
                 "GOPATH": "${workspaceRoot}/../../../..:${env:GOPATH}"
             },
-            "args": ["-x", "/tmp/xds-gdb.env", "-nx"],
+            "args": ["-x", "${workspaceRoot}/__config/gdb-on-target.ini", "-nx"],
             "showLog": false
         },
           {
index ed58a29..f256c1b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -106,6 +106,15 @@ package-all:
        GOOS=darwin GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
        make -f $(ROOT_SRCDIR)/Makefile clean
 
+.PHONY: install
+install:
+       @test -e $(LOCAL_BINDIR)/$(TARGET)$(EXT) || { echo "Please execute first: make all\n"; exit 1; }
+       export DESTDIR=$(DESTDIR) && $(ROOT_SRCDIR)/scripts/install.sh
+
+.PHONY: uninstall
+uninstall:
+       export DESTDIR=$(DESTDIR) && $(ROOT_SRCDIR)/scripts/install.sh uninstall
+
 vendor: tools/glide glide.yaml
        ./tools/glide install --strip-vendor
 
@@ -122,9 +131,11 @@ tools/glide:
 help:
        @echo "Main supported rules:"
        @echo "  all               (default)"
+       @echo "  build"
        @echo "  release"
        @echo "  clean"
        @echo "  package"
+       @echo "  install / uninstall"
        @echo "  distclean"
        @echo ""
        @echo "Influential make variables:"
diff --git a/conf.d/etc/profile.d/xds-gdb.sh b/conf.d/etc/profile.d/xds-gdb.sh
new file mode 100644 (file)
index 0000000..91662d2
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#----------  AGL xds-exec tool options Start ---------"
+[ ":${PATH}:" != *":%%XDS_INSTALL_BIN_DIR%%:"* ] && export PATH=%%XDS_INSTALL_BIN_DIR%%:${PATH}
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755 (executable)
index 0000000..7541915
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Install XDS gdb
+
+DESTDIR=${DESTDIR:-/opt/AGL/xds/gdb}
+
+ROOT_SRCDIR=$(cd $(dirname "$0")/.. && pwd)
+
+install() {
+    mkdir -p ${DESTDIR} && cp ${ROOT_SRCDIR}/bin/* ${DESTDIR} || exit 1
+
+    FILE=/etc/profile.d/xds-gdb.sh
+    sed -e "s;%%XDS_INSTALL_BIN_DIR%%;${DESTDIR};g" ${ROOT_SRCDIR}/conf.d/${FILE} > ${FILE} || exit 1
+}
+
+uninstall() {
+    rm -rf "${DESTDIR}"
+    rm -f /etc/profile.d/xds-gdb.sh
+}
+
+if [ "$1" == "uninstall" ]; then
+    echo -n "Are-you sure you want to remove ${DESTDIR} [y/n]? "
+    read answer
+    if [ "${answer}" = "y" ]; then
+        uninstall
+        echo "xds-gdb sucessfully uninstalled."
+    else
+        echo "Uninstall canceled."
+    fi
+else
+    install
+fi