nixpkgs/pkgs/applications/networking/remote/citrix-workspace/generic.nix
Alyssa Ross fd78240ac8
treewide: use lib.getLib for OpenSSL libraries
At some point, I'd like to make another attempt at
71f1f4884b ("openssl: stop static binaries referencing libs"), which
was reverted in 195c7da07d.  One problem with my previous attempt is
that I moved OpenSSL's libraries to a lib output, but many dependent
packages were hardcoding the out output as the location of the
libraries.  This patch fixes every such case I could find in the tree.
It won't have any effect immediately, but will mean these packages
will automatically use an OpenSSL lib output if it is reintroduced in
future.

This patch should cause very few rebuilds, because it shouldn't make
any change at all to most packages I'm touching.  The few rebuilds
that are introduced come from when I've changed a package builder not
to use variable names like openssl.out in scripts / substitution
patterns, which would be confusing since they don't hardcode the
output any more.

I started by making the following global replacements:

    ${pkgs.openssl.out}/lib -> ${lib.getLib pkgs.openssl}/lib
    ${openssl.out}/lib -> ${lib.getLib openssl}/lib

Then I removed the ".out" suffix when part of the argument to
lib.makeLibraryPath, since that function uses lib.getLib internally.

Then I fixed up cases where openssl was part of the -L flag to the
compiler/linker, since that unambigously is referring to libraries.

Then I manually investigated and fixed the following packages:

 - pycurl
 - citrix-workspace
 - ppp
 - wraith
 - unbound
 - gambit
 - acl2

I'm reasonably confindent in my fixes for all of them.

For acl2, since the openssl library paths are manually provided above
anyway, I don't think openssl is required separately as a build input
at all.  Removing it doesn't make a difference to the output size, the
file list, or the closure.

I've tested evaluation with the OfBorg meta checks, to protect against
introducing evaluation failures.
2022-03-30 15:10:00 +00:00

214 lines
6.3 KiB
Nix

