From 3f81c313c613ef23452445653f420b1148167fa6 Mon Sep 17 00:00:00 2001 From: Rhys Davies Date: Fri, 17 Mar 2023 21:37:05 +1300 Subject: [PATCH] intune-portal: init at 1.2312.35-jammy --- pkgs/by-name/in/intune-portal/package.nix | 109 ++++++++++++++++++++++ pkgs/by-name/in/intune-portal/update.sh | 26 ++++++ 2 files changed, 135 insertions(+) create mode 100644 pkgs/by-name/in/intune-portal/package.nix create mode 100755 pkgs/by-name/in/intune-portal/update.sh diff --git a/pkgs/by-name/in/intune-portal/package.nix b/pkgs/by-name/in/intune-portal/package.nix new file mode 100644 index 000000000000..66c5a4372d70 --- /dev/null +++ b/pkgs/by-name/in/intune-portal/package.nix @@ -0,0 +1,109 @@ +{ stdenv +, lib +, fetchurl +, dpkg +, libuuid +, xorg +, curlMinimal +, openssl +, libsecret +, webkitgtk +, libsoup +, gtk3 +, atk +, pango +, glib +, sqlite +, zlib +, systemd +, msalsdk-dbusclient +, pam +, dbus +}: +stdenv.mkDerivation rec { + pname = "intune-portal"; + version = "1.2312.35-jammy"; + + src = fetchurl { + url = "https://packages.microsoft.com/ubuntu/22.04/prod/pool/main/i/${pname}/${pname}_${version}_amd64.deb"; + hash = "sha256-mgcnqj/+4ffMf4PhMW4ovCotLilyudGOpn0qqXZCmzc="; + }; + + nativeBuildInputs = [ dpkg ]; + + buildPhase = + let + libPath = { + intune = lib.makeLibraryPath [ + stdenv.cc.cc.lib + libuuid + xorg.libX11 + curlMinimal + openssl + libsecret + webkitgtk + libsoup + gtk3 + atk + glib + pango + sqlite + zlib + systemd + msalsdk-dbusclient + dbus + ]; + pam = lib.makeLibraryPath [ pam ]; + }; + in + '' + runHook preBuild + + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath ${libPath.intune} opt/microsoft/intune/bin/intune-portal + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath ${libPath.intune} opt/microsoft/intune/bin/intune-agent + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath ${libPath.intune} opt/microsoft/intune/bin/intune-daemon + patchelf --set-rpath ${libPath.pam} ./usr/lib/x86_64-linux-gnu/security/pam_intune.so + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp -a opt/microsoft/intune/bin/* $out/bin/ + cp -a usr/share $out + cp -a lib $out + mkdir -p $out/lib/security + cp -a ./usr/lib/x86_64-linux-gnu/security/pam_intune.so $out/lib/security/ + cp -a usr/lib/tmpfiles.d $out/lib + + substituteInPlace $out/share/applications/intune-portal.desktop \ + --replace /opt/microsoft/intune/bin/intune-portal $out/bin/intune-portal + + substituteInPlace $out/lib/systemd/user/intune-agent.service \ + --replace \ + ExecStart=/opt/microsoft/intune/bin/intune-agent \ + ExecStart=$out/bin/intune-agent + + substituteInPlace $out/lib/systemd/system/intune-daemon.service \ + --replace \ + ExecStart=/opt/microsoft/intune/bin/intune-daemon \ + ExecStart=$out/bin/intune-daemon + + runHook postInstall + ''; + + # Without this network requests fail + dontPatchELF = true; + + passthru.updateScript = ./update.sh; + + meta = with lib; { + description = "Microsoft Intune Portal allows you to securely access corporate apps, data, and resources"; + homepage = "https://www.microsoft.com/"; + license = licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with lib.maintainers; [ rhysmdnz ]; + }; +} diff --git a/pkgs/by-name/in/intune-portal/update.sh b/pkgs/by-name/in/intune-portal/update.sh new file mode 100755 index 000000000000..4908bcf43794 --- /dev/null +++ b/pkgs/by-name/in/intune-portal/update.sh @@ -0,0 +1,26 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p curl gzip dpkg common-updater-scripts + +index_file=$(curl -sL https://packages.microsoft.com/ubuntu/22.04/prod/dists/jammy/main/binary-amd64/Packages.gz | gzip -dc) + +latest_version="0" + +echo "$index_file" | while read -r line; do + if [[ "$line" =~ ^Package:[[:space:]]*(.*) ]]; then + Package="${BASH_REMATCH[1]}" + fi + if [[ "$line" =~ ^Version:[[:space:]]*(.*) ]]; then + Version="${BASH_REMATCH[1]}" + fi + + if ! [[ "$line" ]] && [[ "${Package}" == "intune-portal" ]]; then + if ( dpkg --compare-versions ${Version} gt ${latest_version} ); then + latest_version="${Version}" + + echo $latest_version + fi + + Package="" + Version="" + fi +done | tail -n 1 | (read version; update-source-version intune-portal $version)