@@ -830,45 +830,41 @@ sub _install_cosmocc {
830
830
_write_json(SITE_CONFIG_FILE, $SiteConfig );
831
831
}
832
832
833
+ # sub _load_valid_site_config {
834
+ # my ($is_cosmo3) = @_;
835
+ # my $SiteConfig = _load_json(SITE_CONFIG_FILE);
836
+ # $SiteConfig || defined($is_cosmo3) or die "Failed to load SiteConfig";
837
+ # $SiteConfig //= {};
838
+ # defined $is_cosmo3 or return $SiteConfig;
839
+ # if ($is_cosmo3) {
840
+ #
841
+ # }
842
+ # }
843
+
833
844
sub InstallBuildDeps {
834
- my ($perlrepo , $cosmorepo , $cosmocc ) = @_ ;
845
+ my ($perlrepo , $cosmorepo ) = @_ ;
835
846
my $SiteConfig = _load_json(SITE_CONFIG_FILE);
847
+ $SiteConfig //= {};
848
+
836
849
# if a repo is not set, set one up by default
837
- if ((! $SiteConfig || ! exists $SiteConfig -> {perl_repo }) && ( !$perlrepo ) ) {
850
+ if (! exists $SiteConfig -> {perl_repo } && !$perlrepo ) {
838
851
$perlrepo = SITE_REPO_DIR." /perl5" ;
839
852
_setup_repo($perlrepo , _load_apperl_configs()-> {perl_remotes });
840
853
print " apperlm install-build-deps: setup perl repo\n " ;
841
854
}
842
- if ((! $SiteConfig || ! exists $SiteConfig -> {cosmo_repo }) && ( !$cosmorepo ) ) {
855
+ if (! exists $SiteConfig -> {cosmo_repo } && !$cosmorepo ) {
843
856
$cosmorepo = SITE_REPO_DIR." /cosmopolitan" ;
844
857
_setup_repo( $cosmorepo , _load_apperl_configs()-> {cosmo_remotes });
845
858
print " apperlm install-build-deps: setup cosmo repo\n " ;
846
859
}
847
- if ((!$SiteConfig || !exists $SiteConfig -> {cosmocc }) && (!$cosmocc )) {
848
- $cosmocc = SITE_REPO_DIR." /cosmocc" ;
849
- print " mkdir -p $cosmocc \n " ;
850
- make_path($cosmocc );
851
- print " cd $cosmocc \n " ;
852
- my $before = getcwd();
853
- chdir ($cosmocc ) or die " Failed to chdir $cosmocc " ;
854
- _command_or_die(' wget' , ' https://cosmo.zip/pub/cosmocc/cosmocc.zip' );
855
- _command_or_die(' unzip' , ' cosmocc.zip' );
856
- print " apperlm install-build-deps: setup cosmocc\n " ;
857
- chdir ($before ) or die " error resetting directory" ;
858
- }
859
860
860
861
# (re)write site config
861
862
$perlrepo //= $SiteConfig -> {perl_repo };
862
863
$cosmorepo //= $SiteConfig -> {cosmo_repo };
863
- $cosmocc //= $SiteConfig -> {cosmocc };
864
- my %siteconfig = (
865
- perl_repo => abs_path($perlrepo ),
866
- cosmo_repo => abs_path($cosmorepo ),
867
- cosmocc => abs_path($cosmocc ),
868
- );
869
- $SiteConfig = \%siteconfig ;
864
+ $SiteConfig -> {perl_repo } = abs_path($perlrepo );
865
+ $SiteConfig -> {cosmo_repo } = abs_path($cosmorepo );
870
866
make_path(SITE_CONFIG_DIR);
871
- _write_json(SITE_CONFIG_FILE, \ %siteconfig );
867
+ _write_json(SITE_CONFIG_FILE, $SiteConfig );
872
868
print " apperlm install-build-deps: wrote site config to " .SITE_CONFIG_FILE." \n " ;
873
869
}
874
870
@@ -1456,25 +1452,22 @@ END_USAGE
1456
1452
apperlm install-build-deps [-h|--help] [-c|--cosmo <path>] [-p|--perl <path>]
1457
1453
-c|--cosmo <path> set path to cosmopolitan repo (skips git initialization)
1458
1454
-p|--perl <path> set path to perl repo (skips git initialization)
1459
- -C|--cosmocc <path> set path to cosmocc
1460
1455
-h|--help Show this message
1461
1456
Install build dependencies for APPerl, use -c or -p to skip initializing
1462
1457
those repos by providing a path to it.
1463
1458
END_USAGE
1464
1459
my $cosmo ;
1465
1460
my $perl ;
1466
- my $cosmocc ;
1467
1461
my $help ;
1468
1462
GetOptionsFromArray(\@_ , " cosmo|c=s" => \$cosmo ,
1469
1463
" perl|p=s" => \$perl ,
1470
- " cosmocc|C=s" => \$cosmocc ,
1471
1464
" help|h" => \$help ,
1472
1465
) or die ($usage );
1473
1466
if ($help ) {
1474
1467
print $usage ;
1475
1468
exit 0;
1476
1469
}
1477
- Perl::Dist::APPerl::InstallBuildDeps($perl , $cosmo , $cosmocc );
1470
+ Perl::Dist::APPerl::InstallBuildDeps($perl , $cosmo );
1478
1471
}
1479
1472
elsif ($command eq ' new-config' ) {
1480
1473
my $usage = <<'END_USAGE' ;
@@ -1539,14 +1532,14 @@ sub _setup_repo {
1539
1532
my ($repopath , $remotes ) = @_ ;
1540
1533
print " mkdir -p $repopath \n " ;
1541
1534
make_path($repopath );
1542
- # print "cd $repopath\n";
1543
- # chdir($repopath) or die "Failed to chdir $repopath";
1544
- # _command_or_die('git', 'init');
1545
- # _command_or_die('git', 'checkout', '-b', 'placeholder_dont_use');
1546
- # foreach my $remote (keys %{$remotes}) {
1547
- # _command_or_die('git', 'remote', 'add', $remote, $remotes->{$remote});
1548
- # _command_or_die('git', 'fetch', $remote);
1549
- # }
1535
+ print " cd $repopath \n " ;
1536
+ chdir ($repopath ) or die " Failed to chdir $repopath " ;
1537
+ _command_or_die(' git' , ' init' );
1538
+ _command_or_die(' git' , ' checkout' , ' -b' , ' placeholder_dont_use' );
1539
+ foreach my $remote (keys %{$remotes }) {
1540
+ _command_or_die(' git' , ' remote' , ' add' , $remote , $remotes -> {$remote });
1541
+ _command_or_die(' git' , ' fetch' , $remote );
1542
+ }
1550
1543
}
1551
1544
1552
1545
sub _write_json {
0 commit comments