[mv3] Safari works; use 3-component version for uBOL

uBOL doesn't pass validation when using 4-component versioning,
so falling back to 3-component versioning for all platforms to
avoid special case.
This commit is contained in:
Raymond Hill 2025-05-08 16:53:07 -04:00
parent df9cd6c9a2
commit 1c98faf46c
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
6 changed files with 56 additions and 35 deletions

View file

@ -6,11 +6,13 @@ run_options := $(filter-out $@,$(MAKECMDGOALS))
compare maxcost medcost mincost modifiers record wasm
sources := ./dist/version $(shell find ./assets -type f) $(shell find ./src -type f)
platform := $(wildcard platform/**/*)
platform := $(wildcard platform/*/*)
assets := dist/build/uAssets
mv3-sources := $(shell find ./src -type f) $(shell find ./platform/mv3 -type f)
mv3-sources := $(shell find ./src -type f) $(wildcard platform/mv3/*) $(shell find ./platform/mv3/extension -type f)
mv3-data := $(shell find ./dist/build/mv3-data -type f)
mv3-safari-deps := $(shell find ./platform/mv3/extension -type f) $(wildcard platform/mv3/safari/*)
mv3-edge-deps := $(wildcard platform/mv3/edge/*)
mv3-safari-deps := $(wildcard platform/mv3/safari/*)
all: chromium firefox npm
@ -77,7 +79,7 @@ dist/build/uBOLite.firefox: tools/make-mv3.sh $(mv3-sources) $(platform) $(mv3-d
mv3-firefox: dist/build/uBOLite.firefox
dist/build/uBOLite.edge: tools/make-mv3.sh tools/make-edge.mjs $(mv3-sources) $(platform) $(mv3-data) dist/build/mv3-data
dist/build/uBOLite.edge: tools/make-mv3.sh $(mv3-sources) $(mv3-edge-deps) $(mv3-data) dist/build/mv3-data
tools/make-mv3.sh edge
mv3-edge: dist/build/uBOLite.edge

View file

@ -19,16 +19,33 @@
Home: https://github.com/gorhill/uBlock
*/
'use strict';
import fs from 'fs/promises';
import process from 'process';
/******************************************************************************/
import fs from 'fs/promises';
const commandLineArgs = (( ) => {
const args = Object.create(null);
let name, value;
for ( const arg of process.argv.slice(2) ) {
const pos = arg.indexOf('=');
if ( pos === -1 ) {
name = arg;
value = '';
} else {
name = arg.slice(0, pos);
value = arg.slice(pos+1);
}
args[name] = value;
}
return args;
})();
/******************************************************************************/
async function main() {
const manifestPath = 'dist/build/uBOLite.edge/manifest.json';
const packageDir = commandLineArgs.packageDir;
const manifestPath = `${packageDir}/manifest.json`;
// Get manifest content
const manifest = await fs.readFile(manifestPath, { encoding: 'utf8'
@ -45,7 +62,7 @@ async function main() {
}
// Commit changes
await fs.writeFile(manifestPath,
JSON.stringify(manifest, null, 2) + '\n'
JSON.stringify(manifest, null, 2)
);
}

View file

@ -1413,7 +1413,7 @@ async function main() {
const dayPart = now.getUTCDate();
const hourPart = Math.floor(now.getUTCHours());
const minutePart = Math.floor(now.getUTCMinutes());
version = `${yearPart}.${monthPart}.${dayPart}.${hourPart * 60 + minutePart}`;
version = `${yearPart}.${monthPart*100+dayPart}.${hourPart*100+minutePart}`;
}
log(`Version: ${version}`, false);

View file

@ -9,6 +9,11 @@
"type": "module",
"persistent": false
},
"browser_specific_settings": {
"safari": {
"strict_min_version": "18.4"
}
},
"commands": {
"enter-zapper-mode": {
"description": "__MSG_zapperTipEnter__"

View file

@ -25,7 +25,7 @@ import process from 'process';
/******************************************************************************/
const commandLineArgs = (( ) => {
const args = new Map();
const args = Object.create(null);
let name, value;
for ( const arg of process.argv.slice(2) ) {
const pos = arg.indexOf('=');
@ -36,7 +36,7 @@ const commandLineArgs = (( ) => {
name = arg.slice(0, pos);
value = arg.slice(pos+1);
}
args.set(name, value);
args[name] = value;
}
return args;
})();
@ -65,7 +65,7 @@ async function fixLongDescription(path) {
async function fixLongDescriptions() {
const promises = [];
const packageDir = commandLineArgs.get('packageDir');
const packageDir = commandLineArgs.packageDir;
const entries = await fs.readdir(`${packageDir}/_locales/`, { withFileTypes: true });
for ( const entry of entries ) {
if ( entry.isDirectory() === false ) { continue; }
@ -79,11 +79,12 @@ async function fixLongDescriptions() {
// Apple store rejects when version has four components.
async function fixManifest() {
const packageDir = commandLineArgs.get('packageDir');
const packageDir = commandLineArgs.packageDir;
const path = `${packageDir}/manifest.json`;
let text = await fs.readFile(path, { encoding: 'utf8' });
const manifest = JSON.parse(text);
const match = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(manifest.version);
if ( match === null ) { return; }
const month = parseInt(match[2], 10);
const dayofmonth = parseInt(match[3], 10);
const monthday /* sort of */ = month * 100 + dayofmonth;
@ -99,7 +100,6 @@ async function main() {
fixLongDescriptions(),
fixManifest(),
]);
}
main();

View file

@ -26,7 +26,7 @@ for i in "$@"; do
safari)
PLATFORM="safari"
;;
uBOLite_+([0-9]).+([0-9]).+([0-9]).+([0-9]))
uBOLite_+([0-9]).+([0-9]).+([0-9]))
TAGNAME="$i"
FULL="yes"
;;
@ -124,24 +124,12 @@ fi
cd - > /dev/null
rm -rf "$UBOL_BUILD_DIR"
# For Edge, declared rulesets must be at package root
if [ "$PLATFORM" = "edge" ]; then
echo "*** uBOLite.edge: Modify reference implementation for Edge compatibility"
mv "$UBOL_DIR"/rulesets/main/* "$UBOL_DIR/"
rmdir "$UBOL_DIR/rulesets/main"
node tools/make-edge.mjs
fi
# For Safari, we must fix the package for compliance
if [ "$PLATFORM" = "safari" ]; then
node platform/mv3/safari/patch-extension.js packageDir="$UBOL_DIR"
fi
echo "*** uBOLite.$PLATFORM: extension ready"
echo "Extension location: $UBOL_DIR/"
# Local build
if [ -z "$TAGNAME" ]; then
TAGNAME="uBOLite_$(jq -r .version "$UBOL_DIR"/manifest.json)"
# Enable DNR rule debugging
tmp=$(mktemp)
jq '.permissions += ["declarativeNetRequestFeedback"]' \
@ -153,6 +141,22 @@ if [ -z "$TAGNAME" ]; then
jq '.browser_specific_settings.gecko.id = "uBOLite.dev@raymondhill.net"' "$UBOL_DIR/manifest.json" > "$tmp" \
&& mv "$tmp" "$UBOL_DIR/manifest.json"
fi
else
tmp=$(mktemp)
jq --arg version "${TAGNAME:8}" '.version = $version' "$UBOL_DIR/manifest.json" > "$tmp" \
&& mv "$tmp" "$UBOL_DIR/manifest.json"
fi
# Platform-specific steps
if [ "$PLATFORM" = "edge" ]; then
# For Edge, declared rulesets must be at package root
echo "*** uBOLite.edge: Modify reference implementation for Edge compatibility"
mv "$UBOL_DIR"/rulesets/main/* "$UBOL_DIR/"
rmdir "$UBOL_DIR/rulesets/main"
node platform/mv3/edge/patch-extension.js packageDir="$UBOL_DIR"
elif [ "$PLATFORM" = "safari" ]; then
# For Safari, we must fix the package for compliance
node platform/mv3/safari/patch-extension.js packageDir="$UBOL_DIR"
fi
if [ "$FULL" = "yes" ]; then
@ -161,13 +165,6 @@ if [ "$FULL" = "yes" ]; then
EXTENSION="xpi"
fi
echo "*** uBOLite.mv3: Creating publishable package..."
if [ -z "$TAGNAME" ]; then
TAGNAME="uBOLite_$(jq -r .version "$UBOL_DIR"/manifest.json)"
else
tmp=$(mktemp)
jq --arg version "${TAGNAME:8}" '.version = $version' "$UBOL_DIR/manifest.json" > "$tmp" \
&& mv "$tmp" "$UBOL_DIR/manifest.json"
fi
UBOL_PACKAGE_NAME="$TAGNAME.$PLATFORM.mv3.$EXTENSION"
UBOL_PACKAGE_DIR=$(mktemp -d)
mkdir -p "$UBOL_PACKAGE_DIR"