From 6e50a5f962779125bf13133e8b16681421ba9656 Mon Sep 17 00:00:00 2001 From: Situphen Date: Tue, 19 May 2020 22:00:10 +0200 Subject: [PATCH] =?UTF-8?q?On=20installe=20TeXLive=20Vanilla=20et=20les=20?= =?UTF-8?q?paquets=20LaTeX=20=C3=A0=20partir=20de=20latex-template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - On utilise la dernière version de TeXLive Vanilla (sans passer par les dépôts de Debian) - On installe les paquets LaTeX à partir de latex-template - Quelques modifications cosmétiques --- roles/latex/handlers/main.yml | 10 ++++- roles/latex/tasks/main.yml | 59 ++++++++++++++++++--------- roles/latex/tasks/packages.yml | 59 +++++++++------------------ roles/latex/templates/texlive.profile | 31 ++++++++++++++ roles/latex/vars/main.yml | 39 ++---------------- 5 files changed, 103 insertions(+), 95 deletions(-) create mode 100644 roles/latex/templates/texlive.profile diff --git a/roles/latex/handlers/main.yml b/roles/latex/handlers/main.yml index ba69706..f6ca076 100644 --- a/roles/latex/handlers/main.yml +++ b/roles/latex/handlers/main.yml @@ -1,7 +1,15 @@ - name: run texhash become: true become_user: zds - ansible.builtin.shell: texhash $HOME/texmf + ansible.builtin.shell: "{{ texlive_binaries }}/texhash $HOME/texmf" - name: refresh font-config cache ansible.builtin.command: fc-cache -f + +- name: remove texlive installation files # noqa deprecated-command-syntax + shell: | + rm -rf ./install-tl-*/ + rm ./texlive.profile + args: + executable: /bin/bash + chdir: "{{ workdir }}" diff --git a/roles/latex/tasks/main.yml b/roles/latex/tasks/main.yml index f975e82..332957d 100644 --- a/roles/latex/tasks/main.yml +++ b/roles/latex/tasks/main.yml @@ -1,31 +1,52 @@ -- name: install texlive packages - ansible.builtin.apt: - pkg: - - texlive - - texlive-luatex - - texlive-lang-french - - texlive-latex-extra - - texlive-fonts-extra - - python-pygments - - xzdec - - wget - cache_valid_time: 3600 +- name: download latest texlive + become: true + become_user: zds + ansible.builtin.unarchive: + src: http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz + dest: "{{ workdir }}" + remote_src: true + tags: + - bootstrap + +- name: copy texlive.profile + become: true + become_user: zds + ansible.builtin.template: + src: texlive.profile + dest: "{{ workdir }}/texlive.profile" tags: - bootstrap -- include_tasks: packages.yml +- name: install latest texlive + become: true + become_user: zds + ansible.builtin.shell: | + if [ -d "{{ texlive_dir }}/bin" ]; then + echo "TeXLive is already installed" + else + ./install-tl*/install-tl -v -profile texlive.profile + fi + args: + executable: /bin/bash + chdir: "{{ workdir }}" + notify: remove texlive installation files tags: - bootstrap -- name: clone the template # noqa git-latest - ansible.builtin.git: - repo: "https://github.com/zestedesavoir/latex-template/" - dest: /opt/zds/texmf/tex/generic/latex-template - notify: run texhash +- name: include packages tasks + include_tasks: packages.yml tags: - bootstrap - upgrade +- name: install fontconfig + ansible.builtin.apt: + pkg: fontconfig + state: present + cache_valid_time: 3600 + tags: + - bootstrap + - name: create font folders ansible.builtin.file: path: /usr/local/share/fonts/{{ item[0].path }}/{{ item[1].slug }}/ @@ -56,6 +77,6 @@ - Regular - Semibold - SemiboldIt + notify: refresh font-config cache tags: - bootstrap - notify: refresh font-config cache diff --git a/roles/latex/tasks/packages.yml b/roles/latex/tasks/packages.yml index 5dadfb3..8c5d0a5 100644 --- a/roles/latex/tasks/packages.yml +++ b/roles/latex/tasks/packages.yml @@ -1,53 +1,34 @@ -- name: create tlmgr usertree +- name: clone latex template # noqa git-latest become: true become_user: zds - ansible.builtin.command: tlmgr init-usertree - args: - creates: $HOME/texmf - tags: - - bootstrap - -- name: create ansible state if non-existant - ansible.builtin.file: - path: /opt/zds/texmf/ansible-state - state: touch - mode: u=rw,g=r,o=r - tags: - - bootstrap - -- name: check ansible state - ansible.builtin.slurp: src=/opt/zds/texmf/ansible-state - register: installed_packages + ansible.builtin.git: + repo: "https://github.com/zestedesavoir/latex-template/" + dest: "{{ template_dir }}" + notify: run texhash -- name: install packages # noqa risky-shell-pipe +- name: install latex packages become: true become_user: zds - ansible.builtin.shell: > - # we make sure that tlmgr repository correspond to texlive annual release - texlive_year=$(tlmgr --version) && - texlive_year=$(echo -n $texlive_year | tail -c 4) && - tlmgr option repository http://ftp.math.utah.edu/pub/tex/historic/systems/texlive/$texlive_year/tlnet-final && - # we tell updmap to go user mode, not system mode - updmap-user && - # we update and install - tlmgr update --list && - tlmgr install {{ ' '.join(latex_packages) }} && - echo {{ ' '.join(latex_packages) }} > $HOME/texmf/ansible-state - when: installed_packages.content|b64decode|trim != latex_packages|join(" ") - tags: - - bootstrap + vars: + packages: "{{ template_dir }}/scripts/packages" + ansible.builtin.shell: | + packages=$(cat {{ packages }}) + {{ texlive_binaries }}/tlmgr update --self + {{ texlive_binaries }}/tlmgr install $packages + args: + executable: /bin/bash - name: create tabu directory + become: true + become_user: zds ansible.builtin.file: - path: /opt/zds/texmf/tex/latex/tabu/ + path: "{{ texlive_dir }}/texmf-dist/tex/latex/tabu/" state: directory mode: u=rw,g=r,o=r - tags: - - bootstrap - name: install tabu package + become: true + become_user: zds ansible.builtin.get_url: url: https://raw.githubusercontent.com/tabu-issues-for-future-maintainer/tabu/master/tabu.sty - dest: /opt/zds/texmf/tex/latex/tabu/tabu.sty - tags: - - bootstrap + dest: "{{ texlive_dir }}/texmf-dist/tex/latex/tabu/tabu.sty" diff --git a/roles/latex/templates/texlive.profile b/roles/latex/templates/texlive.profile new file mode 100644 index 0000000..311453f --- /dev/null +++ b/roles/latex/templates/texlive.profile @@ -0,0 +1,31 @@ +# Forked from Zeste de Savoir: +# https://github.com/zestedesavoir/zds-site/blob/a16c5fc932b361cbee5c6e61b24167605e24cd8b/scripts/texlive.profile +selected_scheme scheme-small +TEXMFCONFIG $TEXMFSYSCONFIG +TEXDIR {{ texlive_dir }} +TEXMFLOCAL {{ texlive_dir }}/texmf-local +TEXMFSYSCONFIG {{ texlive_dir }}/texmf-config +TEXMFSYSVAR {{ texlive_dir }}/texmf-var +TEXMFHOME $TEXMFLOCAL +TEXMFVAR $TEXMFSYSVAR +binary_x86_64-linux 1 +collection-basic 1 +collection-latex 1 +collection-latexrecommended 1 +collection-xetex 1 +option_adjustrepo 1 +tlpdbopt_autobackup 1 +tlpdbopt_backupdir tlpkg/backups +tlpdbopt_desktop_integration +option_doc 1 +tlpdbopt_file_assocs +option_fmt 1 +option_letter 0 +option_path +tlpdbopt_post_code 1 +option_src 1 +option_sys_bin /usr/local/bin +option_sys_info /usr/local/share/info +option_sys_man /usr/local/share/man +tlpdbopt_w32_multi_user 1 +portable 1 diff --git a/roles/latex/vars/main.yml b/roles/latex/vars/main.yml index 4cc8b0a..fd79d25 100644 --- a/roles/latex/vars/main.yml +++ b/roles/latex/vars/main.yml @@ -1,39 +1,6 @@ -latex_packages: - - adjustbox - - blindtext - - capt-of - - catoptions - - chemgreek - - cm-super - - collectbox - - ctablestack - - datatool - - environ - - etoolbox - - fontspec - - framed - - fvextra - - geometry - - ifmtarg - - ifplatform - - luacode - - menukeys - - mfirstuc - - mhchem - - minted - - multirow - - ntheorem - - pagecolor - - relsize - - substr - - tcolorbox - - tracklang - - trimspaces - - varwidth - - xfor - - xifthen - - xpatch - - xstring +texlive_dir: "{{ workdir }}/texlive" +texlive_binaries: "{{ texlive_dir }}/bin/x86_64-linux" +template_dir: "{{ texlive_dir }}/texmf-dist/tex/generic/latex-template" fonttypes: - ext: otf