Created
March 21, 2020 00:04
-
-
Save ento/5713e51419ad0d8cfff45de2e6e62159 to your computer and use it in GitHub Desktop.
Failed attempts at shrinking the size of sqitchPg closure in Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attempt 1: Build sqitch with pp | |
-> built binary still failed with "Can't locate PAR.pm in @INC" | |
Attemp 2: Install sqitchModule with ./Build bundle | |
-> Configuring DBD::Pg fails: | |
> Configuring DBD-Pg-3.10.4 ... N/A | |
> ! No MYMETA file is found after configure. Your toolchain is too old? | |
> ! Configure failed for DBD-Pg-3.10.4. See /run/user/1000/nix-build-perl5.30.0-App-Sqitch-1.0.0.drv-3/App-Sqitch-v1.0.0/cpanm/work/1584732411.27638/build.log for details. | |
It uses cpanm to download modules during build, so it won't work with sandboxed builds anyways. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/myldr/Makefile.PL b/myldr/Makefile.PL | |
index 6abee6e..4956025 100644 | |
--- a/myldr/Makefile.PL | |
+++ b/myldr/Makefile.PL | |
@@ -60,7 +60,8 @@ my $o = $Config{obj_ext}; | |
my $gccversion = $Config{gccversion}; | |
# NOTE: on some platforms, ccopts or ldopts may contain newlines | |
chomp( my $pccflags = ccopts() ); | |
-chomp( my $pldflags = ldopts() ); | |
+my @nix_ldflags = split " ", $ENV{'NIX_LDFLAGS'}; | |
+chomp( my $pldflags = ldopts(0,"",\@nix_ldflags) ); | |
my $dynperl = $Config{useshrplib} && ($Config{useshrplib} ne 'false'); | |
$dynperl = 1 if $pldflags =~ /\B-lperl\b/; # Gentoo lies to us! | |
diff --git a/myldr/boot.c b/myldr/boot.c | |
index 55dedab..8812156 100644 | |
--- a/myldr/boot.c | |
+++ b/myldr/boot.c | |
@@ -33,7 +33,7 @@ typedef struct | |
* return EXTRACT_ALREADY if the extracted file already exists (and has the | |
* expected size), EXTRACT_OK if successful, EXTRACT_FAIL otherwise | |
*/ | |
-static | |
+static | |
int extract_embedded_file(embedded_file_t *emb_file, const char* ext_name, const char* stmpdir, char** ext_path) { | |
int fd; | |
chunk_t *chunk; | |
@@ -48,20 +48,27 @@ int extract_embedded_file(embedded_file_t *emb_file, const char* ext_name, const | |
return EXTRACT_ALREADY; /* file already exists and has the expected size */ | |
tmp_path = malloc(len + 1 + 20 + 1); /* 20 decimal digits should be enough to hold up to 2^64-1 */ | |
- sprintf(tmp_path, "%s.%lu", *ext_path, (unsigned long)getpid()); | |
+ sprintf(tmp_path, "%s.%lu", stmpdir, (unsigned long)getpid()); | |
fd = open(tmp_path, O_CREAT | O_WRONLY | OPEN_O_BINARY, 0755); | |
- if ( fd == -1 ) | |
+ if ( fd == -1 ) { | |
+ fprintf(stderr, "boot: open failed %s)\n", | |
+ tmp_path); | |
return EXTRACT_FAIL; | |
+ } | |
chunk = emb_file->chunks; | |
while (chunk->len) { | |
- if ( write(fd, chunk->buf, chunk->len) != chunk->len ) | |
+ if ( write(fd, chunk->buf, chunk->len) != chunk->len ) { | |
+ fprintf(stderr, "boot: write failed)\n"); | |
return EXTRACT_FAIL; | |
+ } | |
chunk++; | |
} | |
- if (close(fd) == -1) | |
+ if (close(fd) == -1) { | |
+ fprintf(stderr, "boot: close failed)\n"); | |
return EXTRACT_FAIL; | |
+ } | |
chmod(tmp_path, 0750); | |
if (rename(tmp_path, *ext_path) == -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self: super: | |
{ | |
perlPackages = super.perlPackages // { | |
AppSqitch = super.perlPackages.AppSqitch.overrideAttrs (old: { | |
installPhase = '' | |
runHook preInstall | |
mkdir cpanm | |
export PERL_CPANM_HOME=$(pwd)/cpanm | |
./Build bundle --install_base $out --with postgres | |
runHook postInstall | |
''; | |
buildInputs = [ super.perlPackages.MenloLegacy ] ++ old.buildInputs; | |
}); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self: super: | |
let | |
PAR = super.buildPerlPackage rec { | |
pname = "PAR"; | |
version = "1.016"; | |
src = super.fetchurl { | |
url = "mirror://cpan/authors/id/R/RS/RSCHUPP/${pname}-${version}.tar.gz"; | |
sha256 = "15wxvm27di5yv2mp4wa5kdsfgw0d1175y440m30r5bk76fpzn98a"; | |
}; | |
buildInputs = [ | |
self.perlPackages.ArchiveZip | |
self.perlPackages.AutoLoader | |
self.perlPackages.CompressZlib | |
self.perlPackages.DigestSHA | |
self.perlPackages.FileTemp | |
self.perlPackages.PARDist | |
]; | |
}; | |
pp = super.buildPerlPackage rec { | |
pname = "PAR-Packer"; | |
version = "1.050"; | |
src = super.fetchurl { | |
url = "mirror://cpan/authors/id/R/RS/RSCHUPP/${pname}-${version}.tar.gz"; | |
sha256 = "1zfwb6x8gjz2f8nm18l3hchpxixhzpbsj97lhsdvsmmw8pdqlxp3"; | |
}; | |
buildInputs = [ | |
self.perlPackages.ArchiveZip | |
self.perlPackages.GetoptArgvFile | |
self.perlPackages.IPCRun3 | |
self.perlPackages.ModuleScanDeps | |
self.perlPackages.PARDist | |
PAR | |
]; | |
patches = [ ./PAR-Packer.diff ]; | |
}; | |
in | |
{ | |
sqitchPg = super.stdenv.mkDerivation { | |
inherit (super.sqitchPg) name; | |
src = super.sqitchPg; | |
buildPhase = '' | |
${pp}/bin/pp -o bin/sqitch-standalone bin/.sqitch-wrapped | |
''; | |
installPhase = '' | |
mkdir -p $out/bin | |
install bin/sqitch-standalone $out/bin/sqitch | |
''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment