forked from mirrors/nixpkgs
Move "fetchurl restricted" code to requireFile.
This reverts r21474 and r21467. Also migrate wtk (r21472) to new API. svn path=/nixpkgs/trunk/; revision=21575
This commit is contained in:
parent
2d9ba975e7
commit
796ffd9f71
pkgs
build-support
development/libraries/wtk
stdenv
top-level
|
@ -1,4 +1,4 @@
|
||||||
{stdenv, curl, writeScript}: # Note that `curl' may be `null', in case of the native stdenv.
|
{stdenv, curl}: # Note that `curl' may be `null', in case of the native stdenv.
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ let
|
||||||
else [] /* backwards compatibility */;
|
else [] /* backwards compatibility */;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{ # URL to fetch.
|
{ # URL to fetch.
|
||||||
url ? ""
|
url ? ""
|
||||||
|
|
||||||
|
@ -45,12 +45,6 @@ in
|
||||||
, # If set, don't download the file, but write a list of all possible
|
, # If set, don't download the file, but write a list of all possible
|
||||||
# URLs (resulting from resolving mirror:// URLs) to $out.
|
# URLs (resulting from resolving mirror:// URLs) to $out.
|
||||||
showURLs ? false
|
showURLs ? false
|
||||||
|
|
||||||
, # If set, down't download file but tell user how to download it.
|
|
||||||
restricted ? false
|
|
||||||
|
|
||||||
, # Used only if restricted. Should contain instructions how to fetch the file.
|
|
||||||
message ? ""
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert urls != [] -> url == "";
|
assert urls != [] -> url == "";
|
||||||
|
@ -62,55 +56,34 @@ assert showURLs || (outputHash != "" && outputHashAlgo != "")
|
||||||
let
|
let
|
||||||
|
|
||||||
urls_ = if urls != [] then urls else [url];
|
urls_ = if urls != [] then urls else [url];
|
||||||
name_ = if showURLs then "urls"
|
|
||||||
else if name != "" then name
|
|
||||||
else baseNameOf (toString (builtins.head urls_));
|
|
||||||
hashAlgo_ = if outputHashAlgo != "" then outputHashAlgo else
|
|
||||||
if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
|
|
||||||
hash_ = if outputHash != "" then outputHash else
|
|
||||||
if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation {
|
||||||
name = name_;
|
name =
|
||||||
outputHashAlgo = hashAlgo_;
|
if showURLs then "urls"
|
||||||
outputHash = hash_;
|
else if name != "" then name
|
||||||
urls = urls_;
|
else baseNameOf (toString (builtins.head urls_));
|
||||||
|
|
||||||
# Compatibility with Nix <= 0.7.
|
|
||||||
id = md5;
|
|
||||||
|
|
||||||
inherit showURLs mirrorsFile;
|
|
||||||
}
|
|
||||||
// (if (!showURLs && restricted) then rec {
|
|
||||||
builder = writeScript "restrict-message" ''
|
|
||||||
source ${stdenv}/setup
|
|
||||||
cat <<_EOF_
|
|
||||||
${message_}
|
|
||||||
_EOF_
|
|
||||||
'';
|
|
||||||
message_ = if message != "" then message else ''
|
|
||||||
You have to download ${name_} from ${stdenv.lib.concatStringsSep " " urls_} yourself,
|
|
||||||
and add it to the store using either
|
|
||||||
nix-store --add-fixed ${hashAlgo_} ${name_}
|
|
||||||
or
|
|
||||||
${if hashAlgo_ != "sha256" then "NIX_HASH_ALGO=${hashAlgo_} " else
|
|
||||||
""}nix-prefetch-url file://path/to/${name_}
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
|
|
||||||
buildInputs = [curl];
|
buildInputs = [curl];
|
||||||
|
|
||||||
|
urls = urls_;
|
||||||
|
|
||||||
# If set, prefer the content-addressable mirrors
|
# If set, prefer the content-addressable mirrors
|
||||||
# (http://nixos.org/tarballs) over the original URLs.
|
# (http://nixos.org/tarballs) over the original URLs.
|
||||||
preferHashedMirrors = true;
|
preferHashedMirrors = true;
|
||||||
|
|
||||||
|
# Compatibility with Nix <= 0.7.
|
||||||
|
id = md5;
|
||||||
|
|
||||||
# New-style output content requirements.
|
# New-style output content requirements.
|
||||||
|
outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else
|
||||||
|
if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
|
||||||
|
outputHash = if outputHash != "" then outputHash else
|
||||||
|
if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
|
||||||
|
|
||||||
impureEnvVars = [
|
impureEnvVars = [
|
||||||
# We borrow these environment variables from the caller to allow
|
# We borrow these environment variables from the caller to allow
|
||||||
# easy proxy configuration. This is impure, but a fixed-output
|
# easy proxy configuration. This is impure, but a fixed-output
|
||||||
|
@ -122,5 +95,6 @@ else {
|
||||||
# command-line.
|
# command-line.
|
||||||
"NIX_HASHED_MIRRORS"
|
"NIX_HASHED_MIRRORS"
|
||||||
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
||||||
})
|
|
||||||
)
|
inherit showURLs mirrorsFile;
|
||||||
|
}
|
||||||
|
|
|
@ -73,6 +73,36 @@ rec {
|
||||||
linkFarm = name: entries: runCommand name {} ("mkdir -p $out; cd $out; \n" +
|
linkFarm = name: entries: runCommand name {} ("mkdir -p $out; cd $out; \n" +
|
||||||
(stdenv.lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));
|
(stdenv.lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));
|
||||||
|
|
||||||
|
# Require file
|
||||||
|
requireFile = {name, sha256, url ? null, message ? null} :
|
||||||
|
assert (message != null) || (url != null);
|
||||||
|
let msg =
|
||||||
|
if message != null then message
|
||||||
|
else ''
|
||||||
|
Unfortunately, we may not download file ${name} automatically.
|
||||||
|
Please, go to ${url}, download it yourself, and add it to the Nix store
|
||||||
|
using either
|
||||||
|
nix-store --add-fixed sha256 ${name}
|
||||||
|
or
|
||||||
|
nix-prefetch-url file://path/to/${name}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
inherit name;
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHash = sha256;
|
||||||
|
builder = writeScript "restrict-message" ''
|
||||||
|
source ${stdenv}/setup
|
||||||
|
cat <<_EOF_
|
||||||
|
|
||||||
|
***
|
||||||
|
${msg}
|
||||||
|
***
|
||||||
|
|
||||||
|
_EOF_
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Search in the environment if the same program exists with a set uid or
|
# Search in the environment if the same program exists with a set uid or
|
||||||
# set gid bit. If it exists, run the first program found, otherwise run
|
# set gid bit. If it exists, run the first program found, otherwise run
|
||||||
# the default binary.
|
# the default binary.
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
{ stdenv, fetchurl, unzip, xlibs }:
|
{ stdenv, requireFile, unzip, xlibs }:
|
||||||
|
|
||||||
assert stdenv.system == "i686-linux";
|
assert stdenv.system == "i686-linux";
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "sun-java-wtk-2.5.2_01";
|
name = "sun-java-wtk-2.5.2_01";
|
||||||
|
|
||||||
src = fetchurl {
|
src = requireFile {
|
||||||
url = meta.homepage;
|
url = meta.homepage;
|
||||||
name = "sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh";
|
name = "sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh";
|
||||||
restricted = true;
|
sha256 = "1cjb9c27847wv0hq3j645ckn4di4vsfvp29fr4zmdqsnvk4ahvj1";
|
||||||
md5 = "6b70b6e6d426eac121db8a087991589f";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
|
|
|
@ -104,7 +104,6 @@ rec {
|
||||||
fetchurl = import ../../build-support/fetchurl {
|
fetchurl = import ../../build-support/fetchurl {
|
||||||
stdenv = stdenvLinuxBoot0;
|
stdenv = stdenvLinuxBoot0;
|
||||||
curl = bootstrapTools;
|
curl = bootstrapTools;
|
||||||
inherit (allPackages) writeScript;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,6 @@ rec {
|
||||||
stdenv = stdenvBoot0;
|
stdenv = stdenvBoot0;
|
||||||
# Curl should be in /usr/bin or so.
|
# Curl should be in /usr/bin or so.
|
||||||
curl = null;
|
curl = null;
|
||||||
inherit (allPackages) writeScript;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,8 @@ let
|
||||||
# from being built.
|
# from being built.
|
||||||
fetchurl = useFromStdenv "fetchurl"
|
fetchurl = useFromStdenv "fetchurl"
|
||||||
(import ../build-support/fetchurl {
|
(import ../build-support/fetchurl {
|
||||||
inherit stdenv curl writeScript;
|
curl = curl;
|
||||||
|
stdenv = stdenv;
|
||||||
});
|
});
|
||||||
|
|
||||||
# fetchurlBoot is used for curl and its dependencies in order to
|
# fetchurlBoot is used for curl and its dependencies in order to
|
||||||
|
@ -5230,8 +5231,8 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
wtk = import ../development/libraries/wtk {
|
wtk = import ../development/libraries/wtk {
|
||||||
inherit fetchurl stdenv unzip xlibs;
|
inherit requireFile stdenv unzip xlibs;
|
||||||
};
|
};
|
||||||
|
|
||||||
x264 = import ../development/libraries/x264 {
|
x264 = import ../development/libraries/x264 {
|
||||||
inherit fetchurl stdenv yasm;
|
inherit fetchurl stdenv yasm;
|
||||||
|
|
Loading…
Reference in a new issue