31 lignes
1.1 KiB
Python
Fichiers exécutables
31 lignes
1.1 KiB
Python
Fichiers exécutables
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
assert len(sys.argv) > 1, "Pas de fichier indiqué"
|
|
fichier = sys.argv[1].replace("file://", "")
|
|
base, ext = os.path.splitext(fichier)
|
|
destination = base + "_public" + ext
|
|
|
|
|
|
scriptdir=os.path.dirname(os.path.realpath(__file__))
|
|
assert len(subprocess.check_output(["git", "status", "--porcelain=v1"], cwd=scriptdir)) == 0, "Le répertoire est sale."
|
|
|
|
commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=scriptdir).decode("ascii").strip()
|
|
|
|
contenu = open(fichier).read()
|
|
with open(destination, "w") as f :
|
|
f.write("""%% Les fichiers nécessaires à la compilation sont disponibles sur SourceSup.
|
|
%% Version la plus récente :
|
|
%% https://sourcesup.renater.fr/scm/browser.php?group_id=5479&scm_plugin=scmgit
|
|
%% Version au moment de la publication du présent fichier :
|
|
%% https://sourcesup.renater.fr/scm/browser.php?group_id=5479&scm_plugin=scmgit&path=/anonscm/gitweb?p=typo-cpge/typo-cpge.git;a=tree;hb={}
|
|
%% Téléchargement direct :
|
|
%% https://git.renater.fr/anonscm/gitweb?p=typo-cpge/typo-cpge.git;a=snapshot;h={};sf=tgz
|
|
%%
|
|
""".format(commit,commit))
|
|
f.write(contenu)
|
|
|