summaryrefslogtreecommitdiff
path: root/Mk/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Mk/Scripts')
-rw-r--r--Mk/Scripts/electron-create-mtree.sh34
-rw-r--r--Mk/Scripts/electron-normalize-permissions.awk30
2 files changed, 64 insertions, 0 deletions
diff --git a/Mk/Scripts/electron-create-mtree.sh b/Mk/Scripts/electron-create-mtree.sh
new file mode 100644
index 000000000000..6e213f0d5b23
--- /dev/null
+++ b/Mk/Scripts/electron-create-mtree.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# MAINTAINER: tagattie@FreeBSD.org
+
+PATH=/bin:/usr/bin:/usr/sbin
+
+set -e
+set -o pipefail
+
+[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_ELECTRON_CREATE_MTREE}" ] && set -x
+
+PREFETCH_TIMESTAMP=61171200 # 1971-12-10 00:00:00 GMT
+
+set -u
+
+usage() {
+ cat <<EOF
+ Usage: ${0##*/} dirname
+EOF
+ exit 1
+}
+
+if [ $# -ne 1 ]; then
+ usage
+fi
+
+mtree -cbnSp "$1" | mtree -C | \
+awk -f "${SCRIPTSDIR}/electron-normalize-permissions.awk" | \
+sed -e "s/time=[0-9.]*/time=${PREFETCH_TIMESTAMP}.000000000/" \
+ -e 's/\([gu]id\)=[0-9]*/\1=0/g' \
+ -e 's/flags=.*/flags=none/' \
+ -e "s|^\.|$1|" \
+ -e "s|^${WRKDIR}/||" \
+ -e '1d'
diff --git a/Mk/Scripts/electron-normalize-permissions.awk b/Mk/Scripts/electron-normalize-permissions.awk
new file mode 100644
index 000000000000..876f6c4fb684
--- /dev/null
+++ b/Mk/Scripts/electron-normalize-permissions.awk
@@ -0,0 +1,30 @@
+# MAINTAINER: tagattie@FreeBSD.org
+
+function oct2dec(octstr, i, c, val) {
+ val = 0
+ for (i = 1; i <= length(octstr); i++) {
+ c = substr(octstr, i, 1)
+ if (c < "0" || c > "7") {
+ break
+ }
+ val = val * 8 + (c - "0")
+ }
+ return val
+}
+
+{
+ if (match($0, /mode=[0-7]+/)) {
+ mode_str = substr($0, RSTART+5, RLENGTH-5)
+ mode = oct2dec(mode_str)
+ exec_bits = 73 # 0o111
+ special_bits = 3584 # 0o7000
+ special = and(mode, special_bits)
+ if (and(mode, exec_bits) != 0) {
+ newmode = or(special, 493) # 0o755
+ } else {
+ newmode = or(special, 420) # 0o644
+ }
+ sub(/mode=[0-7]+/, "mode=" sprintf("%04o", newmode))
+ }
+ print
+}