{ lib, stdenv, requireFile, makeWrapper, autoPatchelfHook, wrapGAppsHook, which, more
, file, atk, alsa-lib, cairo, fontconfig, gdk-pixbuf, glib, webkitgtk, gtk2-x11, gtk3
, heimdal, krb5, libsoup, libvorbis, speex, openssl, zlib, xorg, pango, gtk2
, gnome2, mesa, nss, nspr, gtk_engines, freetype, dconf, libpng12, libxml2
, libjpeg, libredirect, tzdata, cacert, systemd, libcxxabi, libcxx, e2fsprogs, symlinkJoin
, libpulseaudio, pcsclite, glib-networking, llvmPackages_12
, homepage, version, prefix, hash
, extraCerts ? []
}:
let
openssl' = symlinkJoin {
name = "openssl-backwards-compat";
nativeBuildInputs = [ makeWrapper ];
paths = [ (lib.getLib openssl) ];
postBuild = ''
ln -sf $out/lib/libcrypto.so $out/lib/libcrypto.so.1.0.0
ln -sf $out/lib/libssl.so $out/lib/libssl.so.1.0.0
'';
};
in
stdenv.mkDerivation rec {
pname = "citrix-workspace";
inherit version;
src = requireFile rec {
name = "${prefix}-${version}.tar.gz";
sha256 = hash;
message = ''
In order to use Citrix Workspace, you need to comply with the Citrix EULA and download
the ${if stdenv.is64bit then "64-bit" else "32-bit"} binaries, .tar.gz from:
${homepage}
(if you do not find version ${version} there, try at
https://www.citrix.com/downloads/workspace-app/
Once you have downloaded the file, please use the following command and re-run the
installation:
nix-prefetch-url file://\$PWD/${name}
'';
};
dontBuild = true;
dontConfigure = true;
sourceRoot = ".";
preferLocalBuild = true;
passthru.icaroot = "${placeholder "out"}/opt/citrix-icaclient";
nativeBuildInputs = [
autoPatchelfHook
file
makeWrapper
more
which
wrapGAppsHook
];
buildInputs = [
alsa-lib
atk
cairo
dconf
fontconfig
freetype
gdk-pixbuf
gnome2.gtkglext
glib-networking
webkitgtk
gtk2
gtk2-x11
gtk3
gtk_engines
heimdal
krb5
libcxx
libcxxabi
libjpeg
libpng12
libsoup
libvorbis
libxml2
mesa
nspr
nss
openssl'
pango
speex
(lib.getLib systemd)
stdenv.cc.cc
xorg.libXaw
xorg.libXmu
xorg.libXScrnSaver
xorg.libXtst
zlib
] ++ lib.optional (lib.versionOlder version "20.04") e2fsprogs
++ lib.optional (lib.versionAtLeast version "20.10") libpulseaudio
++ lib.optional (lib.versionAtLeast version "21.12") llvmPackages_12.libunwind;
runtimeDependencies = [
glib
glib-networking
pcsclite
xorg.libX11
xorg.libXScrnSaver
xorg.libXext
xorg.libXfixes
xorg.libXinerama
xorg.libXmu
xorg.libXrender
xorg.libXtst
xorg.libxcb
];
installPhase = let
icaFlag = program:
if (builtins.match "selfservice(.*)" program) != null then "--icaroot"
else if (lib.versionAtLeast version "21.12" && builtins.match "wfica(.*)" program != null) then null
else "-icaroot";
wrap = program: ''
wrapProgram $out/opt/citrix-icaclient/${program} \
${lib.optionalString (icaFlag program != null) ''--add-flags "${icaFlag program} $ICAInstDir"''} \
--set ICAROOT "$ICAInstDir" \
--prefix LD_LIBRARY_PATH : "$ICAInstDir:$ICAInstDir/lib" \
--set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS "/usr/share/zoneinfo=${tzdata}/share/zoneinfo:/etc/zoneinfo=${tzdata}/share/zoneinfo:/etc/timezone=$ICAInstDir/timezone"
'';
wrapLink = program: ''
${wrap program}
ln -sf $out/opt/citrix-icaclient/${program} $out/bin/${baseNameOf program}
'';
copyCert = path: ''
cp -v ${path} $out/opt/citrix-icaclient/keystore/cacerts/${baseNameOf path}
'';
mkWrappers = lib.concatMapStringsSep "\n";
toWrap = [ "wfica" "selfservice" "util/configmgr" "util/conncenter" "util/ctx_rehash" ]
++ lib.optional (lib.versionOlder version "20.06") "selfservice_old";
in ''
runHook preInstall
mkdir -p $out/{bin,share/applications}
export ICAInstDir="$out/opt/citrix-icaclient"
export HOME=$(mktemp -d)
# Run upstream installer in the store-path.
sed -i -e 's,^ANSWER="",ANSWER="$INSTALLER_YES",g' -e 's,/bin/true,true,g' ./${prefix}/hinst
${stdenv.shell} ${prefix}/hinst CDROM "$(pwd)"
if [ -f "$ICAInstDir/util/setlog" ]; then
chmod +x "$ICAInstDir/util/setlog"
ln -sf "$ICAInstDir/util/setlog" "$out/bin/citrix-setlog"
fi
${mkWrappers wrapLink toWrap}
${mkWrappers wrap [ "PrimaryAuthManager" "ServiceRecord" "AuthManagerDaemon" "util/ctxwebhelper" ]}
ln -sf $ICAInstDir/util/storebrowse $out/bin/storebrowse
# As explained in https://wiki.archlinux.org/index.php/Citrix#Security_Certificates
echo "Expanding certificates..."
pushd "$ICAInstDir/keystore/cacerts"
awk 'BEGIN {c=0;} /BEGIN CERT/{c++} { print > "cert." c ".pem"}' \
< ${cacert}/etc/ssl/certs/ca-bundle.crt
popd
${mkWrappers copyCert extraCerts}
# See https://developer-docs.citrix.com/projects/workspace-app-for-linux-oem-guide/en/latest/reference-information/#library-files
# Those files are fallbacks to support older libwekit.so and libjpeg.so
rm $out/opt/citrix-icaclient/lib/ctxjpeg_fb_8.so || true
rm $out/opt/citrix-icaclient/lib/UIDialogLibWebKit.so || true
# We support only Gstreamer 1.0
rm $ICAInstDir/util/{gst_aud_{play,read},gst_*0.10,libgstflatstm0.10.so}
ln -sf $ICAInstDir/util/gst_play1.0 $ICAInstDir/util/gst_play
ln -sf $ICAInstDir/util/gst_read1.0 $ICAInstDir/util/gst_read
echo "We arbitrarily set the timezone to UTC. No known consequences at this point."
echo UTC > "$ICAInstDir/timezone"
echo "Copy .desktop files."
cp $out/opt/citrix-icaclient/desktop/* $out/share/applications/
# We introduce a dependency on the source file so that it need not be redownloaded everytime
echo $src >> "$out/share/workspace_dependencies.pin"
runHook postInstall
'';
# Make sure that `autoPatchelfHook` is executed before
# running `ctx_rehash`.
dontAutoPatchelf = true;
postFixup = ''
autoPatchelf -- "$out"
$out/opt/citrix-icaclient/util/ctx_rehash
'';
meta = with lib; {
license = licenses.unfree;
description = "Citrix Workspace";
platforms = platforms.linux;
maintainers = with maintainers; [ pmenke ];
inherit homepage;
};
}