cplex: meta.mainProgram, desktop entry, fix oplide GUI, misc fixes (#361105)

This commit is contained in:
Wolfgang Walther 2024-12-15 22:03:54 +01:00 committed by GitHub
commit 153abc87a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
{ lib, stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }:
{ lib, stdenv, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, alsa-lib, glib, glib-networking, gsettings-desktop-schemas, gtk3, libsecret, openjdk, sqlite, unixODBC, gtk2, xorg, glibcLocales, releasePath ? null }:
# To use this package, you need to download your own cplex installer from IBM
# and override the releasePath attribute to point to the location of the file.
@ -26,51 +26,97 @@ stdenv.mkDerivation rec {
else
releasePath;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ];
nativeBuildInputs = [ autoPatchelfHook copyDesktopItems makeWrapper openjdk ];
buildInputs = [ alsa-lib gsettings-desktop-schemas gtk2 sqlite unixODBC xorg.libXtst glibcLocales ];
unpackPhase = "cp $src $name";
patchPhase = ''
postPatch = ''
sed -i -e 's|/usr/bin/tr"|tr" |' $name
'';
buildPhase = ''
runHook preBuild
export JAVA_TOOL_OPTIONS=-Djdk.util.zip.disableZip64ExtraFieldValidation=true
sh $name LAX_VM ${openjdk}/bin/java -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
sh $name LAX_VM "$(command -v java)" -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
runHook postBuild
'';
installPhase = ''
mkdir -p $out/bin
ln -s $out/opl/bin/x86-64_linux/oplrun\
$out/opl/bin/x86-64_linux/oplrunjava\
$out/opl/oplide/oplide\
$out/cplex/bin/x86-64_linux/cplex\
$out/cpoptimizer/bin/x86-64_linux/cpoptimizer\
$out/bin
'';
fixupPhase =
let
libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
installPhase = let
libraryPath = lib.makeLibraryPath [ stdenv.cc.cc glib gtk2 gtk3 libsecret xorg.libXtst ];
in ''
interpreter=${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2
runHook preInstall
for pgm in $out/opl/bin/x86-64_linux/oplrun $out/opl/bin/x86-64_linux/oplrunjava $out/opl/oplide/oplide;
do
patchelf --set-interpreter "$interpreter" $pgm;
wrapProgram $pgm \
--prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \
--set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
done
mkdir -p $out/bin
for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*;
for pgm in \
$out/opl/bin/x86-64_linux/oplrun \
$out/opl/bin/x86-64_linux/oplrunjava \
$out/opl/oplide/oplide \
$out/cplex/bin/x86-64_linux/cplex \
$out/cpoptimizer/bin/x86-64_linux/cpoptimizer
do
if grep ELF $pgm > /dev/null;
then
patchelf --set-interpreter "$interpreter" $pgm;
makeWrapperArgs=(
--set-default LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive
)
if [[ "$pgm" = "$out/opl/oplide/oplide" ]]; then
makeWrapperArgs+=(
--prefix LD_LIBRARY_PATH : ${libraryPath}
--prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules"
--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
)
fi
makeWrapper "$pgm" "$out/bin/$(basename "$pgm")" "''${makeWrapperArgs[@]}"
done
mkdir -p $out/share/pixmaps
ln -s $out/opl/oplide/icon.xpm $out/share/pixmaps/oplide.xpm
mkdir -p $out/share/doc
mv $out/doc $out/share/doc/$name
mkdir -p $out/share/licenses
mv $out/license $out/share/licenses/$name
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = "oplide";
desktopName = "IBM ILOG CPLEX Optimization Studio";
genericName = "Optimization Software";
icon = "oplide";
exec = "oplide";
categories = [ "Development" "IDE" "Math" "Science" ];
})
];
fixupPhase = ''
runHook preFixup
rm -r $out/Uninstall
bins=(
$out/bin/*
$out/cplex/bin/x86-64_linux/cplex
$out/cplex/bin/x86-64_linux/cplexamp
$out/cpoptimizer/bin/x86-64_linux/cpoptimizer
$out/opl/bin/x86-64_linux/oplrun
$out/opl/bin/x86-64_linux/oplrunjava
$out/opl/oplide/jre/bin/*
$out/opl/oplide/oplide
)
find $out -type d -exec chmod 755 {} \;
find $out -type f -exec chmod 644 {} \;
chmod +111 "''${bins[@]}"
runHook postFixup
'';
passthru = {
@ -81,6 +127,7 @@ stdenv.mkDerivation rec {
meta = with lib; {
description = "Optimization solver for mathematical programming";
homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex";
mainProgram = "cplex";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
platforms = [ "x86_64-linux" ];