@@ -922,12 +922,11 @@ sub Status {
922
922
923
923
# unfortunately this needs to be called in several places to try to keep them in sync
924
924
# as perl's make trips up when trying to build an symlinked extension
925
- sub _install_perl_repo_files {
926
- my ($itemconfig , $SiteConfig ) = @_ ;
925
+ sub _install_perl_src_files {
926
+ my ($itemconfig , $perl_build_dir ) = @_ ;
927
927
foreach my $dest (keys %{$itemconfig -> {perl_repo_files }}) {
928
928
foreach my $file (@{$itemconfig -> {perl_repo_files }{$dest }}) {
929
- # _command_or_die('ln', '-sf', START_WD."/$file", "$SiteConfig->{perl_repo}/$dest");
930
- _copy_recursive(START_WD." /$file " , " $SiteConfig ->{perl_repo}/$dest " );
929
+ _copy_recursive(START_WD." /$file " , " $perl_build_dir /$dest " );
931
930
}
932
931
}
933
932
}
@@ -955,11 +954,13 @@ sub Set {
955
954
} else {
956
955
-d $SiteConfig -> {cosmocc } or die $SiteConfig -> {cosmocc } . ' is not a directory' ;
957
956
}
958
- # $UserProjectConfig->{configs}{$cfgname}{perl_build_dir} //= $SiteConfig->{perl_repo} // "$UserProjectConfig->{apperl_output}/$cfgname/tmp/perl5";
957
+ $UserProjectConfig -> {configs }{$cfgname }{perl_build_dir } //= $SiteConfig -> {perl_repo } if !$itemconfig -> {perl_url };
958
+ $UserProjectConfig -> {configs }{$cfgname }{perl_build_dir } //= " $UserProjectConfig ->{apperl_output}/$cfgname /tmp/perl5" ;
959
+ my $perl_build_dir = $UserProjectConfig -> {configs }{$cfgname }{perl_build_dir };
959
960
if (! $itemconfig -> {perl_url }) {
960
- -d $SiteConfig -> { perl_repo } or die $SiteConfig -> { perl_repo } .' is not directory' ;
961
- print " cd " .$SiteConfig -> { perl_repo } ." \n " ;
962
- chdir ($SiteConfig -> { perl_repo } ) or die " Failed to enter perl repo" ;
961
+ -d $perl_build_dir or die $perl_build_dir .' is not directory' ;
962
+ print " cd " .$perl_build_dir ." \n " ;
963
+ chdir ($perl_build_dir ) or die " Failed to enter perl repo" ;
963
964
print " make veryclean\n " ;
964
965
system (" make" , " veryclean" );
965
966
foreach my $todelete (' miniperl.com' , ' perl.com' , ' miniperl.elf' , ' miniperl.com.dbg' , ' perl.elf' , ' perl.com.dbg' ) {
@@ -971,27 +972,27 @@ sub Set {
971
972
$itemconfig -> {patches } //= [];
972
973
} else {
973
974
my $tarball_name = basename($itemconfig -> {perl_url });
974
- _command_or_die(' mkdir' , ' -p' , $SiteConfig -> {perl_repo });
975
- my $download_dir = $SiteConfig -> {perl_repo } . ' /..' ;
975
+ my $download_dir = $UserProjectConfig -> {apperl_output };
976
976
chdir ($download_dir ) or die " Failed to enter download dir" ;
977
977
if (! -f $tarball_name ) {
978
978
_command_or_die(' wget' , $itemconfig -> {perl_url });
979
979
}
980
980
_command_or_die(' tar' , ' -xf' , $tarball_name );
981
- _command_or_die(" rm" , ' -rf' , $SiteConfig -> { perl_repo } );
981
+ _command_or_die(" rm" , ' -rf' , $perl_build_dir );
982
982
my ($version ) = $tarball_name =~ / ^v(\d +\.\d +\.\d +)\. tar/ ;
983
983
my $tomove = " perl5-$version " ;
984
- _command_or_die(' mv' , $tomove , ' perl5 ' );
985
- chdir ($SiteConfig -> { perl_repo } ) or die " Failed to enter perl repo" ;
984
+ _command_or_die(' mv' , $tomove , $perl_build_dir );
985
+ chdir ($perl_build_dir ) or die " Failed to enter perl repo" ;
986
986
}
987
987
foreach my $patch (@{$itemconfig -> {patches }}) {
988
988
my $realpatch = _fix_bases($patch , {__sharedir__ => SHARE_DIR});
989
- _command_or_die(' git' , ' apply' , $realpatch );
989
+ my $cmd = " patch -p1 < $realpatch " ; # can't git apply to ignored files within a git repository :(
990
+ print " $cmd \n " ;
991
+ system ($cmd ) == 0 or die " failed to apply patch $realpatch " ;
990
992
}
991
-
992
993
print " cd " .START_WD." \n " ;
993
994
chdir (START_WD) or die " Failed to restore cwd" ;
994
- _install_perl_repo_files ($itemconfig , $SiteConfig );
995
+ _install_perl_src_files ($itemconfig , $perl_build_dir );
995
996
}
996
997
else {
997
998
my $validperl ;
@@ -1021,10 +1022,11 @@ sub Configure {
1021
1022
my $UserProjectConfig = _load_valid_user_project_config_with_default($Configs ) or die " cannot Configure without valid UserProjectConfig" ;
1022
1023
my $CurAPPerlName = $UserProjectConfig -> {current_apperl };
1023
1024
! exists $UserProjectConfig -> {nobuild_perl_bin } or die " nobuild perl cannot be configured" ;
1024
- my $SiteConfig = _load_json(SITE_CONFIG_FILE) or die " cannot Configure without build deps (run apperlm install-build-deps) " ;
1025
- -d $SiteConfig -> { perl_repo } or die $SiteConfig -> { perl_repo } . ' is not directory' ;
1025
+ my $perl_build_dir = $UserProjectConfig -> { configs }{ $CurAPPerlName }{ perl_build_dir } ;
1026
+ $perl_build_dir && -d $perl_build_dir or die " $perl_build_dir is not a directory" ;
1026
1027
my $itemconfig = _load_apperl_config($Configs -> {apperl_configs }, $CurAPPerlName );
1027
- _install_perl_repo_files($itemconfig , $SiteConfig );
1028
+ my $SiteConfig = _load_json(SITE_CONFIG_FILE) or die " cannot Configure without build deps (run apperlm install-build-deps)" ;
1029
+ _install_perl_src_files($itemconfig , $perl_build_dir );
1028
1030
1029
1031
if (! $itemconfig -> {cosmo3 }) {
1030
1032
-d $SiteConfig -> {cosmo_repo } or die $SiteConfig -> {cosmo_repo } .' is not directory' ;
@@ -1047,8 +1049,8 @@ sub Configure {
1047
1049
}
1048
1050
1049
1051
# Finally Configure perl
1050
- print " cd " . $SiteConfig -> { perl_repo }. " \n " ;
1051
- chdir ($SiteConfig -> { perl_repo } ) or die " Failed to enter perl repo" ;
1052
+ print " cd $perl_build_dir \n " ;
1053
+ chdir ($perl_build_dir ) or die " Failed to enter perl repo" ;
1052
1054
my @onlyextensions = ();
1053
1055
push @onlyextensions , (" -Donlyextensions= " .join (' ' , sort @{$itemconfig -> {perl_onlyextensions }}).' ' ) if (exists $itemconfig -> {perl_onlyextensions });
1054
1056
_command_or_die(' sh' , ' Configure' , @{$itemconfig -> {perl_flags }}, @onlyextensions , @{$itemconfig -> {perl_extra_flags }}, @_ );
@@ -1096,16 +1098,17 @@ sub Build {
1096
1098
} else {
1097
1099
-d $SiteConfig -> {cosmocc } or die $SiteConfig -> {cosmocc } .' is not directory' ;
1098
1100
}
1099
- -d $SiteConfig -> {perl_repo } or die $SiteConfig -> {perl_repo } .' is not directory' ;
1100
- _install_perl_repo_files($itemconfig , $SiteConfig );
1101
- print " cd " .$SiteConfig -> {perl_repo }." \n " ;
1102
- chdir ($SiteConfig -> {perl_repo }) or die " Failed to enter perl repo" ;
1101
+ my $perl_build_dir = $UserProjectConfig -> {configs }{$CurAPPerlName }{perl_build_dir };
1102
+ $perl_build_dir && -d $perl_build_dir or die " $perl_build_dir is not a directory" ;
1103
+ _install_perl_src_files($itemconfig , $perl_build_dir );
1104
+ print " cd $perl_build_dir \n " ;
1105
+ chdir ($perl_build_dir ) or die " Failed to enter perl repo" ;
1103
1106
# build using cosmo's zlib to avoid name clashes or including two versions of zlib
1104
1107
local $ENV {' BUILD_ZLIB' } = ' False' if $itemconfig -> {cosmo3 };
1105
1108
local $ENV {' ZLIB_INCLUDE' } = $SiteConfig -> {cosmocc } . ' /include/third_party/zlib' if $itemconfig -> {cosmo3 };
1106
1109
local $ENV {' ZLIB_LIB' } = ' ' if $itemconfig -> {cosmo3 };
1107
1110
_command_or_die(' make' );
1108
- $PERL_APE = " $SiteConfig ->{perl_repo} /perl.com" ;
1111
+ $PERL_APE = " $perl_build_dir /perl.com" ;
1109
1112
@perl_config_cmd = (' ./perl' , ' -Ilib' );
1110
1113
}
1111
1114
else {
@@ -1115,7 +1118,7 @@ sub Build {
1115
1118
1116
1119
# prepare for install and pack
1117
1120
-f $PERL_APE or die " apperlm build: perl ape not found" ;
1118
- my $OUTPUTDIR = " $UserProjectConfig ->{apperl_output}/$CurAPPerlName " ;
1121
+ my $OUTPUTDIR = " $UserProjectConfig ->{apperl_output}/$CurAPPerlName /o " ;
1119
1122
if (-d $OUTPUTDIR ) {
1120
1123
print " rm -rf $OUTPUTDIR \n " ;
1121
1124
remove_tree($OUTPUTDIR );
0 commit comments