Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
scripts: expose the package name to the scripts (lua and shell)
Baptiste Daroussin committed 5 years ago
commit c4f96ea7050725e062001f788c19e74df7af7b01
parent 5e291f8
5 files changed +12 -2
modified NEWS
@@ -1,3 +1,6 @@
+
Changes from 1.16.99.3 to 1.16.99.4
+
- expose the name of the packages to its scripts lua and shell
+

Changes from 1.16.99.2 to 1.16.99.3
- lua update to 5.4.2
- pkg repo accept now all supported formats mixed without config
modified docs/pkg-lua-script.5
@@ -11,7 +11,7 @@
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
-
.Dd July 17, 2020
+
.Dd March 26, 2021
.Dt PKG-LUA-SCRIPT 5
.Os
.Sh NAME
@@ -80,6 +80,8 @@ has been disabled.
.Pp
The following variables are available defined to any lua scripts:
.Bl -tag -width Ds
+
.It Va pkg_name
+
name of the package.
.It Va pkg_prefix
.Va PREFIX
defined within the package at build time.
modified docs/pkg-script.5
@@ -11,7 +11,7 @@
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
-
.Dd January 28, 2020
+
.Dd March 26, 2021
.Dt PKG-SCRIPT 5
.Os
.Sh NAME
@@ -48,6 +48,8 @@ new post-install
.Sh Environment
The following environment variable are exported to be used by the script
.Bl -tag -width Ds
+
.It Ev PKG_NAME
+
Represents the name of the package.
.It Ev PKG_PREFIX
.Va PREFIX
defined within the package at build time.
modified libpkg/lua_scripts.c
@@ -103,6 +103,8 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
			lua_pushliteral(L, "PREFIX");
			lua_pushstring(L, pkg->prefix);
			lua_setglobal(L, "pkg_prefix");
+
			lua_pushstring(L, pkg->name);
+
			lua_setglobal(L, "pkg_name");
			if (ctx.pkg_rootdir == NULL)
				ctx.pkg_rootdir = "/";
			lua_pushstring(L, ctx.pkg_rootdir);
modified libpkg/scripts.c
@@ -110,6 +110,7 @@ pkg_script_run(struct pkg * const pkg, pkg_script type, bool upgrade)
			if (upgrade) {
				setenv("PKG_UPGRADE", "true", 1);
			}
+
			setenv("PKG_NAME", pkg->name, 1);
			setenv("PKG_PREFIX", pkg->prefix, 1);
			if (ctx.pkg_rootdir == NULL)
				ctx.pkg_rootdir = "/";