Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Move copy and filecmp to the pkg package
Baptiste Daroussin committed 5 years ago
commit 93e3998503fcfba3a2b2a86211b9631e1340c5b8
parent 3f7d9e5
3 files changed +8 -10
modified docs/pkg-lua-script.5
@@ -106,7 +106,7 @@ if needed and returns it as
send messages to the user that will be shown at the end of the
.Xr pkg 8
process.
-
.It Fn pkg_filecmp "file1" "file2"
+
.It Fn pkg.filecmp "file1" "file2"
Compare 2 files, return
.Va 0
if the files are identical,
@@ -114,7 +114,7 @@ if the files are identical,
if the files are different and
.Va >1
if an error occured
-
.It Fn pkg_filecopy "source" "destination"
+
.It Fn pkg.copy "source" "destination"
Copy a file preserving its attributes. return
.Va -1
if an error occured
modified libpkg/lua_scripts.c
@@ -387,6 +387,8 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
			static const luaL_Reg pkg_lib[] = {
				{ "print_msg", lua_print_msg },
				{ "prefixed_path", lua_prefix_path },
+
				{ "filecmp", lua_pkg_filecmp },
+
				{ "copy", lua_pkg_copy },
				{ NULL, NULL },
			};
			close(cur_pipe[0]);
@@ -406,10 +408,6 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
			lua_setglobal(L, "pkg_rootdir");
			lua_pushboolean(L, (upgrade));
			lua_setglobal(L, "pkg_upgrade");
-
			lua_pushcfunction(L, lua_pkg_copy);
-
			lua_setglobal(L, "pkg_copy");
-
			lua_pushcfunction(L, lua_pkg_filecmp);
-
			lua_setglobal(L, "pkg_filecmp");
			lua_pushcfunction(L, lua_print_msg);
			luaL_newlib(L, pkg_lib);
			lua_setglobal(L, "pkg");
modified tests/frontend/lua.sh
@@ -268,8 +268,8 @@ files: {
}
lua_scripts: {
  post-install: [ <<EOS
-
  if pkg_filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
-
     pkg_copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
+
  if pkg.filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
+
     pkg.copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
  end
EOS
, ]
@@ -307,8 +307,8 @@ files: {
}
lua_scripts: {
  post-install: [ <<EOS
-
  if pkg_filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
-
     pkg_copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
+
  if pkg.filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
+
     pkg.copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
  end
EOS
, ]