Files
ports/Mk/Scripts/electron-normalize-permissions.awk
T
Hiroki Tagato 331eb8eae5 Mk/Uses: Add electron.mk and companion scripts
electron.mk and companion scripts for making it easier to port
Electron-based applications.

The electron.mk addresses the following obstacles in porting:

- Need to adapt to different node package managers used in a
  project (npm, yarn, and pnpm)

  Different package managers have different commands and options. With
  electron.mk, porters don't have to worry about those differences
  using USE_ELECTRON=npm feature.

- Need to create an archive of necessary node modules and host the
  file somewhere online

  An Electron-based project usually needs to install node modules
  using "npm install" command during the build phase. We can't allow
  this because "npm install" involves network access. So we had to
  pre-generate an archive of necessary node modules and host it
  somewhere online. electron.mk eliminates the necessity by locally
  generating the archive of the node modules on-the-fly at a host
  building the port during the fetch phase.

- Need to adapt to different package builders used (electron-builder,
  electron-packager, and electron-forge)

  Different package builders have different commands and options. With
  electron.mk, porters don't have to worry about those differences
  using USE_ELECTRON=build feature.

PR:		291321
Reviewed by:	arrowd
Approved by:	portmgr (implicit)
Differential Revision:	https://reviews.freebsd.org/D54005
2025-12-21 21:47:23 +09:00

31 lines
635 B
Awk

# 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
}