@ottatto/setup-tex 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPENDS.txt +16 -0
- package/LICENSE +21 -0
- package/README.ja.md +196 -0
- package/README.md +192 -2
- package/bin/stex.js +110 -0
- package/check/expected.pdf +0 -0
- package/check/latexmkrc +6 -0
- package/check/sample.bib +7 -0
- package/check/sample.tex +26 -0
- package/package.json +42 -4
- package/scripts/check.ps1 +35 -0
- package/scripts/check.sh +31 -0
- package/scripts/depends.ps1 +38 -0
- package/scripts/depends.sh +58 -0
- package/scripts/setup.ps1 +61 -0
- package/scripts/setup.sh +66 -0
- package/texlive.profile +12 -0
package/DEPENDS.txt
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 たと
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<h1 align="center">Setup TeX</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center"><strong><em>Minimal TeX Live. One command. On your PC and in CI.</em></strong></p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@ottatto/setup-tex"><img src="https://img.shields.io/npm/v/@ottatto/setup-tex?logo=npm&style=for-the-badge" alt="npm"></a>
|
|
7
|
+
<img src="https://img.shields.io/node/v/@ottatto/setup-tex?logo=nodedotjs&style=for-the-badge" alt="Node.js">
|
|
8
|
+
<a href="https://github.com/otTATto/setup-tex/releases"><img src="https://img.shields.io/github/v/release/otTATto/setup-tex?logo=github&style=for-the-badge" alt="GitHub Release"></a>
|
|
9
|
+
<a href="https://github.com/otTATto/setup-tex/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@ottatto/setup-tex?style=for-the-badge" alt="License"></a>
|
|
10
|
+
</p>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://tug.org/texlive/"><img src="https://img.shields.io/badge/TeX_Live-scheme--infraonly-008080?logo=latex&style=for-the-badge" alt="TeX Live"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
[English](README.md) | 日本語
|
|
16
|
+
|
|
17
|
+
$\TeX$ 環境を PC や GitHub Actions にセットアップするための「**個人的な**」設定ファイルとスクリプトです。
|
|
18
|
+
|
|
19
|
+
## 🚀 セットアップ手順
|
|
20
|
+
|
|
21
|
+
### 💻 PC にセットアップする
|
|
22
|
+
|
|
23
|
+
> [!IMPORTANT]
|
|
24
|
+
> Node.js(22 以降)が必要です。
|
|
25
|
+
|
|
26
|
+
1. 以下を実行して、端末の任意の場所から `stex` コマンドを使えるようにします
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm install -g @ottatto/setup-tex
|
|
30
|
+
```
|
|
31
|
+
2. 以下を実行することで、端末に最小構成の TeX Live を導入し、どの文書でも使うような基本的なパッケージ(以降、「基本パッケージ」と呼ぶ。)をインストールします
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
stex setup
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- macOS では、途中で `sudo` のパスワードが必要になります
|
|
38
|
+
- Windows では、PATH を反映させるために、終了後にターミナルを開き直します
|
|
39
|
+
3. 試しに以下を実行し、同梱のサンプルが期待どおりにコンパイルされることを確認します
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
stex check
|
|
43
|
+
```
|
|
44
|
+
4. `✅ Matches check/expected.pdf` と返れば OK です
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
<summary><strong>補足① インストールせずに試してみたい</strong></summary>
|
|
48
|
+
|
|
49
|
+
- 以下のように `npx` を使えば、インストールせずに `stex` コマンドを試せます
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npx @ottatto/setup-tex@latest setup
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- ただし、以降の説明における `stex` を `npx @ottatto/setup-tex@latest` に読み替えて実行する必要があります
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary><strong>補足② 文書ごとに追加でパッケージを入れたい</strong></summary>
|
|
61
|
+
|
|
62
|
+
- 文書のディレクトリに、基本パッケージと同じ形式(`hard <pkg>` 行)の `DEPENDS.txt` を置いておき、そこで以下を実行すると、足りないパッケージを追加でインストールできます
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
cd path/to/document
|
|
66
|
+
stex depends # ./DEPENDS.txt を読む
|
|
67
|
+
stex depends path/to/DEPENDS.txt
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
<details>
|
|
73
|
+
<summary><strong>補足③ Clone してスクリプトを直接実行したい</strong></summary>
|
|
74
|
+
|
|
75
|
+
- `stex` の各コマンドは、`scripts/` のスクリプトを呼んでいるだけなので、Clone したリポジトリで直接実行することもできます
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
# Windows
|
|
79
|
+
scripts\setup.ps1
|
|
80
|
+
scripts\depends.ps1 path\to\DEPENDS.txt
|
|
81
|
+
scripts\check.ps1
|
|
82
|
+
```
|
|
83
|
+
```sh
|
|
84
|
+
# macOS
|
|
85
|
+
scripts/setup.sh
|
|
86
|
+
scripts/depends.sh path/to/DEPENDS.txt
|
|
87
|
+
scripts/check.sh
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
</details>
|
|
91
|
+
|
|
92
|
+
### 🤖 GitHub Actions にセットアップする
|
|
93
|
+
|
|
94
|
+
1. Workflow の yml に以下のように書きます
|
|
95
|
+
|
|
96
|
+
```yml
|
|
97
|
+
- uses: actions/checkout@v7
|
|
98
|
+
- uses: otTATto/setup-tex@v1
|
|
99
|
+
with:
|
|
100
|
+
depends: path/to/DEPENDS.txt # 任意: 基本パッケージの他に追加で入れたいパッケージを指定
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `depends`: ワークスペースからの相対パスで、形式はこのリポジトリの `DEPENDS.txt` と同じ `hard <pkg>` 行です
|
|
104
|
+
- `cache`: インストール先をキャッシュし、2 回目以降はインストールを飛ばします(既定は `true` です)
|
|
105
|
+
- ubuntu / windows / macos のランナーに対応しています
|
|
106
|
+
|
|
107
|
+
## 📝 設定ファイルとスクリプト
|
|
108
|
+
|
|
109
|
+
### ⚙️ 設定ファイル
|
|
110
|
+
|
|
111
|
+
各種設定ファイルは以下のとおりです。
|
|
112
|
+
|
|
113
|
+
| ファイル名 | 役割 |
|
|
114
|
+
| :-- | :-- |
|
|
115
|
+
| `texlive.profile` | TeX Live のインストール設定 |
|
|
116
|
+
| `DEPENDS.txt` | インストールする基本パッケージの定義 |
|
|
117
|
+
|
|
118
|
+
### 📦 setup スクリプト
|
|
119
|
+
|
|
120
|
+
setup スクリプトは、以下の 3 つのことを行います。
|
|
121
|
+
|
|
122
|
+
1. TeX Live 公式インストーラ `install-tl` を取得する
|
|
123
|
+
2. `install-tl` に `texlive.profile` を渡して TeX Live をインストールする
|
|
124
|
+
3. TeX Live に同梱されるパッケージマネージャ `tlmgr` に `DEPENDS.txt` を渡して基本パッケージをインストールする
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><strong>[補足]TeX Live のインストール先を変えたい</strong></summary>
|
|
128
|
+
|
|
129
|
+
- 無指定の場合、TeX Live は `install-tl` の既定の場所(Windows: `C:\texlive\YYYY`, macOS: `/usr/local/texlive/YYYY`)にインストールされます
|
|
130
|
+
- 任意の場所にインストールしたい場合は、以下のように指定してインストールします
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
stex setup --texdir <path>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
</details>
|
|
137
|
+
|
|
138
|
+
### 🧩 depends スクリプト
|
|
139
|
+
|
|
140
|
+
depends スクリプトは、以下の 2 つのことを行います。
|
|
141
|
+
|
|
142
|
+
1. 指定の `DEPENDS.txt`(省略時はカレントディレクトリの `DEPENDS.txt`)から `hard <pkg>` 行のパッケージを読み取る
|
|
143
|
+
2. 既に入っている TeX Live に、`tlmgr` でそのパッケージを追加でインストールし、増えたコマンドにも PATH を通す
|
|
144
|
+
|
|
145
|
+
- インストール先は PATH 上の TeX Live から決められます
|
|
146
|
+
- 別の場所の TeX Live に入れる場合は `--texdir <path>` を指定してください
|
|
147
|
+
|
|
148
|
+
### ⚖️ check スクリプト
|
|
149
|
+
|
|
150
|
+
check スクリプトは、以下の 2 つのことを行います。
|
|
151
|
+
|
|
152
|
+
1. `latexmk` で `check/sample.tex` をコンパイルする
|
|
153
|
+
2. 生成された `check/sample.pdf` が期待する `check/expected.pdf` と一致するか検証する
|
|
154
|
+
|
|
155
|
+
<details>
|
|
156
|
+
<summary><strong>[補足]期待するファイルを新しいものに置き換えたい</strong></summary>
|
|
157
|
+
|
|
158
|
+
- `check/sample.tex` を更新した場合や、TeX Live の更新で生成される PDF が変わった場合などには、以下を実行して、期待するファイル `check/expected.pdf` を新しく作り直すことができます
|
|
159
|
+
|
|
160
|
+
```powershell
|
|
161
|
+
# Windows
|
|
162
|
+
scripts\check.ps1 -Update
|
|
163
|
+
```
|
|
164
|
+
```sh
|
|
165
|
+
# macOS
|
|
166
|
+
scripts/check.sh --update
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
## 🗂️ リポジトリの構造
|
|
172
|
+
|
|
173
|
+
大まかには、以下のような構造になっています。
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
.
|
|
177
|
+
├── bin/ # stex コマンドの入口
|
|
178
|
+
├── check/ # check スクリプトが検証する TeX ファイルなど
|
|
179
|
+
├── scripts/ # setup・depends・check スクリプト
|
|
180
|
+
├── texlive.profile # TeX Live のインストール設定
|
|
181
|
+
├── DEPENDS.txt # インストールする基本パッケージの定義
|
|
182
|
+
├── action.yml # GitHub Actions から setup・depends スクリプトを呼び出す action
|
|
183
|
+
├── package.json
|
|
184
|
+
└── README.md
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 📖 参考
|
|
188
|
+
|
|
189
|
+
- [**TeX Live** - TeX Wiki](https://texwiki.texjp.org/?TeX%20Live)
|
|
190
|
+
- [**TeX Live package dependencies**](https://tug.org/texlive/pkgdepend.html)
|
|
191
|
+
- [**install-tl** - TeX Live cross-platform installer](https://www.tug.org/texlive/doc/install-tl.html)
|
|
192
|
+
- [**latexmk** - TeX Wiki](https://texwiki.texjp.org/?Latexmk)
|
|
193
|
+
|
|
194
|
+
## 📜 ライセンス
|
|
195
|
+
|
|
196
|
+
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,3 +1,193 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">Setup TeX</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center"><strong><em>Minimal <a>TeX Live</a>. One command. On your PC and in CI.</em></strong></p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@ottatto/setup-tex"><img src="https://img.shields.io/npm/v/@ottatto/setup-tex?logo=npm&style=for-the-badge" alt="npm"></a>
|
|
7
|
+
<img src="https://img.shields.io/node/v/@ottatto/setup-tex?logo=nodedotjs&style=for-the-badge" alt="Node.js">
|
|
8
|
+
<a href="https://github.com/otTATto/setup-tex/releases"><img src="https://img.shields.io/github/v/release/otTATto/setup-tex?logo=github&style=for-the-badge" alt="GitHub Release"></a>
|
|
9
|
+
<a href="https://github.com/otTATto/setup-tex/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@ottatto/setup-tex?style=for-the-badge" alt="License"></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
English | [日本語](README.ja.md)
|
|
13
|
+
|
|
14
|
+
My **PERSONAL** config files and scripts for setting up a $\TeX$ environment on a PC or on GitHub Actions.
|
|
15
|
+
|
|
16
|
+
## 🚀 Setup
|
|
17
|
+
|
|
18
|
+
### 💻 On Your PC
|
|
19
|
+
|
|
20
|
+
> [!IMPORTANT]
|
|
21
|
+
> Node.js (22 or later) is required.
|
|
22
|
+
|
|
23
|
+
1. Run the following to make the `stex` command available anywhere in your terminal
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install -g @ottatto/setup-tex
|
|
27
|
+
```
|
|
28
|
+
2. Run the following to install a minimal TeX Live along with the packages used in almost every document (the "basic packages")
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
stex setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- On macOS, you will be asked for your `sudo` password along the way
|
|
35
|
+
- On Windows, reopen the terminal afterwards to pick up the new PATH
|
|
36
|
+
3. To try it out, run the following and make sure the bundled sample compiles as expected
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
stex check
|
|
40
|
+
```
|
|
41
|
+
4. If it says `✅ Matches check/expected.pdf`, you are all set
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary><strong>TIP 1: Try it without installing</strong></summary>
|
|
45
|
+
|
|
46
|
+
- With `npx`, you can try the `stex` command without installing it
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx @ottatto/setup-tex@latest setup
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- In that case, read `stex` in the rest of this README as `npx @ottatto/setup-tex@latest`
|
|
53
|
+
|
|
54
|
+
</details>
|
|
55
|
+
|
|
56
|
+
<details>
|
|
57
|
+
<summary><strong>TIP 2: Install extra packages per document</strong></summary>
|
|
58
|
+
|
|
59
|
+
- Put a `DEPENDS.txt` in the same format as the basic packages (`hard <pkg>` lines) in your document's directory, and run the following there to install the missing packages
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
cd path/to/document
|
|
63
|
+
stex depends # Reads ./DEPENDS.txt
|
|
64
|
+
stex depends path/to/DEPENDS.txt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
<details>
|
|
70
|
+
<summary><strong>TIP 3: Run the scripts directly from a clone</strong></summary>
|
|
71
|
+
|
|
72
|
+
- Each `stex` command just calls a script in `scripts/`, so you can also run them directly in a clone of this repository
|
|
73
|
+
|
|
74
|
+
```powershell
|
|
75
|
+
# Windows
|
|
76
|
+
scripts\setup.ps1
|
|
77
|
+
scripts\depends.ps1 path\to\DEPENDS.txt
|
|
78
|
+
scripts\check.ps1
|
|
79
|
+
```
|
|
80
|
+
```sh
|
|
81
|
+
# macOS
|
|
82
|
+
scripts/setup.sh
|
|
83
|
+
scripts/depends.sh path/to/DEPENDS.txt
|
|
84
|
+
scripts/check.sh
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
</details>
|
|
88
|
+
|
|
89
|
+
### 🤖 On GitHub Actions
|
|
90
|
+
|
|
91
|
+
1. Write the following in your workflow yml
|
|
92
|
+
|
|
93
|
+
```yml
|
|
94
|
+
- uses: actions/checkout@v7
|
|
95
|
+
- uses: otTATto/setup-tex@v1
|
|
96
|
+
with:
|
|
97
|
+
depends: path/to/DEPENDS.txt # Optional: extra packages to install besides the basic packages
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `depends`: A path relative to the workspace, in the same `hard <pkg>` format as this repository's `DEPENDS.txt`
|
|
101
|
+
- `cache`: Caches the installation and skips it from the second run on (defaults to `true`)
|
|
102
|
+
- Supports ubuntu / windows / macos runners
|
|
103
|
+
|
|
104
|
+
## 📝 Config Files and Scripts
|
|
105
|
+
|
|
106
|
+
### ⚙️ Config Files
|
|
107
|
+
|
|
108
|
+
The config files are as follows.
|
|
109
|
+
|
|
110
|
+
| File | Role |
|
|
111
|
+
| :-- | :-- |
|
|
112
|
+
| `texlive.profile` | Installation settings for TeX Live |
|
|
113
|
+
| `DEPENDS.txt` | The basic packages to install |
|
|
114
|
+
|
|
115
|
+
### 📦 setup Script
|
|
116
|
+
|
|
117
|
+
The setup script does the following 3 things.
|
|
118
|
+
|
|
119
|
+
1. Fetches `install-tl`, the official TeX Live installer
|
|
120
|
+
2. Installs TeX Live by passing `texlive.profile` to `install-tl`
|
|
121
|
+
3. Installs the basic packages by passing `DEPENDS.txt` to `tlmgr`, the package manager bundled with TeX Live
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary><strong>TIP: Change where TeX Live is installed</strong></summary>
|
|
125
|
+
|
|
126
|
+
- By default, TeX Live is installed where `install-tl` puts it (Windows: `C:\texlive\YYYY`, macOS: `/usr/local/texlive/YYYY`)
|
|
127
|
+
- To install it elsewhere, specify the location as follows
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
stex setup --texdir <path>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
</details>
|
|
134
|
+
|
|
135
|
+
### 🧩 depends Script
|
|
136
|
+
|
|
137
|
+
The depends script does the following 2 things.
|
|
138
|
+
|
|
139
|
+
1. Reads the packages on the `hard <pkg>` lines of the given `DEPENDS.txt` (defaults to `DEPENDS.txt` in the current directory)
|
|
140
|
+
2. Installs them into the existing TeX Live with `tlmgr`, and puts any new commands on the PATH
|
|
141
|
+
|
|
142
|
+
- The TeX Live to install into is found from the PATH
|
|
143
|
+
- To install into a TeX Live elsewhere, specify `--texdir <path>`
|
|
144
|
+
|
|
145
|
+
### ⚖️ check Script
|
|
146
|
+
|
|
147
|
+
The check script does the following 2 things.
|
|
148
|
+
|
|
149
|
+
1. Compiles `check/sample.tex` with `latexmk`
|
|
150
|
+
2. Verifies that the generated `check/sample.pdf` matches the expected `check/expected.pdf`
|
|
151
|
+
|
|
152
|
+
<details>
|
|
153
|
+
<summary><strong>TIP: Replace the expected file</strong></summary>
|
|
154
|
+
|
|
155
|
+
- When you update `check/sample.tex`, or when a TeX Live update changes the generated PDF, you can regenerate the expected `check/expected.pdf` by running the following
|
|
156
|
+
|
|
157
|
+
```powershell
|
|
158
|
+
# Windows
|
|
159
|
+
scripts\check.ps1 -Update
|
|
160
|
+
```
|
|
161
|
+
```sh
|
|
162
|
+
# macOS
|
|
163
|
+
scripts/check.sh --update
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
</details>
|
|
167
|
+
|
|
168
|
+
## 🗂️ Repository Structure
|
|
169
|
+
|
|
170
|
+
Roughly, the repository is structured as follows.
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
.
|
|
174
|
+
├── bin/ # Entry point of the stex command
|
|
175
|
+
├── check/ # TeX files and more verified by the check script
|
|
176
|
+
├── scripts/ # setup, depends, and check scripts
|
|
177
|
+
├── texlive.profile # Installation settings for TeX Live
|
|
178
|
+
├── DEPENDS.txt # The basic packages to install
|
|
179
|
+
├── action.yml # Action that calls the setup and depends scripts from GitHub Actions
|
|
180
|
+
├── package.json
|
|
181
|
+
└── README.md
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 📖 References
|
|
185
|
+
|
|
186
|
+
- [**TeX Live**](https://tug.org/texlive/)
|
|
187
|
+
- [**TeX Live package dependencies**](https://tug.org/texlive/pkgdepend.html)
|
|
188
|
+
- [**install-tl** - TeX Live cross-platform installer](https://www.tug.org/texlive/doc/install-tl.html)
|
|
189
|
+
- [**latexmk**](https://ctan.org/pkg/latexmk)
|
|
190
|
+
|
|
191
|
+
## 📜 License
|
|
192
|
+
|
|
193
|
+
[MIT](LICENSE)
|
package/bin/stex.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { parseArgs } from 'node:util';
|
|
7
|
+
|
|
8
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
const windows = process.platform === 'win32';
|
|
10
|
+
|
|
11
|
+
const USAGE = `Usage: stex <command> [options]
|
|
12
|
+
|
|
13
|
+
Commands:
|
|
14
|
+
setup [--texdir <dir>] Install a minimal TeX Live with the basic packages
|
|
15
|
+
depends [<DEPENDS.txt>] [--texdir <dir>] Install the packages on the hard lines of DEPENDS.txt
|
|
16
|
+
(defaults to DEPENDS.txt in the current directory)
|
|
17
|
+
check [--update] Compile the sample and compare it with the expected PDF
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
-h, --help Show this usage
|
|
21
|
+
-v, --version Show the version`;
|
|
22
|
+
|
|
23
|
+
// 各コマンドの CLI オプションと、それを sh / ps1 の引数に直す方法
|
|
24
|
+
const COMMANDS = {
|
|
25
|
+
setup: {
|
|
26
|
+
options: { texdir: { type: 'string' } },
|
|
27
|
+
sh: ({ texdir }) => (texdir ? ['--texdir', resolve(texdir)] : []),
|
|
28
|
+
ps1: ({ texdir }) => (texdir ? ['-TexDir', resolve(texdir)] : []),
|
|
29
|
+
},
|
|
30
|
+
depends: {
|
|
31
|
+
options: { texdir: { type: 'string' } },
|
|
32
|
+
positional: true,
|
|
33
|
+
sh: ({ texdir }, path) => [
|
|
34
|
+
...(texdir ? ['--texdir', resolve(texdir)] : []),
|
|
35
|
+
...(path ? [resolve(path)] : []),
|
|
36
|
+
],
|
|
37
|
+
ps1: ({ texdir }, path) => [
|
|
38
|
+
...(texdir ? ['-TexDir', resolve(texdir)] : []),
|
|
39
|
+
...(path ? ['-Path', resolve(path)] : []),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
check: {
|
|
43
|
+
options: { update: { type: 'boolean' } },
|
|
44
|
+
sh: ({ update }) => (update ? ['--update'] : []),
|
|
45
|
+
ps1: ({ update }) => (update ? ['-Update'] : []),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** @param {string} message */
|
|
50
|
+
const fail = (message) => {
|
|
51
|
+
console.error(`❌ ${message}\n\n${USAGE}`);
|
|
52
|
+
process.exit(2);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const [name, ...rest] = process.argv.slice(2);
|
|
56
|
+
if (name === undefined || name === '-h' || name === '--help') {
|
|
57
|
+
console.log(USAGE);
|
|
58
|
+
process.exit(name === undefined ? 2 : 0);
|
|
59
|
+
}
|
|
60
|
+
if (name === '-v' || name === '--version') {
|
|
61
|
+
console.log(JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
const command = COMMANDS[name];
|
|
65
|
+
if (!command) fail(`unknown command: ${name}`);
|
|
66
|
+
|
|
67
|
+
let parsed;
|
|
68
|
+
try {
|
|
69
|
+
parsed = parseArgs({
|
|
70
|
+
args: rest,
|
|
71
|
+
options: { ...command.options, help: { type: 'boolean', short: 'h' } },
|
|
72
|
+
allowPositionals: true,
|
|
73
|
+
});
|
|
74
|
+
} catch (err) {
|
|
75
|
+
fail(err instanceof Error ? err.message : String(err));
|
|
76
|
+
}
|
|
77
|
+
const { values, positionals } = parsed;
|
|
78
|
+
if (values.help) {
|
|
79
|
+
console.log(USAGE);
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
if (positionals.length > (command.positional ? 1 : 0)) {
|
|
83
|
+
fail(`too many arguments: ${positionals.join(' ')}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const [file, args] = windows
|
|
87
|
+
? [
|
|
88
|
+
'powershell.exe',
|
|
89
|
+
[
|
|
90
|
+
'-NoProfile',
|
|
91
|
+
'-ExecutionPolicy',
|
|
92
|
+
'Bypass',
|
|
93
|
+
'-File',
|
|
94
|
+
join(root, 'scripts', `${name}.ps1`),
|
|
95
|
+
...command.ps1(values, positionals[0]),
|
|
96
|
+
],
|
|
97
|
+
]
|
|
98
|
+
: ['sh', [join(root, 'scripts', `${name}.sh`), ...command.sh(values, positionals[0])]];
|
|
99
|
+
|
|
100
|
+
// pwsh (PowerShell 7) から起動すると、PSModulePath に PowerShell 7 のモジュールが入ったまま引き継がれ、
|
|
101
|
+
// Windows PowerShell 5.1 が Get-FileHash などを読み込めなくなるので、外して既定に戻させる
|
|
102
|
+
const env = windows
|
|
103
|
+
? Object.fromEntries(Object.entries(process.env).filter(([key]) => key.toLowerCase() !== 'psmodulepath'))
|
|
104
|
+
: process.env;
|
|
105
|
+
const result = spawnSync(file, args, { stdio: 'inherit', env });
|
|
106
|
+
if (result.error) {
|
|
107
|
+
console.error(`❌ failed to run ${file}: ${result.error.message}`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
process.exit(result.status ?? 1);
|
|
Binary file
|
package/check/latexmkrc
ADDED
package/check/sample.bib
ADDED
package/check/sample.tex
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
% setup.tex の動作確認用文書
|
|
2
|
+
\documentclass[a4paper]{jarticle}
|
|
3
|
+
|
|
4
|
+
\title{動作確認}
|
|
5
|
+
\author{setup.tex}
|
|
6
|
+
\date{}
|
|
7
|
+
|
|
8
|
+
\begin{document}
|
|
9
|
+
\maketitle
|
|
10
|
+
|
|
11
|
+
\section{和文と欧文}
|
|
12
|
+
吾輩は猫である。名前は\textbf{まだ無い}。
|
|
13
|
+
The quick brown fox jumps over \textbf{the lazy dog}.
|
|
14
|
+
|
|
15
|
+
\section{数式}
|
|
16
|
+
\begin{equation}
|
|
17
|
+
e^{i\pi} + 1 = 0, \qquad
|
|
18
|
+
\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}
|
|
19
|
+
\end{equation}
|
|
20
|
+
|
|
21
|
+
\section{参考文献}
|
|
22
|
+
\LaTeX{} の解説書 \cite{lamport} を参照。
|
|
23
|
+
|
|
24
|
+
\bibliographystyle{junsrt}
|
|
25
|
+
\bibliography{sample}
|
|
26
|
+
\end{document}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ottatto/setup-tex",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Install a minimal TeX Live with basic (p)LaTeX packages, and add packages listed in DEPENDS.txt.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tex",
|
|
7
|
+
"latex",
|
|
8
|
+
"platex",
|
|
9
|
+
"texlive",
|
|
10
|
+
"tlmgr",
|
|
11
|
+
"setup"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/otTATto/setup-tex#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/otTATto/setup-tex/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/otTATto/setup-tex.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "otTATto",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"setup-tex": "bin/stex.js",
|
|
26
|
+
"stex": "bin/stex.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"scripts",
|
|
31
|
+
"check/sample.tex",
|
|
32
|
+
"check/sample.bib",
|
|
33
|
+
"check/latexmkrc",
|
|
34
|
+
"check/expected.pdf",
|
|
35
|
+
"texlive.profile",
|
|
36
|
+
"DEPENDS.txt"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
check/sample.tex をコンパイルし、期待する check/expected.pdf と一致するか確かめる
|
|
4
|
+
.PARAMETER Update
|
|
5
|
+
比較せず、生成した PDF で check/expected.pdf を置き換える
|
|
6
|
+
#>
|
|
7
|
+
param([switch]$Update)
|
|
8
|
+
$ErrorActionPreference = 'Stop'
|
|
9
|
+
|
|
10
|
+
$check = Join-Path (Split-Path $PSScriptRoot -Parent) 'check'
|
|
11
|
+
$actual = "$check\sample.pdf"
|
|
12
|
+
$expected = "$check\expected.pdf"
|
|
13
|
+
|
|
14
|
+
# 日時を固定し、同じ入力からは同じバイト列の PDF が出るようにする
|
|
15
|
+
$env:SOURCE_DATE_EPOCH = '0'
|
|
16
|
+
$env:FORCE_SOURCE_DATE = '1'
|
|
17
|
+
|
|
18
|
+
latexmk -cd -r "$check\latexmkrc" "$check\sample.tex"
|
|
19
|
+
if ($LASTEXITCODE) { throw "❌ Compilation failed (exit $LASTEXITCODE)" }
|
|
20
|
+
latexmk -cd -r "$check\latexmkrc" -c "$check\sample.tex" | Out-Null
|
|
21
|
+
|
|
22
|
+
if ($Update) {
|
|
23
|
+
Move-Item -Force $actual $expected
|
|
24
|
+
Write-Host "⚠️ Updated check/expected.pdf"
|
|
25
|
+
exit 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ((Get-FileHash $actual).Hash -eq (Get-FileHash $expected).Hash) {
|
|
29
|
+
Remove-Item $actual
|
|
30
|
+
Write-Host '✅ Matches check/expected.pdf'
|
|
31
|
+
exit 0
|
|
32
|
+
}
|
|
33
|
+
Write-Host '🚨 Does not match check/expected.pdf; compare it with check/sample.pdf'
|
|
34
|
+
Write-Host '🤔 TeX Live updates can change the output; if it looks fine, run with -Update to replace the expected PDF'
|
|
35
|
+
exit 1
|
package/scripts/check.sh
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# check/sample.tex をコンパイルし、期待する check/expected.pdf と一致するか確かめる
|
|
3
|
+
#
|
|
4
|
+
# 使い方: scripts/check.sh [--update]
|
|
5
|
+
# --update 比較せず、生成した PDF で check/expected.pdf を置き換える
|
|
6
|
+
set -eu
|
|
7
|
+
|
|
8
|
+
check=$(cd "$(dirname "$0")/../check" && pwd)
|
|
9
|
+
actual=$check/sample.pdf
|
|
10
|
+
expected=$check/expected.pdf
|
|
11
|
+
|
|
12
|
+
# 日時を固定し、同じ入力からは同じバイト列の PDF が出るようにする
|
|
13
|
+
export SOURCE_DATE_EPOCH=0 FORCE_SOURCE_DATE=1
|
|
14
|
+
|
|
15
|
+
latexmk -cd -r "$check/latexmkrc" "$check/sample.tex"
|
|
16
|
+
latexmk -cd -r "$check/latexmkrc" -c "$check/sample.tex" > /dev/null
|
|
17
|
+
|
|
18
|
+
if [ "${1:-}" = --update ]; then
|
|
19
|
+
mv -f "$actual" "$expected"
|
|
20
|
+
echo '⚠️ Updated check/expected.pdf'
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
if cmp -s "$actual" "$expected"; then
|
|
25
|
+
rm -f "$actual"
|
|
26
|
+
echo '✅ Matches check/expected.pdf'
|
|
27
|
+
exit 0
|
|
28
|
+
fi
|
|
29
|
+
echo '🚨 Does not match check/expected.pdf; compare it with check/sample.pdf'
|
|
30
|
+
echo '🤔 TeX Live updates can change the output; if it looks fine, run with --update to replace the expected PDF'
|
|
31
|
+
exit 1
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
入っている TeX Live に、DEPENDS.txt の hard 行のパッケージを追加でインストールする
|
|
4
|
+
.PARAMETER Path
|
|
5
|
+
hard <pkg> 行を並べたファイル(省略時はカレントディレクトリの DEPENDS.txt)
|
|
6
|
+
.PARAMETER TexDir
|
|
7
|
+
TeX Live のインストール先(省略時は PATH 上の TeX Live から求める)
|
|
8
|
+
#>
|
|
9
|
+
param(
|
|
10
|
+
[string]$Path = 'DEPENDS.txt',
|
|
11
|
+
[string]$TexDir
|
|
12
|
+
)
|
|
13
|
+
$ErrorActionPreference = 'Stop'
|
|
14
|
+
|
|
15
|
+
if (-not (Test-Path -PathType Leaf $Path)) { throw "❌ $Path not found" }
|
|
16
|
+
|
|
17
|
+
if (-not $TexDir) {
|
|
18
|
+
$cmd = Get-Command tlmgr -ErrorAction SilentlyContinue
|
|
19
|
+
if (-not $cmd) { throw '❌ TeX Live not found; install it with setup first' }
|
|
20
|
+
# <TexDir>\bin\windows\tlmgr.bat から 3 つさかのぼる
|
|
21
|
+
$TexDir = Split-Path (Split-Path (Split-Path $cmd.Source -Parent) -Parent) -Parent
|
|
22
|
+
}
|
|
23
|
+
$tlmgr = "$TexDir\bin\windows\tlmgr.bat"
|
|
24
|
+
if (-not (Test-Path $tlmgr)) { throw "❌ tlmgr not found in $TexDir" }
|
|
25
|
+
|
|
26
|
+
# Get-Content は PowerShell 5.1 で UTF-8 を Shift_JIS として読むため、.NET の UTF-8 API で読む
|
|
27
|
+
$packages = @([IO.File]::ReadAllLines((Resolve-Path $Path)) | ForEach-Object {
|
|
28
|
+
if ($_ -match '^\s*hard\s+(\S+)') { $Matches[1] }
|
|
29
|
+
})
|
|
30
|
+
if (-not $packages) {
|
|
31
|
+
Write-Host "⚠️ No hard lines in $Path"
|
|
32
|
+
exit 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
& $tlmgr install @packages
|
|
36
|
+
if ($LASTEXITCODE) { throw "❌ tlmgr install failed (exit $LASTEXITCODE)" }
|
|
37
|
+
|
|
38
|
+
Write-Host "✅ Installed the packages in $Path"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# 入っている TeX Live に、DEPENDS.txt の hard 行のパッケージを追加でインストールする
|
|
3
|
+
#
|
|
4
|
+
# 使い方: scripts/depends.sh [--texdir <dir>] [<DEPENDS.txt>]
|
|
5
|
+
# <DEPENDS.txt> hard <pkg> 行を並べたファイル(省略時はカレントディレクトリの DEPENDS.txt)
|
|
6
|
+
# --texdir TeX Live のインストール先(省略時は PATH 上の TeX Live から求める)
|
|
7
|
+
set -eu
|
|
8
|
+
|
|
9
|
+
texdir=
|
|
10
|
+
file=
|
|
11
|
+
while [ $# -gt 0 ]; do
|
|
12
|
+
case $1 in
|
|
13
|
+
--texdir) texdir=$2; shift 2 ;;
|
|
14
|
+
-*) echo "❌ unknown option: $1" >&2; exit 2 ;;
|
|
15
|
+
*)
|
|
16
|
+
if [ -n "$file" ]; then echo "❌ too many arguments: $1" >&2; exit 2; fi
|
|
17
|
+
file=$1; shift ;;
|
|
18
|
+
esac
|
|
19
|
+
done
|
|
20
|
+
file=${file:-DEPENDS.txt}
|
|
21
|
+
|
|
22
|
+
if [ ! -f "$file" ]; then
|
|
23
|
+
echo "❌ $file not found" >&2
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
if [ -z "$texdir" ]; then
|
|
28
|
+
if ! command -v kpsewhich > /dev/null; then
|
|
29
|
+
echo '❌ TeX Live not found; install it with setup first' >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
texdir=$(kpsewhich -var-value=SELFAUTOPARENT)
|
|
33
|
+
fi
|
|
34
|
+
tlmgr=$(echo "$texdir"/bin/*/tlmgr)
|
|
35
|
+
if [ ! -x "$tlmgr" ]; then
|
|
36
|
+
echo "❌ tlmgr not found in $texdir" >&2
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# インストール先と、コマンドのリンクを張る先の両方に書き込めないときは root でやり直す
|
|
41
|
+
sys_bin=$("$tlmgr" option sys_bin | sed 's/.*: //')
|
|
42
|
+
if [ "$(id -u)" -ne 0 ] && { [ ! -w "$texdir" ] || [ ! -w "$sys_bin" ]; }; then
|
|
43
|
+
echo "🔑 Running with sudo to write to $texdir and $sys_bin"
|
|
44
|
+
exec sudo sh "$0" --texdir "$texdir" "$file"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
packages=$(sed -n 's/^[[:space:]]*hard[[:space:]]\{1,\}\([^[:space:]#]\{1,\}\).*/\1/p' "$file")
|
|
48
|
+
if [ -z "$packages" ]; then
|
|
49
|
+
echo "⚠️ No hard lines in $file"
|
|
50
|
+
exit 0
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# shellcheck disable=SC2086
|
|
54
|
+
"$tlmgr" install $packages
|
|
55
|
+
# 増えたコマンドにもシンボリックリンクを張る
|
|
56
|
+
"$tlmgr" path add
|
|
57
|
+
|
|
58
|
+
echo "✅ Installed the packages in $file"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
最小構成の TeX Live を導入し、DEPENDS.txt のパッケージをインストールする
|
|
4
|
+
.PARAMETER TexDir
|
|
5
|
+
インストール先(省略時は install-tl の既定 C:\texlive\YYYY になる)
|
|
6
|
+
#>
|
|
7
|
+
param(
|
|
8
|
+
[string]$TexDir
|
|
9
|
+
)
|
|
10
|
+
$ErrorActionPreference = 'Stop'
|
|
11
|
+
$ProgressPreference = 'SilentlyContinue' # Expand-Archive の進捗表示を省く
|
|
12
|
+
|
|
13
|
+
# mirror.ctan.org は毎回別のミラーへリダイレクトするが、
|
|
14
|
+
# curl の --retry は証明書エラーなどを再試行しないので、失敗したら取得し直す
|
|
15
|
+
# Invoke-WebRequest は一部のミラーに拒否されるため、Windows 標準の curl.exe を使う
|
|
16
|
+
function Get-CtanFile([string]$Path, [string]$OutFile) {
|
|
17
|
+
$url = "https://mirror.ctan.org/$Path"
|
|
18
|
+
$max = 5
|
|
19
|
+
for ($i = 1; ; $i++) {
|
|
20
|
+
curl.exe -fsSL --retry 3 -o $OutFile $url
|
|
21
|
+
$status = $LASTEXITCODE
|
|
22
|
+
if (-not $status) { return }
|
|
23
|
+
if ($i -ge $max) { throw "❌ Failed to fetch $url after $max attempts (curl exit $status)" }
|
|
24
|
+
Write-Warning "Attempt $i/$max to fetch $url failed (curl exit $status); retrying with another mirror in $($i * 5)s"
|
|
25
|
+
Start-Sleep -Seconds ($i * 5)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$root = Split-Path $PSScriptRoot -Parent
|
|
30
|
+
$work = Join-Path ([IO.Path]::GetTempPath()) "setup.tex-$PID"
|
|
31
|
+
New-Item -ItemType Directory $work | Out-Null
|
|
32
|
+
try {
|
|
33
|
+
# 1. install-tl を取得
|
|
34
|
+
$zip = Join-Path $work 'install-tl.zip'
|
|
35
|
+
Get-CtanFile 'systems/texlive/tlnet/install-tl.zip' $zip
|
|
36
|
+
Expand-Archive $zip $work
|
|
37
|
+
$installer = (Get-ChildItem $work -Directory -Filter 'install-tl-*')[0].FullName
|
|
38
|
+
|
|
39
|
+
if (-not $TexDir) {
|
|
40
|
+
$year = (Select-String "$installer\release-texlive.txt" -Pattern 'version (\d{4})').Matches[0].Groups[1].Value
|
|
41
|
+
$TexDir = "C:\texlive\$year"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# 2. texlive.profile を渡して TeX Live をインストール
|
|
45
|
+
& "$installer\install-tl-windows.bat" -no-gui -profile "$root\texlive.profile" -texdir $TexDir
|
|
46
|
+
if ($LASTEXITCODE) { throw "❌ install-tl failed (exit $LASTEXITCODE)" }
|
|
47
|
+
|
|
48
|
+
# 3. DEPENDS.txt のパッケージをインストール
|
|
49
|
+
# Get-Content は PowerShell 5.1 で UTF-8 を Shift_JIS として読み、日本語コメントの
|
|
50
|
+
# 文字化けで改行が消えて hard 行が欠けることがあるため、.NET の UTF-8 API で読む
|
|
51
|
+
$packages = [IO.File]::ReadAllLines("$root\DEPENDS.txt") | ForEach-Object {
|
|
52
|
+
if ($_ -match '^\s*hard\s+(\S+)') { $Matches[1] }
|
|
53
|
+
}
|
|
54
|
+
& "$TexDir\bin\windows\tlmgr.bat" install @packages
|
|
55
|
+
if ($LASTEXITCODE) { throw "❌ tlmgr install failed (exit $LASTEXITCODE)" }
|
|
56
|
+
|
|
57
|
+
Write-Host "✅ Installed TeX Live to $TexDir; reopen the terminal to pick up the new PATH"
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
Remove-Item -Recurse -Force $work
|
|
61
|
+
}
|
package/scripts/setup.sh
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# 最小構成の TeX Live を導入し、DEPENDS.txt のパッケージをインストールする
|
|
3
|
+
#
|
|
4
|
+
# 使い方: scripts/setup.sh [--texdir <dir>]
|
|
5
|
+
# --texdir インストール先(省略時は install-tl の既定 /usr/local/texlive/YYYY になる)
|
|
6
|
+
set -eu
|
|
7
|
+
|
|
8
|
+
# /usr/local 以下に書き込むので、root でなければ sudo で実行し直す
|
|
9
|
+
# ただし sudo は PATH を置き換え、sudo npx では node が見つからないことがあるため、呼び出し側では sudo しない
|
|
10
|
+
if [ "$(id -u)" -ne 0 ]; then
|
|
11
|
+
exec sudo sh "$0" "$@"
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
15
|
+
texdir=
|
|
16
|
+
while [ $# -gt 0 ]; do
|
|
17
|
+
case $1 in
|
|
18
|
+
--texdir) texdir=$2; shift 2 ;;
|
|
19
|
+
*) echo "❌ unknown option: $1" >&2; exit 2 ;;
|
|
20
|
+
esac
|
|
21
|
+
done
|
|
22
|
+
|
|
23
|
+
# mirror.ctan.org は毎回別のミラーへリダイレクトするが、
|
|
24
|
+
# curl の --retry は証明書エラーなどを再試行しないので、失敗したら取得し直す
|
|
25
|
+
fetch_ctan() {
|
|
26
|
+
url=https://mirror.ctan.org/$1
|
|
27
|
+
out=$2
|
|
28
|
+
max=5
|
|
29
|
+
i=1
|
|
30
|
+
while :; do
|
|
31
|
+
curl -fsSL --retry 3 -o "$out" "$url" && return 0
|
|
32
|
+
status=$?
|
|
33
|
+
if [ "$i" -ge "$max" ]; then
|
|
34
|
+
echo "❌ failed to fetch $url after $max attempts (curl exit $status)" >&2
|
|
35
|
+
return 1
|
|
36
|
+
fi
|
|
37
|
+
echo "⚠️ attempt $i/$max to fetch $url failed (curl exit $status); retrying with another mirror in $((i * 5))s" >&2
|
|
38
|
+
sleep $((i * 5))
|
|
39
|
+
i=$((i + 1))
|
|
40
|
+
done
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
work=$(mktemp -d)
|
|
44
|
+
trap 'rm -rf "$work"' EXIT
|
|
45
|
+
|
|
46
|
+
# 1. install-tl を取得
|
|
47
|
+
fetch_ctan systems/texlive/tlnet/install-tl-unx.tar.gz "$work/install-tl-unx.tar.gz"
|
|
48
|
+
tar -xzf "$work/install-tl-unx.tar.gz" -C "$work"
|
|
49
|
+
installer=$(echo "$work"/install-tl-[0-9]*)
|
|
50
|
+
|
|
51
|
+
if [ -z "$texdir" ]; then
|
|
52
|
+
year=$(sed -n 's/.*version \([0-9]\{4\}\).*/\1/p' "$installer/release-texlive.txt" | head -n 1)
|
|
53
|
+
texdir=/usr/local/texlive/$year
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# 2. texlive.profile を渡して TeX Live をインストール
|
|
57
|
+
"$installer/install-tl" -profile "$root/texlive.profile" -texdir "$texdir"
|
|
58
|
+
|
|
59
|
+
# 3. DEPENDS.txt のパッケージをインストール
|
|
60
|
+
packages=$(sed -n 's/^[[:space:]]*hard[[:space:]]\{1,\}\([^[:space:]#]\{1,\}\).*/\1/p' "$root/DEPENDS.txt")
|
|
61
|
+
tlmgr=$(echo "$texdir"/bin/*)/tlmgr
|
|
62
|
+
# shellcheck disable=SC2086
|
|
63
|
+
"$tlmgr" install $packages
|
|
64
|
+
"$tlmgr" path add
|
|
65
|
+
|
|
66
|
+
echo "✅ Installed TeX Live to $texdir"
|
package/texlive.profile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# install-tl に渡すプロファイル
|
|
2
|
+
selected_scheme scheme-infraonly
|
|
3
|
+
instopt_adjustpath 1
|
|
4
|
+
instopt_adjustrepo 1
|
|
5
|
+
instopt_letter 0
|
|
6
|
+
instopt_write18_restricted 1
|
|
7
|
+
tlpdbopt_autobackup 0
|
|
8
|
+
tlpdbopt_desktop_integration 0
|
|
9
|
+
tlpdbopt_file_assocs 0
|
|
10
|
+
tlpdbopt_install_docfiles 0
|
|
11
|
+
tlpdbopt_install_srcfiles 0
|
|
12
|
+
tlpdbopt_w32_multi_user 0
|