Skip to content

Commit

Permalink
compress executables via upx (see if it helps #394)
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jan 4, 2023
1 parent 81dab01 commit 8ee79e3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
with:
pandoc-version: '2.17.1.1'

- name: Install upx
run: choco install upx

- name: Install R
uses: r-lib/actions/setup-r@v2
with:
Expand Down Expand Up @@ -139,6 +142,7 @@ jobs:

- name: Build TinyTeX-0.zip & install more package
run: |
sudo apt install -y upx
sed -i 's|# finished base|cp $OLDPWD/install-tl-unx.tar.gz tools/; Rscript tools/clean-tlpdb.R; tar zcf TinyTeX-0.tar.gz -C ~ .TinyTeX|' tools/install-unx.sh
./tools/install-unx.sh
Expand Down Expand Up @@ -223,6 +227,7 @@ jobs:

- name: Build TinyTeX-0.zip & install more package
run: |
brew install upx
sed -i '' 's|# finished base|Rscript "${{ github.workspace }}/tools/clean-tlpdb.R"; tar zcf "${{ github.workspace}}/TinyTeX-0.tgz" -C ~/Library TinyTeX|' tools/install-unx.sh
./tools/install-unx.sh
Expand Down Expand Up @@ -257,7 +262,7 @@ jobs:
command: |
gh release upload ${{needs.new-release.outputs.draft-tag}} TinyTeX-0.tgz TinyTeX-1.tgz TinyTeX.tgz TinyTeX-2.tgz --clobber
tinitex:
tinitex:
needs: [new-release]
name: Get tinitex release
runs-on: ubuntu-latest
Expand All @@ -276,7 +281,7 @@ jobs:
7z a -o.. tinitex.zip x86_64-pc-windows-msvc/.
7z a -ttar -so tinitex.tar x86_64-apple-darwin/. | 7z a -si -o.. tinitex.tgz
7z a -ttar -so tinitex.tar x86_64-unknown-linux-gnu/. | 7z a -si -o.. tinitex.tar.gz
- run: ls -lisa tinitex

- name: Upload bundles
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tinytex
Type: Package
Title: Helper Functions to Install and Maintain TeX Live, and Compile LaTeX Documents
Version: 0.43.1
Version: 0.43.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person(family = "RStudio, PBC", role = "cph"),
Expand Down
22 changes: 18 additions & 4 deletions tools/clean-tlpdb.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
if (!requireNamespace('tinytex', quietly = TRUE)) utils::install.packages('tinytex')
# clean texlive.tlpdb.* files
tinytex:::delete_tlpdb_files()
# clean log files
unlink(list.files(
tinytex::tinytex_root(FALSE), '[.]log$', full.names = TRUE, recursive = TRUE
))

local({
files = list.files(tinytex::tinytex_root(FALSE), full.names = TRUE, recursive = TRUE)

# clean log files
unlink(grep('[.]log$', files, value = TRUE))

# compress executables using upx
if (Sys.which('upx') != '') {
if (xfun::is_windows()) {
files = grep('[.](dll|exe)$', files, value = TRUE)
} else {
files = files[file_test('-x', files)]
files = files[sapply(sprintf('file --mime-encoding %s | grep -q binary', shQuote(files)), system) == 0]
}
for (f in shQuote(files)) system2('upx', c('-qq', f))
}
})

0 comments on commit 8ee79e3

Please sign in to comment.