Skip to content

Instantly share code, notes, and snippets.

@qknight
Created June 14, 2014 10:07
Show Gist options
  • Save qknight/0f05f2cd9fbca102f838 to your computer and use it in GitHub Desktop.
Save qknight/0f05f2cd9fbca102f838 to your computer and use it in GitHub Desktop.
my $curl = WWW::Curl::Easy->new;
#system("$Nix::Config::curl --fail --location --insecure --connect-timeout $curlConnectTimeout '$url' $decompressor | $Nix::Config::binDir/nix-store --restore $destPath");
#$curl->setopt(CURLOPT_HEADER, 1);
#$curl->setopt(CURLOPT_URL, 'https://raw.githubusercontent.com/qknight/nix-build-hack/master/www_curl_easy.pl');
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_NOPROGRESS, 0);
$curl->setopt(CURLOPT_FAILONERROR, 0);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_SSL_VERIFYHOST, 0);
$curl->setopt(CURLOPT_CONNECTTIMEOUT, $curlConnectTimeout);
$curl->setopt(CURLOPT_CAINFO, $caBundle) if defined $caBundle;
$curl->setopt(CURLOPT_USERAGENT, "Nix/$Nix::Config::version");
$curl->setopt(CURLOPT_PROGRESSFUNCTION, sub {
my ( $easy, $dltotal, $dlnow, $ultotal, $ulnow, $uservar ) = @_;
print STDERR join(' ', @_[1..4]), "\n";
return 0;
}
);
my $string;
my $fh1;
open($fh1, "> /tmp/bar123");
#open($fh1, ">>", \$string);
$curl->setopt(CURLOPT_WRITEDATA, $fh1);
# Starts the actual request
my $retcode = $curl->perform;
print STDERR "===========================================================\n\n\n";
print STDERR " URL = '".$url."'";
# Looking at the results...
my $ret = 0;
if ($retcode == 0) {
#close $fh1;
print STDERR "Transfer went ok\n";
my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
my $wh;
system("/nix/store/xdswdgz11w9lm9n9bzb6spl7dj45s2x2-coreutils-8.21/bin/rm /tmp/bar");
open($wh, "> /tmp/bar");
#open($wh, "| $decompressor | $Nix::Config::binDir/nix-store --restore $destPath");
@qknight
Copy link
Author

qknight commented Jun 14, 2014

here is what happens when i run the code and do a ls -la /tmp/bar afterwards

  /nix/store/washfiqpj0dn3xk3d50igp35nsa6vm8s-perl-HTTP-Daemon-6.01
fetching path `/nix/store/1hmq9xkq73cgzgxmgn17fr7ixrr5l82h-perl-HTTP-Cookies-6.01'...

***! Downloading ‘http://cache.nixos.org/nar/1b1zmhvznhlw4js0pjv9b1pawpb39mhqp4b9pcp50r6f4y23dwqw.nar.xz’ to ‘/nix/store/1hmq9xkq73cgzgxmgn17fr7ixrr5l82h-perl-HTTP-Cookies-6.01’...
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
19788 13032 0 0
19788 13032 0 0
19788 19788 0 0
19788 19788 0 0
19788 19788 0 0
19788 19788 0 0
===========================================================


 URL = 'http://cache.nixos.org/nar/1b1zmhvznhlw4js0pjv9b1pawpb39mhqp4b9pcp50r6f4y23dwqw.nar.xz'Transfer went ok
Use of uninitialized value $string in print at /root/nix/inst/libexec/nix/substituters/download-from-binary-cache.pl line 130.
===========================================================



substitute did not produce path `/nix/store/1hmq9xkq73cgzgxmgn17fr7ixrr5l82h-perl-HTTP-Cookies-6.01'
fetching path `/nix/store/hcyffjapdys20k52z53r4vpb2r4razbr-perl-WWW-RobotRules-6.02'...
killing process 8098
killing process 8098: No such process
building path(s) `/nix/store/53r9iylprgyd3w1k83ac75qqh2b1636l-wget-1.15.tar.xz'
error: some substitutes for the outputs of derivation `/nix/store/c6jjckqc0igca4qxa7y3walkwcdjx1x9-perl-libwww-perl-6.05.drv' failed (usually happens due to networking issues); try `--fallback' to build derivation from source
-rw-r--r-- 1 root root     0 Jun 14 12:03 /tmp/bar
-rw-r--r-- 1 root root 12223 Jun 14 12:03 /tmp/bar123
-rw-r--r-- 1 root root 46456 Apr 25 03:52 /tmp/bar-1b1zmhvznhlw4js0pjv9b1pawpb39mhqp4b9pcp50r6f4y23dwqw.nar
-rw-r--r-- 1 root root 19788 Apr 25 03:52 /tmp/bar-1b1zmhvznhlw4js0pjv9b1pawpb39mhqp4b9pcp50r6f4y23dwqw.nar.xz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment