@@ -502,17 +502,33 @@ pub fn is_pr_channel(channel: &String) -> bool {
502
502
return Regex :: new ( r"^(pr\d+)(~|$)" ) . unwrap ( ) . is_match ( channel) ;
503
503
}
504
504
505
+ fn parse_nightly_channel_or_id ( channel : & str ) -> Option < String > {
506
+ let nightly_re =
507
+ Regex :: new ( r"^((?:nightly|latest)|latest|(\d+\.\d+)-(?:nightly|latest))" ) . unwrap ( ) ;
508
+
509
+ let caps = nightly_re. captures ( channel) ?;
510
+ if let Some ( xy_match) = caps. get ( 2 ) {
511
+ Some ( xy_match. as_str ( ) . to_string ( ) )
512
+ } else {
513
+ Some ( "" . to_string ( ) )
514
+ }
515
+ }
516
+
505
517
// Identify the unversioned name of a nightly (e.g., `latest-macos-x86_64`) for a channel
506
518
pub fn channel_to_name ( channel : & String ) -> Result < String > {
507
519
let mut parts = channel. splitn ( 2 , '~' ) ;
508
520
509
521
let channel = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
510
522
511
- let version = match channel {
512
- "nightly" => "latest" ,
513
- other => other,
523
+ let version = if let Some ( version_prefix) = parse_nightly_channel_or_id ( channel) {
524
+ if version_prefix. is_empty ( ) {
525
+ "latest" . to_string ( )
526
+ } else {
527
+ format ! ( "{}-latest" , version_prefix)
528
+ }
529
+ } else {
530
+ channel. to_string ( )
514
531
} ;
515
-
516
532
let arch = match parts. next ( ) {
517
533
Some ( arch) => arch. to_string ( ) ,
518
534
None => default_arch ( ) ?,
@@ -621,41 +637,86 @@ pub fn install_non_db_version(
621
637
) -> Result < crate :: config_file:: JuliaupConfigChannel > {
622
638
// Determine the download URL
623
639
let download_url_base = get_julianightlies_base_url ( ) ?;
640
+
624
641
let mut parts = name. splitn ( 2 , '-' ) ;
625
- let id = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
626
- let arch = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
627
- let download_url_path = if id == "latest" {
642
+
643
+ let mut id = parts
644
+ . next ( )
645
+ . expect ( "Failed to parse channel name." )
646
+ . to_string ( ) ;
647
+ let mut arch = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
648
+
649
+ // Check for the case where name is given as "x.y-latest-...", in which case
650
+ // we peel off the "latest" part of the `arch` and attach it to the `id``.
651
+ if arch. starts_with ( "latest" ) {
652
+ let mut parts = arch. splitn ( 2 , '-' ) ;
653
+ let nightly = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
654
+ id. push_str ( "-" ) ;
655
+ id. push_str ( nightly) ;
656
+ arch = parts. next ( ) . expect ( "Failed to parse channel name." ) ;
657
+ }
658
+
659
+ let nightly_version = parse_nightly_channel_or_id ( & id) ;
660
+
661
+ let download_url_path = if let Some ( nightly_version) = nightly_version {
662
+ let nightly_folder = if nightly_version. is_empty ( ) {
663
+ "" . to_string ( ) // No version folder
664
+ } else {
665
+ format ! ( "/{}" , nightly_version) // Use version as folder
666
+ } ;
628
667
match arch {
629
- "macos-x86_64" => Ok ( "bin/macos/x86_64/julia-latest-macos-x86_64.tar.gz" . to_owned ( ) ) ,
630
- "macos-aarch64" => Ok ( "bin/macos/aarch64/julia-latest-macos-aarch64.tar.gz" . to_owned ( ) ) ,
631
- "win64" => Ok ( "bin/winnt/x64/julia-latest-win64.tar.gz" . to_owned ( ) ) ,
632
- "win32" => Ok ( "bin/winnt/x86/julia-latest-win32.tar.gz" . to_owned ( ) ) ,
633
- "linux-x86_64" => Ok ( "bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz" . to_owned ( ) ) ,
634
- "linux-i686" => Ok ( "bin/linux/i686/julia-latest-linux-i686.tar.gz" . to_owned ( ) ) ,
635
- "linux-aarch64" => Ok ( "bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz" . to_owned ( ) ) ,
636
- "freebsd-x86_64" => {
637
- Ok ( "bin/freebsd/x86_64/julia-latest-freebsd-x86_64.tar.gz" . to_owned ( ) )
638
- }
668
+ "macos-x86_64" => Ok ( format ! (
669
+ "bin/macos/x86_64{}/julia-latest-macos-x86_64.tar.gz" ,
670
+ nightly_folder
671
+ ) ) ,
672
+ "macos-aarch64" => Ok ( format ! (
673
+ "bin/macos/aarch64{}/julia-latest-macos-aarch64.tar.gz" ,
674
+ nightly_folder
675
+ ) ) ,
676
+ "win64" => Ok ( format ! (
677
+ "bin/winnt/x64{}/julia-latest-win64.tar.gz" ,
678
+ nightly_folder
679
+ ) ) ,
680
+ "win32" => Ok ( format ! (
681
+ "bin/winnt/x86{}/julia-latest-win32.tar.gz" ,
682
+ nightly_folder
683
+ ) ) ,
684
+ "linux-x86_64" => Ok ( format ! (
685
+ "bin/linux/x86_64{}/julia-latest-linux-x86_64.tar.gz" ,
686
+ nightly_folder
687
+ ) ) ,
688
+ "linux-i686" => Ok ( format ! (
689
+ "bin/linux/i686{}/julia-latest-linux-i686.tar.gz" ,
690
+ nightly_folder
691
+ ) ) ,
692
+ "linux-aarch64" => Ok ( format ! (
693
+ "bin/linux/aarch64{}/julia-latest-linux-aarch64.tar.gz" ,
694
+ nightly_folder
695
+ ) ) ,
696
+ "freebsd-x86_64" => Ok ( format ! (
697
+ "bin/freebsd/x86_64{}/julia-latest-freebsd-x86_64.tar.gz" ,
698
+ nightly_folder
699
+ ) ) ,
639
700
_ => Err ( anyhow ! ( "Unknown nightly." ) ) ,
640
701
}
641
702
} else if id. starts_with ( "pr" ) {
642
703
match arch {
643
704
// https://github.com/JuliaLang/juliaup/issues/903#issuecomment-2183206994
644
705
"macos-x86_64" => {
645
- Ok ( "bin/macos/x86_64/julia-" . to_owned ( ) + id + "-macos-x86_64.tar.gz" )
706
+ Ok ( "bin/macos/x86_64/julia-" . to_owned ( ) + & id + "-macos-x86_64.tar.gz" )
646
707
}
647
708
"macos-aarch64" => {
648
- Ok ( "bin/macos/aarch64/julia-" . to_owned ( ) + id + "-macos-aarch64.tar.gz" )
709
+ Ok ( "bin/macos/aarch64/julia-" . to_owned ( ) + & id + "-macos-aarch64.tar.gz" )
649
710
}
650
- "win64" => Ok ( "bin/windows/x86_64/julia-" . to_owned ( ) + id + "-windows-x86_64.tar.gz" ) ,
711
+ "win64" => Ok ( "bin/windows/x86_64/julia-" . to_owned ( ) + & id + "-windows-x86_64.tar.gz" ) ,
651
712
"linux-x86_64" => {
652
- Ok ( "bin/linux/x86_64/julia-" . to_owned ( ) + id + "-linux-x86_64.tar.gz" )
713
+ Ok ( "bin/linux/x86_64/julia-" . to_owned ( ) + & id + "-linux-x86_64.tar.gz" )
653
714
}
654
715
"linux-aarch64" => {
655
- Ok ( "bin/linux/aarch64/julia-" . to_owned ( ) + id + "-linux-aarch64.tar.gz" )
716
+ Ok ( "bin/linux/aarch64/julia-" . to_owned ( ) + & id + "-linux-aarch64.tar.gz" )
656
717
}
657
718
"freebsd-x86_64" => {
658
- Ok ( "bin/freebsd/x86_64/julia-" . to_owned ( ) + id + "-freebsd-x86_64.tar.gz" )
719
+ Ok ( "bin/freebsd/x86_64/julia-" . to_owned ( ) + & id + "-freebsd-x86_64.tar.gz" )
659
720
}
660
721
_ => Err ( anyhow ! ( "Unknown pr." ) ) ,
661
722
}
0 commit comments