initial: nsSplashPNG plugin 1.0.0

This commit is contained in:
2026-04-29 23:19:34 +02:00
commit db4c1b0f1e
41 changed files with 4400 additions and 0 deletions
+137
View File
@@ -0,0 +1,137 @@
"""
Fix nsSplashPNG repo:
1. Rimuove dal tracking i file di build MSBuild in src/ (artifacts + DLL grezze)
2. Sposta le DLL pre-built in dist/ (struttura canonica)
3. Aggiunge regole .gitignore per escludere le cartelle Release in src/
4. Aggiunge dist/ al tracking (con DLL binarie)
5. Commit + push Gitea + push GitHub
"""
import os, sys, shutil, subprocess
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
# --- Load .env ---
env_path = REPO.parent.parent / '.env' # Launchers/.env
if env_path.exists():
for line in env_path.read_text(encoding='utf-8').splitlines():
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
os.environ.setdefault(k.strip(), v.strip())
GITEA_URL = os.environ['GITEA_URL']
GITEA_USER = os.environ['GITEA_USER']
GITEA_TOK = os.environ['GITEA_TOKEN']
GH_USER = os.environ['GITHUB_USER']
GH_TOK = os.environ['GITHUB_TOKEN']
REPO_NAME = 'nsis-plugin-nssplashpng'
def git(*args):
r = subprocess.run(['git', '-C', str(REPO)] + list(args), capture_output=True, text=True)
if r.returncode != 0:
print(f'[git] stderr: {r.stderr.strip()}')
return r
# 1. Rimuovi dal tracking tutti i file di build in src/
print('[1] Rimuovo artifacts di build dal tracking...')
tracked_artifacts = [
'src/nsSplashPNG/Release Unicode/nsSplashPNG.dll.recipe',
'src/nsSplashPNG/Release Unicode/nsSplashPNG.iobj',
'src/nsSplashPNG/Release Unicode/nsSplashPNG.ipdb',
'src/nsSplashPNG/Release/nsSplashPNG.dll.recipe',
'src/nsSplashPNG/Release/nsSplashPNG.iobj',
'src/nsSplashPNG/Release/nsSplashPNG.ipdb',
'src/nsSplashPNG/x64/Release Unicode/nsSplashPNG.dll.recipe',
'src/nsSplashPNG/x64/Release Unicode/nsSplashPNG.iobj',
'src/nsSplashPNG/x64/Release Unicode/nsSplashPNG.ipdb',
'src/Release Unicode/nsSplashPNG.dll',
'src/Release/nsSplashPNG.dll',
'src/x64/Release Unicode/nsSplashPNG.dll',
]
for f in tracked_artifacts:
r = git('rm', '--cached', f)
if r.returncode == 0:
print(f' [rm cached] {f}')
else:
print(f' [skip] {f} — not tracked or already removed')
# 2. Sposta DLL in dist/ (struttura canonica)
print('[2] Sposto DLL in dist/...')
moves = [
('src/Release/nsSplashPNG.dll', 'dist/x86-ansi/nsSplashPNG.dll'),
('src/Release Unicode/nsSplashPNG.dll', 'dist/x86-unicode/nsSplashPNG.dll'),
('src/x64/Release Unicode/nsSplashPNG.dll', 'dist/amd64-unicode/nsSplashPNG.dll'),
]
for src_rel, dst_rel in moves:
src = REPO / Path(src_rel)
dst = REPO / Path(dst_rel)
dst.parent.mkdir(parents=True, exist_ok=True)
if src.exists():
shutil.copy2(src, dst)
print(f' [copied] {src_rel}{dst_rel}')
elif dst.exists():
print(f' [exists] {dst_rel} (src già rimosso)')
else:
print(f' [warn] {src_rel} non trovato — DLL mancante')
# 3. Aggiungi .gitignore rules per le cartelle MSBuild in src/
print('[3] Aggiorno .gitignore...')
gi_path = REPO / '.gitignore'
gi_content = gi_path.read_text(encoding='utf-8')
extra = (
'\n# MSBuild output directories in src/ (build artifacts, not source)\n'
'src/**/Release/\n'
'src/**/Release Unicode/\n'
'src/**/x64/\n'
'*.recipe\n'
'*.iobj\n'
'*.ipdb\n'
)
if 'MSBuild output directories' not in gi_content:
gi_path.write_text(gi_content + extra, encoding='utf-8')
print(' [ok] .gitignore aggiornato')
else:
print(' [skip] .gitignore già aggiornato')
# 4. Stage dist/ e .gitignore
print('[4] Stage dist/ e .gitignore...')
git('add', 'dist/')
git('add', '.gitignore')
# Verifica status
r = git('status', '--short')
print(r.stdout.strip() or '(nothing staged)')
# 5. Commit
print('[5] Commit...')
r = git('commit', '-m',
'fix: move pre-built DLLs to dist/, remove MSBuild artifacts from tracking\n\n'
'- src/Release*/ and src/nsSplashPNG/Release*/ were committed by mistake\n'
' (MSBuild artifacts: .iobj, .ipdb, .recipe + raw DLL outputs)\n'
'- DLLs moved to canonical dist/{x86-ansi,x86-unicode,amd64-unicode}/\n'
'- .gitignore updated to exclude src/**/Release*/ going forward'
)
if r.returncode != 0:
print(f'[FAIL] commit: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] {r.stdout.strip()}')
# 6. Push Gitea
print('[6] Push Gitea...')
gitea_url = f"{GITEA_URL.replace('://', f'://{GITEA_USER}:{GITEA_TOK}@')}/{GITEA_USER}/{REPO_NAME}.git"
r = subprocess.run(['git', '-C', str(REPO), 'push', gitea_url, 'main'],
capture_output=True, text=True)
if r.returncode != 0:
print(f'[FAIL] Gitea: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] Gitea: {r.stderr.strip() or "up to date"}')
# 7. Push GitHub
print('[7] Push GitHub...')
gh_url = f'https://{GH_USER}:{GH_TOK}@github.com/{GH_USER}/{REPO_NAME}.git'
r = subprocess.run(['git', '-C', str(REPO), 'push', gh_url, 'main'],
capture_output=True, text=True)
if r.returncode != 0:
print(f'[FAIL] GitHub: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] GitHub: {r.stderr.strip() or "up to date"}')
print('[DONE]')
+80
View File
@@ -0,0 +1,80 @@
"""
Push latest commit to Gitea + GitHub directly,
then disable Gitea Actions on the repo (keep GitHub Actions enabled).
"""
import urllib.request, urllib.error, json, os, sys, subprocess
# --- Load .env from workspace root ---
env_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '.env')
env_path = os.path.normpath(env_path)
if os.path.exists(env_path):
with open(env_path, encoding='utf-8') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
os.environ.setdefault(k.strip(), v.strip())
GITEA_URL = os.environ['GITEA_URL']
GITEA_USER = os.environ['GITEA_USER']
GITEA_TOK = os.environ['GITEA_TOKEN']
GH_USER = os.environ['GITHUB_USER']
GH_TOK = os.environ['GITHUB_TOKEN']
REPO = 'nsis-plugin-nssplashpng'
STAGING = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
def api_call(url, method='GET', data=None, headers=None):
body = json.dumps(data).encode() if data else None
req = urllib.request.Request(url, data=body, headers=headers or {}, method=method)
try:
with urllib.request.urlopen(req) as r:
raw = r.read()
return r.status, json.loads(raw) if raw else {}
except urllib.error.HTTPError as e:
raw = e.read()
return e.code, json.loads(raw) if raw else {}
# --- 1. Push to Gitea ---
print('[1] Push to Gitea...')
gitea_push_url = f"{GITEA_URL.replace('://', f'://{GITEA_USER}:{GITEA_TOK}@')}/{GITEA_USER}/{REPO}.git"
r = subprocess.run(['git', '-C', STAGING, 'push', gitea_push_url, 'main'],
capture_output=True, text=True)
if r.returncode != 0:
print(f'[FAIL] Gitea push: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] Gitea push: {r.stderr.strip() or "up to date"}')
# --- 2. Push to GitHub ---
print('[2] Push to GitHub...')
gh_push_url = f'https://{GH_USER}:{GH_TOK}@github.com/{GH_USER}/{REPO}.git'
r = subprocess.run(['git', '-C', STAGING, 'push', gh_push_url, 'main'],
capture_output=True, text=True)
if r.returncode != 0:
print(f'[FAIL] GitHub push: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] GitHub push: {r.stderr.strip() or "up to date"}')
# --- 3. Disable Gitea Actions ---
print('[3] Disabling Gitea Actions...')
gitea_hdrs = {'Authorization': f'token {GITEA_TOK}', 'Content-Type': 'application/json'}
s, resp = api_call(
f'{GITEA_URL}/api/v1/repos/{GITEA_USER}/{REPO}',
method='PATCH',
data={'has_actions': False},
headers=gitea_hdrs
)
if s in (200, 201, 204):
actions_status = resp.get('has_actions', '?')
print(f'[ok] Gitea Actions disabled (has_actions={actions_status})')
else:
print(f'[warn] PATCH repo returned {s}: {resp}')
print('[warn] Trying via repo settings API...')
# Alternative: some Gitea versions use a different field name
s2, resp2 = api_call(
f'{GITEA_URL}/api/v1/repos/{GITEA_USER}/{REPO}',
method='PATCH',
data={'actions': False},
headers=gitea_hdrs
)
print(f'[info] actions=False attempt: {s2}: {resp2.get("has_actions", resp2.get("actions", "?"))}')
print('[DONE]')
+121
View File
@@ -0,0 +1,121 @@
"""
Squash everything in the nsSplashPNG repo into a single initial commit,
then force-push to Gitea and GitHub.
Steps:
1. Create orphan branch 'init'
2. git add -A (all currently tracked + untracked non-ignored files)
3. Commit with the canonical initial message
4. Replace 'main' with 'init'
5. Delete old v1.0.0 tag, recreate on new commit
6. Force-push main + tag to Gitea and GitHub
"""
import os, sys, subprocess
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
# --- Load .env ---
env_path = REPO.parent.parent / '.env'
if env_path.exists():
for line in env_path.read_text(encoding='utf-8').splitlines():
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
os.environ.setdefault(k.strip(), v.strip())
GITEA_URL = os.environ['GITEA_URL']
GITEA_USER = os.environ['GITEA_USER']
GITEA_TOK = os.environ['GITEA_TOKEN']
GH_USER = os.environ['GITHUB_USER']
GH_TOK = os.environ['GITHUB_TOKEN']
REPO_NAME = 'nsis-plugin-nssplashpng'
GITEA_PUSH = f"{GITEA_URL.replace('://', f'://{GITEA_USER}:{GITEA_TOK}@')}/{GITEA_USER}/{REPO_NAME}.git"
GH_PUSH = f'https://{GH_USER}:{GH_TOK}@github.com/{GH_USER}/{REPO_NAME}.git'
COMMIT_MSG = 'chore: initial commit (extracted from Launchers monorepo)'
TAG = 'v1.0.0'
def git(*args, check=True):
r = subprocess.run(['git', '-C', str(REPO)] + list(args),
capture_output=True, text=True)
if check and r.returncode != 0:
print(f'[git {" ".join(args)}] stderr: {r.stderr.strip()}', file=sys.stderr)
sys.exit(1)
return r
# 1. Crea branch orfano
print('[1] Creo branch orfano "init"...')
git('checkout', '--orphan', 'init')
# 2. Stage tutto (include file attualmente tracciati + non-ignorati)
print('[2] Stage di tutti i file...')
git('add', '-A')
# Verifica cosa verrà committato
r = git('status', '--short')
print(r.stdout.strip())
# 3. Commit
print('[3] Commit unico...')
# Configura autore se non già globale
r = git('commit', '-m', COMMIT_MSG)
print(f'[ok] {r.stdout.strip()}')
# 4. Sostituisci main con init
print('[4] Sostituisco branch main...')
git('branch', '-D', 'main')
git('branch', '-m', 'init', 'main')
# 5. Elimina vecchio tag e ricrealo sul nuovo commit
print(f'[5] Ricreo tag {TAG}...')
git('tag', '-d', TAG, check=False) # potrebbe non esistere
git('tag', TAG)
# Verifica finale
r = git('log', '--oneline')
print(f'[log] {r.stdout.strip()}')
r = git('tag', '--list')
print(f'[tags] {r.stdout.strip()}')
# 6. Force push a Gitea
print('[6] Force push a Gitea...')
r = subprocess.run(
['git', '-C', str(REPO), 'push', '--force', GITEA_PUSH, 'main', TAG],
capture_output=True, text=True
)
if r.returncode != 0:
print(f'[FAIL] Gitea: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] Gitea: {r.stderr.strip()}')
# 7. Force push a GitHub
print('[7] Force push a GitHub...')
r = subprocess.run(
['git', '-C', str(REPO), 'push', '--force', GH_PUSH, 'main', TAG],
capture_output=True, text=True
)
if r.returncode != 0:
print(f'[FAIL] GitHub: {r.stderr}', file=sys.stderr); sys.exit(1)
print(f'[ok] GitHub: {r.stderr.strip()}')
# 8. Aggiorna origin/main
print('[8] Aggiorno remote tracking...')
r = subprocess.run(
['git', '-C', str(REPO), 'remote', 'set-head', 'origin', 'main'],
capture_output=True, text=True
)
# Fetch per sincronizzare origin/main con il nuovo HEAD
gitea_fetch = GITEA_PUSH
r2 = subprocess.run(
['git', '-C', str(REPO), 'fetch', '--force', gitea_fetch, 'main:refs/remotes/origin/main'],
capture_output=True, text=True
)
# Verifica stato finale
r = git('log', '--oneline', '-3')
print(f'\n[FINAL LOG]\n{r.stdout.strip()}')
r = git('status', '-sb')
print(f'[FINAL STATUS]\n{r.stdout.strip()}')
print('\n[DONE] Repository ridotto a singolo commit iniziale.')