Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Oct 2020 18:32:29 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r550860 - head/Keywords
Message-ID:  <202010011832.091IWTVW005518@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Thu Oct  1 18:32:29 2020
New Revision: 550860
URL: https://svnweb.freebsd.org/changeset/ports/550860

Log:
  Lua version of the @sample
  
  The bonus of this version being: sandboxed
  Natively rootdir compliant.
  
  Reviewed by:	portmgr (bapt@, mat@)
  Differential Revision:	https://reviews.freebsd.org/D23617

Modified:
  head/Keywords/sample.ucl

Modified: head/Keywords/sample.ucl
==============================================================================
--- head/Keywords/sample.ucl	Thu Oct  1 18:32:04 2020	(r550859)
+++ head/Keywords/sample.ucl	Thu Oct  1 18:32:29 2020	(r550860)
@@ -20,42 +20,28 @@
 
 actions: [file(1)]
 arguments: true
-post-install: <<EOD
-  case "%1" in
-  /*) sample_file="%1" ;;
-  *) sample_file="%D/%1" ;;
-  esac
-  target_file="${sample_file%.sample}"
-  set -- %@
-  if [ $# -eq 2 ]; then
-      target_file=${2}
-  fi
-  case "${target_file}" in
-  /*) target_file="${target_file}" ;;
-  *) target_file="%D/${target_file}" ;;
-  esac
-  if ! [ -f "${target_file}" ]; then
-    /bin/cp -p "${sample_file}" "${target_file}"
-  fi
-EOD
-pre-deinstall: <<EOD
-  case "%1" in
-  /*) sample_file="%1" ;;
-  *) sample_file="%D/%1" ;;
-  esac
-  target_file="${sample_file%.sample}"
-  set -- %@
-  if [ $# -eq 2 ]; then
-      set -- %@
-      target_file=${2}
-  fi
-  case "${target_file}" in
-  /*) target_file="${target_file}" ;;
-  *) target_file="%D/${target_file}" ;;
-  esac
-  if cmp -s "${target_file}" "${sample_file}"; then
-    rm -f "${target_file}"
-  elif [ -e "${target_file}" ] ; then
-    echo "You may need to manually remove ${target_file} if it is no longer needed."
-  fi
-EOD
+post-install-lua: <<EOS
+  sample_file = pkg.prefixed_path("%1")
+  if "%#" == 2 then
+    target_file = pkg.prefixed_path("%1")
+  else
+    target_file = string.gsub(sample_file,'%.sample$', "")
+  end
+  if not pkg.stat(target_file) then
+    pkg.copy(sample_file, target_file)
+  end
+EOS
+
+pre-deinstall-lua: <<EOS
+  sample_file = pkg.prefixed_path("%1")
+  if "%#" == 2 then
+    target_file = pkg.prefixed_path("%1")
+  else
+    target_file = string.gsub(sample_file,'%.sample$', "")
+  end
+  if pkg.filecmp(sample_file, target_file) == 0 then
+    os.remove(target_file)
+  else
+    pkg.print_msg("You may need to manually remove " .. target_file .. " if it is no longer needed.")
+  end
+EOS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010011832.091IWTVW005518>