[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: add run script for easier uninstalled usage
From: |
Eric Blake |
Subject: |
[PATCH] maint: add run script for easier uninstalled usage |
Date: |
Mon, 24 Feb 2020 15:45:06 -0600 |
* run.in: New file.
* configure.ac (AC_CONFIG_FILES): Use it to build 'run'.
* Makefile.am (noinst_SCRIPTS): Include template in tarball.
* HACKING (Running an Uninstalled Poke): Document it.
* .gitignore: Exempt new file.
---
My first poke patch ;) Let me know if I need to sign a copyright
document (I've done it for plenty of other GNU programs...)
Ideas here borrow heavily from libnbd:
https://github.com/libguestfs/libnbd/blob/master/run.in
.gitignore | 1 +
ChangeLog | 9 +++++++++
HACKING | 13 ++++++-------
Makefile.am | 2 ++
configure.ac | 2 ++
run.in | 45 +++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 65 insertions(+), 7 deletions(-)
create mode 100644 run.in
diff --git a/.gitignore b/.gitignore
index 4bbe0d1c..b3319f65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,6 +53,7 @@ config.h.in
/GNUmakefile
/maint.mk
/man/poke.1
+/run
/src/pkl-asm.pkc
/src/pkl-gen.pkc
/src/pkl-lex.c
diff --git a/ChangeLog b/ChangeLog
index 4f3e9f1c..65c6ee57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-24 Eric Blake <address@hidden>
+
+ maint: add run script for easier uninstalled usage
+ * run.in: New file.
+ * configure.ac (AC_CONFIG_FILES): Use it to build 'run'.
+ * Makefile.am (noinst_SCRIPTS): Include template in tarball.
+ * HACKING (Running an Uninstalled Poke): Document it.
+ * .gitignore: Exempt new file.
+
2020-02-24 Jose E. Marchesi <address@hidden>
* HACKING (Running and Uninstalled Poke): Update to cover
diff --git a/HACKING b/HACKING
index 18859ce7..4550430f 100644
--- a/HACKING
+++ b/HACKING
@@ -306,18 +306,17 @@ for more information.
Running an Uninstalled Poke
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Once poke is compiled, you can run it before installing by defining
-the ``POKEDATADIR`` environment variable to point to the ``src/``
-directory in the sources tree, and ``POKEPICKLESDIR`` to point to the
-``pickles/`` directory in the sources tree. Another variable to set
-is ``POKESTYLESDIR``.
+Once poke is compiled, you can run it before installing by using the
+``run`` script built into the root of your build tree; this takes care
+of setting variables such as ``PATH``, ``POKEDATADIR``,
+``POKESTYLESDIR``, and ``POKEPICKLESDIR`` to point at appropriate
+locations.
For example::
$ pwd
/home/jemarch/gnu/hacks/poke/build/
- $ export POKEDATADIR=../src POKEPICKLESDIR=../pickles POKESTYLESDIR=../etc
- $ ./src/poke
+ $ ./run poke
Continuous Integration
~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Makefile.am b/Makefile.am
index 7d293a4c..281ad979 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = jitter lib pickles src doc man testsuite etc po
+noinst_SCRIPTS = run
+
# This (and the accompanying AC_SUBST of WITH_JITTER) is to be removed
# as soon as we bump to a Jitter version not requiring --with-jitter
# if it is installed in a standard location.
diff --git a/configure.ac b/configure.ac
index a9b08a24..5e27d01a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,8 @@ AC_CONFIG_FILES(Makefile
po/Makefile.in
etc/Makefile
testsuite/Makefile)
+AC_CONFIG_FILES([run],
+ [chmod +x,-w run])
AC_OUTPUT
dnl Report warnings
diff --git a/run.in b/run.in
new file mode 100644
index 00000000..7254412a
--- /dev/null
+++ b/run.in
@@ -0,0 +1,45 @@
+#!/bin/sh
+# 'run' an uninstalled poke -*- sh-mode -*-
+
+# Copyright (C) 2020 Eric Blake
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# All child processes of this script will run with your just-built but
+# still uninstalled poke. For example:
+#
+# ./run poke
+#
+# or:
+#
+# ./run my_script # where my_script in turn calls poke
+
+s=$(cd @abs_srcdir@ && pwd)
+b=$(cd @abs_builddir@ && pwd)
+
+# setup to run uninstalled poke
+PATH=$b/src:$PATH
+POKEDATADIR=$s/src
+POKEPICKLESDIR=$s/pickles
+POKESTYLESDIR=$s/etc
+export PATH POKEDATADIR POKEPICKLESDIR POKESTYLESDIR
+
+# Cheap way to find some use-after-free and uninit read problems with glibc
+MALLOC_CHECK_=1
+random_val="$(@AWK@ 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
+MALLOC_PERTURB_=$random_val
+export MALLOC_CHECK_ MALLOC_PERTURB_
+
+# Now run the program
+exec "$@"
--
2.24.1
- [PATCH] maint: add run script for easier uninstalled usage,
Eric Blake <=