uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
84
pkgs/development/interpreters/octave/build-env.nix
Normal file
84
pkgs/development/interpreters/octave/build-env.nix
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
{ lib, stdenv, octave, buildEnv
|
||||
, makeWrapper, texinfo
|
||||
, octavePackages
|
||||
, wrapOctave
|
||||
, computeRequiredOctavePackages
|
||||
, extraLibs ? []
|
||||
, extraOutputsToInstall ? []
|
||||
, postBuild ? ""
|
||||
, ignoreCollisions ? false
|
||||
}:
|
||||
|
||||
# Create an octave executable that knows about additional packages
|
||||
let
|
||||
packages = computeRequiredOctavePackages extraLibs;
|
||||
|
||||
in buildEnv {
|
||||
name = "${octave.name}-env";
|
||||
paths = extraLibs ++ [ octave ];
|
||||
|
||||
inherit ignoreCollisions;
|
||||
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ texinfo wrapOctave ];
|
||||
|
||||
# During "build" we must first unlink the /share symlink to octave's /share
|
||||
# Then, we can re-symlink the all of octave/share, except for /share/octave
|
||||
# in env/share/octave, re-symlink everything from octave/share/octave and then
|
||||
# perform the pkg install.
|
||||
postBuild = ''
|
||||
if [ -L "$out/bin" ]; then
|
||||
unlink $out/bin
|
||||
mkdir -p "$out/bin"
|
||||
cd "${octave}/bin"
|
||||
for prg in *; do
|
||||
if [ -x $prg ]; then
|
||||
makeWrapper "${octave}/bin/$prg" "$out/bin/$prg" --set OCTAVE_SITE_INITFILE "$out/share/octave/site/m/startup/octaverc"
|
||||
fi
|
||||
done
|
||||
cd $out
|
||||
fi
|
||||
|
||||
# Remove symlinks to the input tarballs, they aren't needed, use -f so it
|
||||
# will not fail if no .tar.gz symlinks are there - for example if
|
||||
# sommething which is not a tarball used as a package
|
||||
rm -f $out/*.tar.gz
|
||||
|
||||
createOctavePackagesPath $out ${octave}
|
||||
|
||||
# Create the file even if the loop afterwards has no packages to run over
|
||||
touch $out/.octave_packages
|
||||
for path in ${lib.concatStringsSep " " packages}; do
|
||||
if [ -e $path/*.tar.gz ]; then
|
||||
$out/bin/octave-cli --eval "pkg local_list $out/.octave_packages; \
|
||||
pkg prefix $out/${octave.octPkgsPath} $out/${octave.octPkgsPath}; \
|
||||
pfx = pkg (\"prefix\"); \
|
||||
pkg install -nodeps -local $path/*.tar.gz"
|
||||
fi
|
||||
done
|
||||
|
||||
# Re-write the octave-wide startup file (share/octave/site/m/startup/octaverc)
|
||||
# To point to the new local_list in $out
|
||||
addPkgLocalList $out ${octave}
|
||||
|
||||
wrapOctavePrograms "${lib.concatStringsSep " " packages}"
|
||||
'' + postBuild;
|
||||
|
||||
inherit (octave) meta;
|
||||
|
||||
passthru = octave.passthru // {
|
||||
interpreter = "$out/bin/octave";
|
||||
inherit octave;
|
||||
env = stdenv.mkDerivation {
|
||||
name = "interactive-${octave.name}-environment";
|
||||
|
||||
buildCommand = ''
|
||||
echo >&2 ""
|
||||
echo >&2 "*** octave 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
|
||||
echo >&2 ""
|
||||
exit 1
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
125
pkgs/development/interpreters/octave/build-octave-package.nix
Normal file
125
pkgs/development/interpreters/octave/build-octave-package.nix
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
# Generic builder for GNU Octave libraries.
|
||||
# This is a file that contains nested functions. The first, outer, function
|
||||
# is the library- and package-wide details, such as the nixpkgs library, any
|
||||
# additional configuration provided, and the namePrefix to use (based on the
|
||||
# pname and version of Octave), the octave package, etc.
|
||||
|
||||
{ lib
|
||||
, stdenv
|
||||
, config
|
||||
, octave
|
||||
, texinfo
|
||||
, computeRequiredOctavePackages
|
||||
, writeRequiredOctavePackagesHook
|
||||
}:
|
||||
|
||||
# The inner function contains information required to build the individual
|
||||
# libraries.
|
||||
{ fullLibName ? "${attrs.pname}-${attrs.version}"
|
||||
|
||||
, src
|
||||
|
||||
, dontPatch ? false
|
||||
, patches ? []
|
||||
, patchPhase ? ""
|
||||
|
||||
, enableParallelBuilding ? true
|
||||
# Build-time dependencies for the package, which were compiled for the system compiling this.
|
||||
, nativeBuildInputs ? []
|
||||
|
||||
# Build-time dependencies for the package, which may not have been compiled for the system compiling this.
|
||||
, buildInputs ? []
|
||||
|
||||
# Propagate build dependencies so in case we have A -> B -> C,
|
||||
# C can import package A propagated by B
|
||||
# Run-time dependencies for the package.
|
||||
, propagatedBuildInputs ? []
|
||||
|
||||
# Octave packages that are required at runtime for this one.
|
||||
# These behave similarly to propagatedBuildInputs, where if
|
||||
# package A is needed by B, and C needs B, then C also requires A.
|
||||
# The main difference between these and propagatedBuildInputs is
|
||||
# during the package's installation into octave, where all
|
||||
# requiredOctavePackages are ALSO installed into octave.
|
||||
, requiredOctavePackages ? []
|
||||
|
||||
, preBuild ? ""
|
||||
|
||||
, meta ? {}
|
||||
|
||||
, passthru ? {}
|
||||
|
||||
, ... } @ attrs:
|
||||
|
||||
let
|
||||
requiredOctavePackages' = computeRequiredOctavePackages requiredOctavePackages;
|
||||
|
||||
# Must use attrs.nativeBuildInputs before they are removed by the removeAttrs
|
||||
# below, or everything fails.
|
||||
nativeBuildInputs' = [
|
||||
octave
|
||||
writeRequiredOctavePackagesHook
|
||||
]
|
||||
++ nativeBuildInputs;
|
||||
|
||||
# This step is required because when
|
||||
# a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
|
||||
# (a // b).test = [ "c" "d" ];
|
||||
# This used to mean that if a package defined extra nativeBuildInputs, it
|
||||
# would override the ones for building an Octave package (the hook and Octave
|
||||
# itself, causing everything to fail.
|
||||
attrs' = builtins.removeAttrs attrs [ "nativeBuildInputs" ];
|
||||
|
||||
in stdenv.mkDerivation ({
|
||||
packageName = "${fullLibName}";
|
||||
# The name of the octave package ends up being
|
||||
# "octave-version-package-version"
|
||||
name = "${octave.pname}-${octave.version}-${fullLibName}";
|
||||
|
||||
# This states that any package built with the function that this returns
|
||||
# will be an octave package. This is used for ensuring other octave
|
||||
# packages are installed into octave during the environment building phase.
|
||||
isOctavePackage = true;
|
||||
|
||||
OCTAVE_HISTFILE = "/dev/null";
|
||||
|
||||
inherit src;
|
||||
|
||||
inherit dontPatch patches patchPhase;
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
enableParallelBuilding = enableParallelBuilding;
|
||||
|
||||
requiredOctavePackages = requiredOctavePackages';
|
||||
|
||||
nativeBuildInputs = nativeBuildInputs';
|
||||
|
||||
buildInputs = buildInputs ++ requiredOctavePackages';
|
||||
|
||||
propagatedBuildInputs = propagatedBuildInputs ++ [ texinfo ];
|
||||
|
||||
preBuild = if preBuild == "" then
|
||||
''
|
||||
# This trickery is needed because Octave expects a single directory inside
|
||||
# at the top-most level of the tarball.
|
||||
tar --transform 's,^,${fullLibName}/,' -cz * -f ${fullLibName}.tar.gz
|
||||
''
|
||||
else
|
||||
preBuild;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p $out
|
||||
octave-cli --eval "pkg build $out ${fullLibName}.tar.gz"
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# We don't install here, because that's handled when we build the environment
|
||||
# together with Octave.
|
||||
dontInstall = true;
|
||||
|
||||
inherit meta;
|
||||
} // attrs')
|
||||
245
pkgs/development/interpreters/octave/default.nix
Normal file
245
pkgs/development/interpreters/octave/default.nix
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
{ stdenv
|
||||
, pkgs
|
||||
, lib
|
||||
# Note: either stdenv.mkDerivation or, for octaveFull, the qt-5 mkDerivation
|
||||
# with wrapQtAppsHook (comes from libsForQt5.callPackage)
|
||||
, mkDerivation
|
||||
, fetchurl
|
||||
, gfortran
|
||||
, ncurses
|
||||
, perl
|
||||
, flex
|
||||
, texinfo
|
||||
, qhull
|
||||
, libsndfile
|
||||
, portaudio
|
||||
, libX11
|
||||
, graphicsmagick
|
||||
, pcre
|
||||
, pkg-config
|
||||
, libGL
|
||||
, libGLU
|
||||
, fltk
|
||||
# Both are needed for discrete Fourier transform
|
||||
, fftw
|
||||
, fftwSinglePrec
|
||||
, zlib
|
||||
, curl
|
||||
, blas, lapack
|
||||
# These two should use the same lapack and blas as the above
|
||||
, qrupdate, arpack, suitesparse ? null
|
||||
# If set to true, the above 5 deps are overriden to use the blas and lapack
|
||||
# with 64 bit indexes support. If all are not compatible, the build will fail.
|
||||
, use64BitIdx ? false
|
||||
, libwebp
|
||||
, gl2ps
|
||||
, ghostscript ? null
|
||||
, hdf5 ? null
|
||||
, glpk ? null
|
||||
, gnuplot ? null
|
||||
# - Include support for GNU readline:
|
||||
, enableReadline ? true
|
||||
, readline ? null
|
||||
# - Build Java interface:
|
||||
, enableJava ? true
|
||||
, jdk ? null
|
||||
, python ? null
|
||||
, overridePlatforms ? null
|
||||
, sundials ? null
|
||||
# - Packages required for building extra packages.
|
||||
, newScope
|
||||
, callPackage
|
||||
, makeSetupHook
|
||||
, makeWrapper
|
||||
# - Build Octave Qt GUI:
|
||||
, enableQt ? false
|
||||
, qtbase ? null
|
||||
, qtsvg ? null
|
||||
, qtscript ? null
|
||||
, qscintilla ? null
|
||||
, qttools ? null
|
||||
, libiconv
|
||||
, darwin
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
# Not always evaluated
|
||||
blas' = if use64BitIdx then
|
||||
blas.override {
|
||||
isILP64 = true;
|
||||
}
|
||||
else
|
||||
blas
|
||||
;
|
||||
lapack' = if use64BitIdx then
|
||||
lapack.override {
|
||||
isILP64 = true;
|
||||
}
|
||||
else
|
||||
lapack
|
||||
;
|
||||
qrupdate' = qrupdate.override {
|
||||
# If use64BitIdx is false, this override doesn't evaluate to a new
|
||||
# derivation, as blas and lapack are not overriden.
|
||||
blas = blas';
|
||||
lapack = lapack';
|
||||
};
|
||||
arpack' = arpack.override {
|
||||
blas = blas';
|
||||
lapack = lapack';
|
||||
};
|
||||
# Not always suitesparse is required at all
|
||||
suitesparse' = if suitesparse != null then
|
||||
suitesparse.override {
|
||||
blas = blas';
|
||||
lapack = lapack';
|
||||
}
|
||||
else
|
||||
null
|
||||
;
|
||||
|
||||
octavePackages = import ../../../top-level/octave-packages.nix {
|
||||
inherit pkgs;
|
||||
inherit lib stdenv fetchurl newScope;
|
||||
octave = self;
|
||||
};
|
||||
|
||||
wrapOctave = callPackage ./wrap-octave.nix {
|
||||
octave = self;
|
||||
inherit (pkgs) makeSetupHook makeWrapper;
|
||||
};
|
||||
|
||||
self = mkDerivation rec {
|
||||
version = "7.1.0";
|
||||
pname = "octave";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/octave/${pname}-${version}.tar.gz";
|
||||
sha256 = "sha256-1KnYHz9ntKbgfLeoDcsQrV6RdvzDB2LHCoFYCmS4sLY=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# https://savannah.gnu.org/bugs/?func=detailitem&item_id=62436
|
||||
./patches/bug62436.patch
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
readline
|
||||
ncurses
|
||||
perl
|
||||
flex
|
||||
qhull
|
||||
graphicsmagick
|
||||
pcre
|
||||
fltk
|
||||
zlib
|
||||
curl
|
||||
blas'
|
||||
lapack'
|
||||
libsndfile
|
||||
fftw
|
||||
fftwSinglePrec
|
||||
portaudio
|
||||
qrupdate'
|
||||
arpack'
|
||||
libwebp
|
||||
gl2ps
|
||||
]
|
||||
++ lib.optionals enableQt [
|
||||
qtbase
|
||||
qtsvg
|
||||
qscintilla
|
||||
]
|
||||
++ lib.optionals (ghostscript != null) [ ghostscript ]
|
||||
++ lib.optionals (hdf5 != null) [ hdf5 ]
|
||||
++ lib.optionals (glpk != null) [ glpk ]
|
||||
++ lib.optionals (suitesparse != null) [ suitesparse' ]
|
||||
++ lib.optionals (enableJava) [ jdk ]
|
||||
++ lib.optionals (sundials != null) [ sundials ]
|
||||
++ lib.optionals (gnuplot != null) [ gnuplot ]
|
||||
++ lib.optionals (python != null) [ python ]
|
||||
++ lib.optionals (!stdenv.isDarwin) [ libGL libGLU libX11 ]
|
||||
++ lib.optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
darwin.apple_sdk.frameworks.Accelerate
|
||||
darwin.apple_sdk.frameworks.Cocoa
|
||||
]
|
||||
;
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
gfortran
|
||||
# Listed here as well because it's outputs are split
|
||||
fftw
|
||||
fftwSinglePrec
|
||||
texinfo
|
||||
]
|
||||
++ lib.optionals (sundials != null) [ sundials ]
|
||||
++ lib.optionals enableQt [
|
||||
qtscript
|
||||
qttools
|
||||
]
|
||||
;
|
||||
|
||||
doCheck = !stdenv.isDarwin;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
# Fix linker error on Darwin (see https://trac.macports.org/ticket/61865)
|
||||
NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-lobjc";
|
||||
|
||||
# See https://savannah.gnu.org/bugs/?50339
|
||||
F77_INTEGER_8_FLAG = if use64BitIdx then "-fdefault-integer-8" else "";
|
||||
|
||||
configureFlags = [
|
||||
"--with-blas=blas"
|
||||
"--with-lapack=lapack"
|
||||
(if use64BitIdx then "--enable-64" else "--disable-64")
|
||||
]
|
||||
++ lib.optionals stdenv.isDarwin [ "--enable-link-all-dependencies" ]
|
||||
++ lib.optionals enableReadline [ "--enable-readline" ]
|
||||
++ lib.optionals stdenv.isDarwin [ "--with-x=no" ]
|
||||
++ lib.optionals enableQt [ "--with-qt=5" ]
|
||||
;
|
||||
|
||||
# Keep a copy of the octave tests detailed results in the output
|
||||
# derivation, because someone may care
|
||||
postInstall = ''
|
||||
cp test/fntests.log $out/share/octave/${pname}-${version}-fntests.log || true
|
||||
'';
|
||||
|
||||
passthru = rec {
|
||||
sitePath = "share/octave/${version}/site";
|
||||
octPkgsPath = "share/octave/octave_packages";
|
||||
blas = blas';
|
||||
lapack = lapack';
|
||||
qrupdate = qrupdate';
|
||||
arpack = arpack';
|
||||
suitesparse = suitesparse';
|
||||
inherit fftw fftwSinglePrec;
|
||||
inherit portaudio;
|
||||
inherit jdk;
|
||||
inherit python;
|
||||
inherit enableQt enableReadline enableJava;
|
||||
buildEnv = callPackage ./build-env.nix {
|
||||
octave = self;
|
||||
inherit octavePackages wrapOctave;
|
||||
inherit (octavePackages) computeRequiredOctavePackages;
|
||||
};
|
||||
withPackages = import ./with-packages.nix { inherit buildEnv octavePackages; };
|
||||
pkgs = octavePackages;
|
||||
interpreter = "${self}/bin/octave";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://www.gnu.org/software/octave/";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
maintainers = with lib.maintainers; [ raskin doronbehar ];
|
||||
description = "Scientific Programming Language";
|
||||
platforms = if overridePlatforms == null then
|
||||
(lib.platforms.linux ++ lib.platforms.darwin)
|
||||
else overridePlatforms;
|
||||
};
|
||||
};
|
||||
|
||||
in self
|
||||
13
pkgs/development/interpreters/octave/hooks/default.nix
Normal file
13
pkgs/development/interpreters/octave/hooks/default.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Hooks for building Octave packages.
|
||||
{ octave
|
||||
, lib
|
||||
, callPackage
|
||||
, makeSetupHook
|
||||
}:
|
||||
|
||||
rec {
|
||||
writeRequiredOctavePackagesHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "write-required-octave-packages-hook";
|
||||
} ./write-required-octave-packages-hook.sh) {};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Setup hook for writing octave packages that are run-time dependencies for
|
||||
# another package to a nix-support file.
|
||||
# `echo`s the full path name to the package derivation that is required.
|
||||
echo "Sourcing octave-write-required-octave-packages-hook.sh"
|
||||
|
||||
octaveWriteRequiredOctavePackagesPhase() {
|
||||
echo "Executing octaveWriteRequiredOctavePackagesPhase"
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo ${requiredOctavePackages} > $out/nix-support/required-octave-packages
|
||||
}
|
||||
|
||||
# Yes its a bit long...
|
||||
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
|
||||
echo "Using octaveWriteRequiredOctavePackagesPhase"
|
||||
preDistPhases+=" octaveWriteRequiredOctavePackagesPhase"
|
||||
fi
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Setup hook for writing octave packages that are run-time dependencies for
|
||||
# another package to a nix-support file.
|
||||
# `echo`s the full path name to the package derivation that is required.
|
||||
echo "Sourcing write-required-octave-packages-hook.sh"
|
||||
|
||||
writeRequiredOctavePackagesPhase() {
|
||||
echo "Executing writeRequiredOctavePackagesPhase"
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo ${requiredOctavePackages} > $out/nix-support/required-octave-packages
|
||||
}
|
||||
|
||||
# Yes its a bit long...
|
||||
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
|
||||
echo "Using writeRequiredOctavePackagesPhase"
|
||||
preDistPhases+=" writeRequiredOctavePackagesPhase"
|
||||
fi
|
||||
27
pkgs/development/interpreters/octave/patches/bug62436.patch
Normal file
27
pkgs/development/interpreters/octave/patches/bug62436.patch
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# HG changeset patch
|
||||
# User John Donoghue <john.donoghue@ieee.org>
|
||||
# Date 1652358904 14400
|
||||
# Thu May 12 08:35:04 2022 -0400
|
||||
# Branch stable
|
||||
# Node ID 8c940cfcce257369677c09154da2aab2c56eaa79
|
||||
# Parent 63710f3bd9811c2d206ac9e7b4f47cf06c47e153
|
||||
* scripts/pkg/private/build.m: check configure and Makefile exist before trying to unlink them (Bug #62436)
|
||||
|
||||
diff -r 63710f3bd981 -r 8c940cfcce25 scripts/pkg/private/build.m
|
||||
--- a/scripts/pkg/private/build.m Wed May 11 09:44:55 2022 -0700
|
||||
+++ b/scripts/pkg/private/build.m Thu May 12 08:35:04 2022 -0400
|
||||
@@ -77,8 +77,12 @@
|
||||
else
|
||||
arch_abi = getarch ();
|
||||
configure_make (desc, build_root, verbose);
|
||||
- unlink (fullfile (build_root, "src", "configure"));
|
||||
- unlink (fullfile (build_root, "src", "Makefile"));
|
||||
+ if exist (fullfile (build_root, "src", "configure"), "file")
|
||||
+ unlink (fullfile (build_root, "src", "configure"));
|
||||
+ endif
|
||||
+ if exist (fullfile (build_root, "src", "Makefile"), "file")
|
||||
+ unlink (fullfile (build_root, "src", "Makefile"));
|
||||
+ endif
|
||||
endif
|
||||
tar_name = [desc.name "-" desc.version "-" arch_abi ".tar"];
|
||||
tar_path = fullfile (builddir, tar_name);
|
||||
6
pkgs/development/interpreters/octave/with-packages.nix
Normal file
6
pkgs/development/interpreters/octave/with-packages.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{ buildEnv, octavePackages }:
|
||||
|
||||
# Takes the buildEnv defined for Octave and the set of octavePackages, and returns
|
||||
# a function, which when given a function whose return value is a list of extra
|
||||
# packages to install, builds and returns that environment.
|
||||
f: let packages = f octavePackages; in buildEnv.override { extraLibs = packages; }
|
||||
16
pkgs/development/interpreters/octave/wrap-octave.nix
Normal file
16
pkgs/development/interpreters/octave/wrap-octave.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ lib
|
||||
, octave
|
||||
, makeSetupHook
|
||||
, makeWrapper
|
||||
}:
|
||||
|
||||
# Defined in trivial-builders.nix
|
||||
# Imported as wrapOctave in octave/default.nix and passed to octave's buildEnv
|
||||
# as nativeBuildInput
|
||||
# Each of the substitutions is available in the wrap.sh script as @thingSubstituted@
|
||||
makeSetupHook {
|
||||
name = "${octave.name}-pkgs-setup-hook";
|
||||
deps = makeWrapper;
|
||||
substitutions.executable = octave.interpreter;
|
||||
substitutions.octave = octave;
|
||||
} ./wrap.sh
|
||||
132
pkgs/development/interpreters/octave/wrap.sh
Normal file
132
pkgs/development/interpreters/octave/wrap.sh
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
# Unlinks a directory (given as the first argument), and re-creates that
|
||||
# directory as an actual directory. Then descends into the directory of
|
||||
# the same name in the origin (arg_2/arg_3) and symlinks the contents of
|
||||
# that directory into the passed end-location.
|
||||
unlinkDirReSymlinkContents() {
|
||||
local dirToUnlink="$1"
|
||||
local origin="$2"
|
||||
local contentsLocation="$3"
|
||||
|
||||
unlink $dirToUnlink/$contentsLocation
|
||||
mkdir -p $dirToUnlink/$contentsLocation
|
||||
for f in $origin/$contentsLocation/*; do
|
||||
ln -s -t "$dirToUnlink/$contentsLocation" "$f"
|
||||
done
|
||||
}
|
||||
|
||||
# Using unlinkDirReSymlinkContents, un-symlinks directories down to
|
||||
# $out/share/octave, and then creates the octave_packages directory.
|
||||
createOctavePackagesPath() {
|
||||
local desiredOut=$1
|
||||
local origin=$2
|
||||
|
||||
if [ -L "$out/share" ]; then
|
||||
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share"
|
||||
fi
|
||||
|
||||
if [ -L "$out/share/octave" ]; then
|
||||
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share/octave"
|
||||
fi
|
||||
|
||||
# Now that octave_packages has a path rather than symlinks, create the
|
||||
# octave_packages directory for installed packages.
|
||||
mkdir -p "$desiredOut/share/octave/octave_packages"
|
||||
}
|
||||
|
||||
# First, descends down to $out/share/octave/site/m/startup/octaverc, and
|
||||
# copies that start-up file. Once done, it performs a `chmod` to allow
|
||||
# writing. Lastly, it `echo`s the location of the locally installed packages
|
||||
# to the startup file, allowing octave to discover installed packages.
|
||||
addPkgLocalList() {
|
||||
local desiredOut=$1
|
||||
local origin=$2
|
||||
local octaveSite="share/octave/site"
|
||||
local octaveSiteM="$octaveSite/m"
|
||||
local octaveSiteStartup="$octaveSiteM/startup"
|
||||
local siteOctavercStartup="$octaveSiteStartup/octaverc"
|
||||
|
||||
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSite"
|
||||
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteM"
|
||||
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteStartup"
|
||||
|
||||
unlink "$out/$siteOctavercStartup"
|
||||
cp "$origin/$siteOctavercStartup" "$desiredOut/$siteOctavercStartup"
|
||||
chmod u+w "$desiredOut/$siteOctavercStartup"
|
||||
echo "pkg local_list $out/.octave_packages" >> "$desiredOut/$siteOctavercStartup"
|
||||
}
|
||||
|
||||
# Wrapper function for wrapOctaveProgramsIn. Takes one argument, a
|
||||
# space-delimited string of packages' paths that will be installed.
|
||||
wrapOctavePrograms() {
|
||||
wrapOctaveProgramsIn "$out/bin" "$out" "$@"
|
||||
}
|
||||
|
||||
# Wraps all octave programs in $out/bin with all the propagated inputs that
|
||||
# a particular package requires. $1 is the directory to look for binaries in
|
||||
# to wrap. $2 is the path to the octave ENVIRONMENT. $3 is the space-delimited
|
||||
# string of packages.
|
||||
wrapOctaveProgramsIn() {
|
||||
local dir="$1"
|
||||
local octavePath="$2"
|
||||
local pkgs="$3"
|
||||
local f
|
||||
|
||||
buildOctavePath "$octavePath" "$pkgs"
|
||||
|
||||
# Find all regular files in the output directory that are executable.
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
|
||||
echo "wrapping \`$f'..."
|
||||
local -a wrap_args=("$f"
|
||||
--prefix PATH ':' "$program_PATH"
|
||||
)
|
||||
local -a wrapProgramArgs=("${wrap_args[@]}")
|
||||
wrapProgram "${wrapProgramArgs[@]}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Build the PATH environment variable by walking through the closure of
|
||||
# dependencies. Starts by constructing the `program_PATH` variable with the
|
||||
# environment's path, then adding the original octave's location, and marking
|
||||
# them in `octavePathsSeen`.
|
||||
buildOctavePath() {
|
||||
local octavePath="$1"
|
||||
local packages="$2"
|
||||
|
||||
local pathsToSearch="$octavePath $packages"
|
||||
|
||||
# Create an empty table of Octave paths.
|
||||
declare -A octavePathsSeen=()
|
||||
program_PATH=
|
||||
octavePathsSeen["$out"]=1
|
||||
octavePathsSeen["@octave@"]=1
|
||||
addToSearchPath program_PATH "$out/bin"
|
||||
addToSearchPath program_PATH "@octave@/bin"
|
||||
echo "program_PATH to change to is: $program_PATH"
|
||||
for path in $pathsToSearch; do
|
||||
echo "Recurse to propagated-build-input: $path"
|
||||
_addToOctavePath $path
|
||||
done
|
||||
}
|
||||
|
||||
# Adds the bin directories to the program_PATH variable.
|
||||
# Recurses on any paths declared in `propagated-build-inputs`, while avoiding
|
||||
# duplicating paths by flagging the directires it has seen in `octavePathsSeen`.
|
||||
_addToOctavePath() {
|
||||
local dir="$1"
|
||||
# Stop if we've already visited this path.
|
||||
if [ -n "${octavePathsSeen[$dir]}" ]; then return; fi
|
||||
octavePathsSeen[$dir]=1
|
||||
# addToSearchPath is defined in stdenv/generic/setup.sh. It has the effect
|
||||
# of calling `export X=$dir/...:$X`.
|
||||
addToSearchPath program_PATH $dir/bin
|
||||
|
||||
# Inspect the propagated inputs (if they exist) and recur on them.
|
||||
local prop="$dir/nix-support/propagated-build-inputs"
|
||||
if [ -e $prop ]; then
|
||||
for new_path in $(cat $prop); do
|
||||
_addToOctavePath $new_path
|
||||
done
|
||||
fi
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue