mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-31 01:04:25 +00:00
Merge pull request #211867 from wegank/scilab-bin-refactor
scilab-bin: refactor
This commit is contained in:
commit
4389f86425
@ -1,4 +1,13 @@
|
||||
{ lib, stdenv, fetchurl, undmg, makeWrapper, xorg }:
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, makeWrapper
|
||||
, undmg
|
||||
, autoPatchelfHook
|
||||
, alsa-lib
|
||||
, ncurses5
|
||||
, xorg
|
||||
}:
|
||||
|
||||
let
|
||||
pname = "scilab-bin";
|
||||
@ -26,88 +35,69 @@ let
|
||||
platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
license = lib.licenses.gpl2Only;
|
||||
mainProgram = "scilab";
|
||||
};
|
||||
|
||||
darwin = stdenv.mkDerivation rec {
|
||||
inherit pname version src meta;
|
||||
|
||||
nativeBuildInputs = [ undmg makeWrapper ];
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
undmg
|
||||
];
|
||||
|
||||
sourceRoot = "scilab-${version}.app";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{Applications/scilab.app,bin}
|
||||
cp -R . $out/Applications/scilab.app
|
||||
makeWrapper $out/{Applications/scilab.app/Contents/MacOS,bin}/scilab
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
linux = stdenv.mkDerivation rec {
|
||||
inherit pname version src meta;
|
||||
|
||||
libPath = lib.makeLibraryPath [
|
||||
stdenv.cc.cc
|
||||
xorg.libX11
|
||||
xorg.libXext
|
||||
xorg.libXi
|
||||
xorg.libXrender
|
||||
xorg.libXtst
|
||||
xorg.libXxf86vm
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
];
|
||||
|
||||
fixupPhase = ''
|
||||
sed -i 's|\$(/bin/|$(|g' bin/scilab
|
||||
sed -i 's|/usr/bin/||g' bin/scilab
|
||||
buildInputs = [
|
||||
alsa-lib
|
||||
ncurses5
|
||||
stdenv.cc.cc
|
||||
] ++ (with xorg; [
|
||||
libX11
|
||||
libXcursor
|
||||
libXext
|
||||
libXft
|
||||
libXi
|
||||
libXrandr
|
||||
libXrender
|
||||
libXtst
|
||||
libXxf86vm
|
||||
]);
|
||||
|
||||
sci="$out/opt/scilab-${version}"
|
||||
fullLibPath="$sci/lib/scilab:$sci/lib/thirdparty:$libPath"
|
||||
fullLibPath="$fullLibPath:$sci/lib/thirdparty/redist"
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$fullLibPath" bin/scilab-bin
|
||||
find . -name '*.so' -type f | while read file; do
|
||||
patchelf --set-rpath "$fullLibPath" "$file" 2>/dev/null
|
||||
done
|
||||
'';
|
||||
mkdir -p $out
|
||||
mv -t $out bin include lib share thirdparty
|
||||
sed -i \
|
||||
-e 's|\$(/bin/|$(|g' \
|
||||
-e 's|/usr/bin/||g' \
|
||||
$out/bin/{scilab,xcos}
|
||||
sed -i \
|
||||
-e "s|Exec=|Exec=$out/bin/|g" \
|
||||
-e "s|Terminal=.*$|Terminal=true|g" \
|
||||
$out/share/applications/*.desktop
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/opt/scilab-${version}"
|
||||
cp -r . "$out/opt/scilab-${version}/"
|
||||
|
||||
# Create bin/ dir
|
||||
mkdir "$out/bin"
|
||||
|
||||
# Creating executable symlinks
|
||||
ln -s "$out/opt/scilab-${version}/bin/scilab" "$out/bin/scilab"
|
||||
ln -s "$out/opt/scilab-${version}/bin/scilab-cli" "$out/bin/scilab-cli"
|
||||
ln -s "$out/opt/scilab-${version}/bin/scilab-adv-cli" "$out/bin/scilab-adv-cli"
|
||||
|
||||
# Creating desktop config dir
|
||||
mkdir -p "$out/share/applications"
|
||||
|
||||
# Moving desktop config files
|
||||
mv $out/opt/scilab-${version}/share/applications/*.desktop $out/share/applications
|
||||
|
||||
# Fixing Exec paths and launching each app with a terminal
|
||||
sed -i -e "s|Exec=|Exec=$out/opt/scilab-${version}/bin/|g" \
|
||||
-e "s|Terminal=.*$|Terminal=true|g" $out/share/applications/*.desktop
|
||||
|
||||
# Moving icons to the appropriate locations
|
||||
for path in $out/opt/scilab-${version}/share/icons/hicolor/*/*/*
|
||||
do
|
||||
newpath=$(echo $path | sed 's|/opt/scilab-${version}||g')
|
||||
filename=$(echo $path | sed 's|.*/||g')
|
||||
dir=$(echo $newpath | sed "s|$filename||g")
|
||||
mkdir -p $dir
|
||||
mv $path $newpath
|
||||
done
|
||||
|
||||
# Removing emptied folders
|
||||
rm -rf $out/opt/scilab-${version}/share/{applications,icons}
|
||||
|
||||
# Moving other share/ folders
|
||||
mv $out/opt/scilab-${version}/share/{appdata,locale,mime} $out/share
|
||||
'';
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
if stdenv.isDarwin then darwin else linux
|
||||
|
Loading…
Reference in New Issue
Block a user