Compare commits
14 Commits
feature/pa
...
feature/xe
Author | SHA1 | Date | |
---|---|---|---|
822fd277d5 | |||
a821fb141f | |||
d4547175da | |||
7b2644b953 | |||
4aecce6094 | |||
2a65d38c37 | |||
5591c2c0f0 | |||
0c09b27b8e | |||
5676297827 | |||
822dc3617c | |||
0172b4f62c | |||
d27cc4bf1b | |||
2606a82c17 | |||
bb633a212c |
BIN
datasets/fonts/CaviarDreams.ttf
Normal file
BIN
datasets/fonts/CaviarDreams.ttf
Normal file
Binary file not shown.
BIN
datasets/fonts/CaviarDreams_Bold.ttf
Normal file
BIN
datasets/fonts/CaviarDreams_Bold.ttf
Normal file
Binary file not shown.
BIN
datasets/fonts/CaviarDreams_BoldItalic.ttf
Normal file
BIN
datasets/fonts/CaviarDreams_BoldItalic.ttf
Normal file
Binary file not shown.
BIN
datasets/fonts/CaviarDreams_Italic.ttf
Normal file
BIN
datasets/fonts/CaviarDreams_Italic.ttf
Normal file
Binary file not shown.
12
hooks/build/texlive/xelatex
Executable file
12
hooks/build/texlive/xelatex
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd /src
|
||||
document_root=${PROJECT}
|
||||
for tex in ./presentations/${document_root}/*.tex
|
||||
do
|
||||
rubber --inplace -c shell_escape --unsafe --module=xelatex "$tex"
|
||||
cp "${tex%.tex}.pdf" /dist/
|
||||
# faire quelque chose pour le programme de la formation
|
||||
done
|
||||
popd
|
||||
|
11
hooks/containerbuild/texlive/add-packages
Executable file
11
hooks/containerbuild/texlive/add-packages
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo 'ENV DEBIAN_FRONTEND=noninteractive' >> Dockerfile
|
||||
echo 'RUN apt-get update && apt-get install --yes texlive-full' >> Dockerfile
|
||||
echo 'RUN apt-get update && apt-get install --yes make' >> Dockerfile
|
||||
echo 'RUN apt-get update && apt-get install --yes fonts-liberation fonts-liberation2' >> Dockerfile
|
||||
echo 'RUN apt-get update && apt-get install --yes python3-setuptools python-setuptools python3-pygments python-pygments' >> Dockerfile
|
||||
echo 'RUN apt-get update && apt-get install --yes rubber' >> Dockerfile
|
||||
echo 'ENV DEBIAN_FRONTEND=' >> Dockerfile
|
14
hooks/containerbuild/texlive/add-ressources
Executable file
14
hooks/containerbuild/texlive/add-ressources
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
if [ -e './datasets/fonts' ]
|
||||
then
|
||||
for font_file in $(find . -wholename "./datasets/fonts/*.ttf")
|
||||
do
|
||||
echo 'COPY datasets/fonts/$font_file /root/.fonts/$font_file' >> Dockerfile
|
||||
done
|
||||
fi
|
||||
exit 0
|
||||
|
13
hooks/postbuild/texlive/export-dist
Executable file
13
hooks/postbuild/texlive/export-dist
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
function move_output_to_dist {
|
||||
find . -name "$1" -type f -print0 | xargs -0r mv -t /dist/
|
||||
}
|
||||
|
||||
# Create new directory
|
||||
mkdir -p /dist
|
||||
|
||||
# Move generated files
|
||||
move_output_to_dist "*.pdf"
|
||||
|
||||
tamarin_success "Done :-)"
|
@ -63,10 +63,10 @@ function parse_tag {
|
||||
extended_version="${tag##*/}"
|
||||
if [ "$flavor" = "pkg" ]
|
||||
then
|
||||
exploded_version="$(echo $extended_version | sed "s/\([a-z0-9.+]\+\)-\([0-9]\+\)\(-[a-z]\++[0-9]\+\)\?\(-\([0-9]\+\)-\(g[a-z0-9]\+\)\)\?$/version:\1 revision:\2 modification:\3 distance:\5 anchor:\6/")"
|
||||
exploded_version="$(echo $extended_version | sed "s/\([a-z0-9.]\+\)-\([0-9]\+\)\(-[a-z]\++[0-9]\+\)\?\(-\([0-9]\+\)-\(g[a-z0-9]\+\)\)\?$/version:\1 revision:\2 modification:\3 distance:\5 anchor:\6/")"
|
||||
elif [ "$flavor" = "release" ]
|
||||
then
|
||||
exploded_version="$(echo $extended_version | sed "s/\([a-z0-9.+]\+\)\(-\([0-9]\+\)-\(g[a-z0-9]\+\)\)\?$/version:\1 distance:\3 anchor:\4/")"
|
||||
exploded_version="$(echo $extended_version | sed "s/\([a-z0-9.]\+\)\(-\([0-9]\+\)-\(g[a-z0-9]\+\)\)\?$/version:\1 distance:\3 anchor:\4/")"
|
||||
fi
|
||||
echo $exploded_version
|
||||
}
|
||||
|
3
hooks/prebuild/texlive/complete-project-db
Executable file
3
hooks/prebuild/texlive/complete-project-db
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd src
|
@ -1,4 +1,4 @@
|
||||
import os, glob, subprocess, configparser, codecs, sys, pathlib
|
||||
import os, glob, subprocess, configparser, codecs, sys
|
||||
|
||||
def run_profile_hooks(profile, step, **kwargs):
|
||||
hooks_dir = get_hooks_dir()
|
||||
@ -9,57 +9,55 @@ def run_profile_hooks(profile, step, **kwargs):
|
||||
trimmed_hook_name = hook_name.strip(' \t\n\r')
|
||||
if not trimmed_hook_name:
|
||||
continue
|
||||
hook_path = hooks_dir.joinpath(trimmed_hook_name)
|
||||
hook_path = os.path.join(hooks_dir, trimmed_hook_name)
|
||||
run([hook_path], **kwargs)
|
||||
|
||||
def get_base_dir():
|
||||
base_dir = pathlib.Path(__file__).absolute().parent.parent.resolve()
|
||||
return base_dir
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/..")
|
||||
|
||||
def get_hooks_dir():
|
||||
hooks_dir = get_base_dir().joinpath('hooks')
|
||||
return hooks_dir
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../hooks")
|
||||
|
||||
def get_lib_dir():
|
||||
lib_dir = get_base_dir().joinpath('lib')
|
||||
return lib_dir
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../lib")
|
||||
|
||||
def get_utils_dir():
|
||||
utils_dir = get_base_dir().joinpath('utils')
|
||||
return utils_dir
|
||||
|
||||
def get_profiles_dir():
|
||||
profiles_dir = get_base_dir().joinpath('profiles')
|
||||
return profiles_dir
|
||||
|
||||
def get_workspace_dir():
|
||||
"""Return the absolute path to the tamarin workspace ($HOME/.tamarin)"""
|
||||
home = pathlib.Path(os.environ["HOME"])
|
||||
workspace_dir = home.joinpath('.tamarin')
|
||||
return workspace_dir
|
||||
|
||||
def get_workspace_subdir(subdir):
|
||||
"""Return the absolute path to a subdirectory in tamarin workspace"""
|
||||
subdir_path = get_workspace_dir().joinpath(subdir)
|
||||
subdir_path.mkdir(parents=True, exist_ok=True)
|
||||
return subdir_path
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../utils")
|
||||
|
||||
def load_profile(profile_name, debug=False):
|
||||
profile_filename = profile_name+".conf"
|
||||
profile_path = get_profiles_dir().joinpath(profile_filename)
|
||||
if profile_path.exists():
|
||||
config = configparser.ConfigParser()
|
||||
with codecs.open(profile_path, encoding = 'utf-8', mode = 'r') as handle:
|
||||
config.read_file(handle)
|
||||
return config
|
||||
for profile_file in get_available_profiles():
|
||||
if profile_filename == os.path.basename(profile_file):
|
||||
config = configparser.ConfigParser()
|
||||
with codecs.open(profile_file, encoding = 'utf-8', mode = 'r') as handle:
|
||||
config.read_file(handle)
|
||||
return config
|
||||
return None
|
||||
|
||||
def get_profiles_dir():
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../profiles")
|
||||
|
||||
def get_available_profiles():
|
||||
return get_profiles_dir().glob('*.conf')
|
||||
return glob.glob(get_profiles_dir() + '/*.conf')
|
||||
|
||||
def get_available_profile_names():
|
||||
profile_files = get_available_profiles()
|
||||
return [p.stem for p in profile_files]
|
||||
return [os.path.splitext(os.path.basename(f))[0] for f in profile_files]
|
||||
|
||||
def get_workspace_dir():
|
||||
"""Return the absolute path to the tamarin workspace ($HOME/.tamarin)"""
|
||||
home = os.environ["HOME"]
|
||||
return os.path.join(os.sep, home, '.tamarin')
|
||||
|
||||
def get_workspace_subdir(subdir):
|
||||
"""Return the absolute path to a subdirectory in tamarin workspace"""
|
||||
dir_path = os.path.join(os.sep, get_workspace_dir(), subdir)
|
||||
os.makedirs(dir_path, exist_ok=True)
|
||||
return dir_path
|
||||
|
||||
def get_datasets_dir():
|
||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../datasets")
|
||||
|
||||
|
||||
def run(cmd, captureOutput=False, pty=False, debug=False, **kwargs):
|
||||
"""Execute an arbitrary command on the system"""
|
||||
|
34
package
34
package
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse, sys, shutil, os, subprocess, pathlib
|
||||
import argparse, sys, shutil, os, subprocess
|
||||
|
||||
sys.path.append(pathlib.Path(__file__).parent.joinpath('lib').as_posix())
|
||||
sys.path.append(os.path.dirname(__file__) + '/lib')
|
||||
|
||||
import tamarin
|
||||
|
||||
@ -28,18 +28,18 @@ def create_args_parser():
|
||||
return parser
|
||||
|
||||
def build_image(build_workspace, base_image, profile_name, profile, debug=False, rebuild=False):
|
||||
shutil.copytree(tamarin.get_base_dir(), build_workspace.joinpath('.tamarin'))
|
||||
shutil.copytree(tamarin.get_base_dir(), os.path.join(build_workspace, '.tamarin'))
|
||||
|
||||
with open(build_workspace.joinpath("Dockerfile"), 'w') as dockerfile:
|
||||
with open("{:s}/Dockerfile".format(build_workspace), 'w') as dockerfile:
|
||||
dockerfile.write("FROM {:s}\n".format(base_image))
|
||||
dockerfile.write("COPY .tamarin /tamarin\n")
|
||||
|
||||
# Configure "containerbuild" hooks environment
|
||||
hooks_env = os.environ.copy()
|
||||
hooks_env["PATH"] = os.environ['PATH'] + ':' + tamarin.get_lib_dir().as_posix()
|
||||
hooks_env["PATH"] = os.environ['PATH'] + ':' + tamarin.get_lib_dir()
|
||||
|
||||
# Run hooks
|
||||
tamarin.run_profile_hooks(profile, 'containerbuild', cwd=build_workspace.as_posix(), env=hooks_env, debug=debug)
|
||||
tamarin.run_profile_hooks(profile, 'containerbuild', cwd=build_workspace, env=hooks_env, debug=debug)
|
||||
|
||||
image_tag = "tamarin:{:s}_{:s}_{:d}".format(profile_name, base_image.replace(':', '_'), os.getpid())
|
||||
|
||||
@ -72,9 +72,8 @@ if __name__ == "__main__":
|
||||
cleanup(debug=args.debug)
|
||||
|
||||
# Verify project directory
|
||||
project_dir = pathlib.Path(args.project_directory).absolute()
|
||||
output_dir = pathlib.Path(args.output).absolute()
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
project_dir = os.path.abspath(args.project_directory)
|
||||
output_dir = os.path.abspath(args.output)
|
||||
|
||||
# Load build profile
|
||||
profile = tamarin.load_profile(args.profile, debug=args.debug)
|
||||
@ -84,8 +83,8 @@ if __name__ == "__main__":
|
||||
pid = os.getpid()
|
||||
build_workspace = tamarin.get_workspace_subdir('tmp/build_{:d}'.format(pid))
|
||||
|
||||
shutil.copytree(tamarin.get_utils_dir(), build_workspace.joinpath('utils'))
|
||||
|
||||
shutil.copytree(tamarin.get_utils_dir(), os.path.join(build_workspace, 'utils'))
|
||||
shutil.copytree(tamarin.get_datasets_dir(), os.path.join(build_workspace, 'datasets'))
|
||||
base_image = args.base if args.base != '' else profile['profile']['default_image']
|
||||
|
||||
image_tag = build_image(build_workspace, base_image, args.profile, profile, debug=args.debug, rebuild=args.rebuild)
|
||||
@ -109,16 +108,17 @@ if __name__ == "__main__":
|
||||
|
||||
# volumes definition
|
||||
docker_args += [
|
||||
"-v", "{:s}:/src:z,ro".format(project_dir.as_posix()),
|
||||
"-v", "{:s}:/dist:z".format(output_dir.as_posix()),
|
||||
"-v", "{:s}:/src:z,ro".format(project_dir),
|
||||
"-v", "{:s}:/dist:z".format(output_dir),
|
||||
"-v", "{:s}:/tamarin/datasets:z".format(tamarin.get_datasets_dir()),
|
||||
]
|
||||
|
||||
if not args.no_lib_mounts:
|
||||
docker_args += [
|
||||
"-v", "{:s}:/tamarin/hooks:z,ro".format(tamarin.get_hooks_dir().as_posix()),
|
||||
"-v", "{:s}:/tamarin/lib:z,ro".format(tamarin.get_lib_dir().as_posix()),
|
||||
"-v", "{:s}:/tamarin/profiles:z,ro".format(tamarin.get_profiles_dir().as_posix()),
|
||||
"-v", "{:s}:/tamarin/utils:z,ro".format(tamarin.get_utils_dir().as_posix())
|
||||
"-v", "{:s}:/tamarin/hooks:z,ro".format(tamarin.get_hooks_dir()),
|
||||
"-v", "{:s}:/tamarin/lib:z,ro".format(tamarin.get_lib_dir()),
|
||||
"-v", "{:s}:/tamarin/profiles:z,ro".format(tamarin.get_profiles_dir()),
|
||||
"-v", "{:s}:/tamarin/utils:z,ro".format(tamarin.get_utils_dir())
|
||||
]
|
||||
|
||||
# Use environment proxy if defined
|
||||
|
@ -1,31 +0,0 @@
|
||||
# Configuration générale du profil
|
||||
[profile]
|
||||
# Image Docker par défaut
|
||||
default_image=ubuntu:jammy
|
||||
|
||||
# Configuration de l'étape de pré-construction du conteneur
|
||||
[containerbuild]
|
||||
hooks=
|
||||
containerbuild/debian/install-build-essential,
|
||||
containerbuild/debian/install-git,
|
||||
containerbuild/eole-2.9.0/configure-additional-repository,
|
||||
|
||||
# Configuration de l'étape de pré-construction du paquet
|
||||
[prebuild]
|
||||
hooks=
|
||||
prebuild/debian/copy-sources-to-workspace,
|
||||
prebuild/debian/run-project-hooks,
|
||||
prebuild/debian/load-project-db,
|
||||
prebuild/debian/complete-project-db,
|
||||
prebuild/eole/create-changelog,
|
||||
prebuild/debian/install-build-depends
|
||||
|
||||
# Configuration de l'étape de construction du paquet
|
||||
[build]
|
||||
hooks=build/debian/build
|
||||
|
||||
# Configuration de l'étape de post-construction du paquet
|
||||
[postbuild]
|
||||
hooks=
|
||||
postbuild/debian/run-project-hooks,
|
||||
postbuild/debian/export-dist
|
28
profiles/texlive.conf
Normal file
28
profiles/texlive.conf
Normal file
@ -0,0 +1,28 @@
|
||||
# Configuration générale du profil
|
||||
[profile]
|
||||
# Image Docker par défaut
|
||||
default_image=ubuntu:focal
|
||||
|
||||
# Configuration de l’étape de pré-construction du conteneur
|
||||
[containerbuild]
|
||||
hooks=
|
||||
containerbuild/texlive/add-packages,
|
||||
containerbuild/texlive/add-ressources,
|
||||
|
||||
# Configuration de l’étape de pré-compilation des documents
|
||||
[prebuild]
|
||||
hooks=
|
||||
prebuild/debian/copy-sources-to-workspace,
|
||||
prebuild/debian/run-project-hooks,
|
||||
prebuild/debian/load-project-db,
|
||||
prebuild/texlive/complete-project-db,
|
||||
|
||||
# Configuration de l’étape de compilation du document
|
||||
[build]
|
||||
hooks=build/texlive/xelatex
|
||||
|
||||
# Configuration de l’étape de post-compilation du document
|
||||
[postbuild]
|
||||
hooks=
|
||||
postbuild/debian/run-project-hooks,
|
||||
postbuild/texlive/export-dist,
|
Reference in New Issue
Block a user