@@ -33,6 +33,7 @@ import { suggestUserBinPaths } from "../../core/path.ts";
3333
3434import { ensureDirSync , walkSync } from "../../deno_ral/fs.ts" ;
3535import {
36+ arch ,
3637 isLinux ,
3738 isMac ,
3839 isWindows ,
@@ -65,15 +66,6 @@ export const tinyTexInstallable: InstallableTool = {
6566 } ,
6667 os : [ "darwin" ] ,
6768 message : "The directory /usr/local/bin is not writable." ,
68- } , {
69- check : ( ) => {
70- // Can't be a linux non-x86 platform
71- const needsSource = needsSourceInstall ( ) ;
72- return Promise . resolve ( ! needsSource ) ;
73- } ,
74- os : [ "linux" ] ,
75- message :
76- "This platform doesn't support installation at this time. Please install manually instead. See https://yihui.org/tinytex/#installation." ,
7769 } ] ,
7870 installed,
7971 installDir,
@@ -161,14 +153,11 @@ async function preparePackage(
161153 const version = pkgInfo . version ;
162154
163155 // target package information
164- const pkgName = tinyTexPkgName ( kPackageMaximal , version ) ;
165- const filePath = join ( context . workingDir , pkgName ) ;
166-
167- // Download the package
168- const url = tinyTexUrl ( pkgName , pkgInfo ) ;
169- if ( url ) {
170- // Download the package
171- await context . download ( `TinyTex ${ version } ` , url , filePath ) ;
156+ const candidates = tinyTexPkgName ( kPackageMaximal , version ) ;
157+ const result = tinyTexUrl ( candidates , pkgInfo ) ;
158+ if ( result ) {
159+ const filePath = join ( context . workingDir , result . name ) ;
160+ await context . download ( `TinyTex ${ version } ` , result . url , filePath ) ;
172161 return { filePath, version } ;
173162 } else {
174163 context . error ( "Couldn't determine what URL to use to download" ) ;
@@ -502,22 +491,55 @@ async function textLiveRepo() {
502491 return autoUrl ;
503492}
504493
505- function tinyTexPkgName ( base ?: string , ver ?: string ) {
506- const ext = isWindows ? "zip" : isLinux ? "tar.gz" : "tgz" ;
494+ export function tinyTexPkgName (
495+ base ?: string ,
496+ ver ?: string ,
497+ options ?: { os ?: string ; arch ?: string } ,
498+ ) : string [ ] {
499+ const effectiveOs = options ?. os ??
500+ ( isWindows ? "windows" : isLinux ? "linux" : "darwin" ) ;
501+ const effectiveArch = options ?. arch ?? arch ;
507502
508503 base = base || "TinyTeX" ;
509- if ( ver ) {
510- return `${ base } -${ ver } .${ ext } ` ;
504+
505+ if ( ! ver ) {
506+ const ext = effectiveOs === "windows"
507+ ? "zip"
508+ : effectiveOs === "linux"
509+ ? "tar.gz"
510+ : "tgz" ;
511+ return [ `${ base } .${ ext } ` ] ;
512+ }
513+
514+ const candidates : string [ ] = [ ] ;
515+
516+ if ( effectiveOs === "windows" ) {
517+ candidates . push ( `${ base } -windows-${ ver } .exe` ) ;
518+ candidates . push ( `${ base } -${ ver } .zip` ) ;
519+ } else if ( effectiveOs === "linux" ) {
520+ if ( effectiveArch === "aarch64" ) {
521+ candidates . push ( `${ base } -linux-arm64-${ ver } .tar.xz` ) ;
522+ candidates . push ( `${ base } -arm64-${ ver } .tar.gz` ) ;
523+ } else {
524+ candidates . push ( `${ base } -linux-x86_64-${ ver } .tar.xz` ) ;
525+ candidates . push ( `${ base } -${ ver } .tar.gz` ) ;
526+ }
511527 } else {
512- return `${ base } .${ ext } ` ;
528+ candidates . push ( `${ base } -darwin-${ ver } .tar.xz` ) ;
529+ candidates . push ( `${ base } -${ ver } .tgz` ) ;
513530 }
531+
532+ return candidates ;
514533}
515534
516- function tinyTexUrl ( pkg : string , remotePkgInfo : RemotePackageInfo ) {
517- const asset = remotePkgInfo . assets . find ( ( asset ) => {
518- return asset . name === pkg ;
519- } ) ;
520- return asset ?. url ;
535+ function tinyTexUrl ( candidates : string [ ] , remotePkgInfo : RemotePackageInfo ) {
536+ for ( const pkg of candidates ) {
537+ const asset = remotePkgInfo . assets . find ( ( asset ) => asset . name === pkg ) ;
538+ if ( asset ) {
539+ return { url : asset . url , name : pkg } ;
540+ }
541+ }
542+ return undefined ;
521543}
522544
523545async function remotePackageInfo ( ) : Promise < RemotePackageInfo > {
@@ -537,14 +559,6 @@ async function isWritable(path: string) {
537559 return status . state === "granted" ;
538560}
539561
540- function needsSourceInstall ( ) {
541- if ( isLinux && Deno . build . arch !== "x86_64" ) {
542- return true ;
543- } else {
544- return false ;
545- }
546- }
547-
548562async function isTinyTex ( ) {
549563 const root = await texLiveRoot ( ) ;
550564 if ( root ) {
0 commit comments