PRIV: Add helper tool.
authorzrj <rimvydas.jasinskas@gmail.com>
Fri, 12 Apr 2019 07:55:29 +0000 (10:55 +0300)
committerzrj <zrj@dragonflybsd.org>
Fri, 12 Apr 2019 08:15:15 +0000 (11:15 +0300)
To speed up vendor updates.

tools/tools/README
tools/tools/unpriv_base/unpriv_base.sh [new file with mode: 0644]

index a9409ac..3039d58 100644 (file)
@@ -21,6 +21,7 @@ scsi-defects  Get at the primary or grown defect list of a SCSI disk.
 splitpatch     Python script to split a large patch file into independent
                patches.  Default name convention is compatible with
                the patch framework.
+unpriv_base    Crates symlinks for private base libraries and headers.
 vop_table      Generates a HTML document that shows all the VOP's in
                the kernel.
 wlandebug      Manipulate netproto/802_11 debug flags symbolically.
diff --git a/tools/tools/unpriv_base/unpriv_base.sh b/tools/tools/unpriv_base/unpriv_base.sh
new file mode 100644 (file)
index 0000000..03c0545
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]
+then
+       echo "$0 [unpriv] [restore] <DESTDIR>" >&2
+       echo "   create/remove conveniece symlinks for base private" >&2
+       echo "   libraries and headers:" >&2
+       echo "      libedit ncurses openssl" >&2
+       echo "   if new software package needs runtime for tests or does" >&2
+       echo "   not respect -rpath /lib/priv -rpath /usr/lib/priv flags" >&2
+       echo "   use export LD_LIBRARY_PATH=/lib/priv:/usr/lib/priv"
+       exit 1
+fi
+
+DESTDIR=$2
+
+set -e
+
+if [ "$1" == "unpriv" ]
+then
+       echo "Creating symlinks:"
+       ln -sv priv/ncurses  "$DESTDIR"/usr/include/ncurses
+       ln -sv priv/openssl  "$DESTDIR"/usr/include/openssl
+       ln -sv priv/readline "$DESTDIR"/usr/include/readline
+       # ncurses
+       ln -sv priv/libprivate_ncurses.a   "$DESTDIR"/usr/lib/libncurses.a
+       ln -sv priv/libprivate_ncurses.so  "$DESTDIR"/usr/lib/libncurses.so
+       ln -sv priv/libprivate_ncursesw.a  "$DESTDIR"/usr/lib/libncursesw.a
+       ln -sv priv/libprivate_ncursesw.so "$DESTDIR"/usr/lib/libncursesw.so
+       # LibreSSL
+       ln -sv priv/libprivate_crypto.a  "$DESTDIR"/usr/lib/libcrypto.a
+       ln -sv priv/libprivate_crypto.so "$DESTDIR"/usr/lib/libcrypto.so
+       ln -sv priv/libprivate_ssl.a     "$DESTDIR"/usr/lib/libssl.a
+       ln -sv priv/libprivate_ssl.so    "$DESTDIR"/usr/lib/libssl.so
+       # libedit
+       ln -sv priv/libprivate_edit.a  "$DESTDIR"/usr/lib/libedit.a
+       ln -sv priv/libprivate_edit.so "$DESTDIR"/usr/lib/libedit.so
+       # warn
+       echo "Done. Later DO NOT forget to run '$0 restore'"
+fi
+
+if [ "$1" == "restore" ]
+then
+       echo "Cleaning symlinks:"
+       rm -fv "$DESTDIR"/usr/include/ncurses
+       rm -fv "$DESTDIR"/usr/include/openssl
+       rm -fv "$DESTDIR"/usr/include/readline
+       # ncurses
+       rm -fv "$DESTDIR"/usr/lib/libncurses.a
+       rm -fv "$DESTDIR"/usr/lib/libncurses.so
+       rm -fv "$DESTDIR"/usr/lib/libncursesw.a
+       rm -fv "$DESTDIR"/usr/lib/libncursesw.so
+       # LibreSSL
+       rm -fv "$DESTDIR"/usr/lib/libcrypto.a
+       rm -fv "$DESTDIR"/usr/lib/libcrypto.so
+       rm -fv "$DESTDIR"/usr/lib/libssl.a
+       rm -fv "$DESTDIR"/usr/lib/libssl.so
+       # libedit
+       rm -fv "$DESTDIR"/usr/lib/libedit.a
+       rm -fv "$DESTDIR"/usr/lib/libedit.so
+       # warn
+       echo "Done."
+fi