From 5a7e93fef9d32af785bbb1ab43c3fd04cc89c48c Mon Sep 17 00:00:00 2001 From: Rhys Davies Date: Fri, 17 Mar 2023 21:33:47 +1300 Subject: [PATCH] msalsdk-dbusclient: init at 1.0.1 --- .../by-name/ms/msalsdk-dbusclient/package.nix | 37 +++++++++++++++++++ pkgs/by-name/ms/msalsdk-dbusclient/update.sh | 26 +++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 pkgs/by-name/ms/msalsdk-dbusclient/package.nix create mode 100755 pkgs/by-name/ms/msalsdk-dbusclient/update.sh diff --git a/pkgs/by-name/ms/msalsdk-dbusclient/package.nix b/pkgs/by-name/ms/msalsdk-dbusclient/package.nix new file mode 100644 index 000000000000..2fcccf8c6c9e --- /dev/null +++ b/pkgs/by-name/ms/msalsdk-dbusclient/package.nix @@ -0,0 +1,37 @@ +{ stdenv +, lib +, fetchurl +, dpkg +, sdbus-cpp +}: +stdenv.mkDerivation rec { + pname = "msalsdk-dbusclient"; + version = "1.0.1"; + + src = fetchurl { + url = "https://packages.microsoft.com/ubuntu/22.04/prod/pool/main/m/${pname}/${pname}_${version}_amd64.deb"; + hash = "sha256-AVPrNxCjXGza2gGETP0YrlXeEgI6AjlrSVTtqKb2UBI="; + }; + + nativeBuildInputs = [ dpkg ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib + install -m 755 usr/lib/libmsal_dbus_client.so $out/lib/ + patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc.lib sdbus-cpp ]} $out/lib/libmsal_dbus_client.so + + runHook postInstall + ''; + + passthru.updateScript = ./update.sh; + meta = with lib; { + description = "Microsoft Authentication Library cross platform Dbus client for talking to microsoft-identity-broker"; + homepage = "https://github.com/AzureAD/microsoft-authentication-library-for-cpp"; + license = licenses.unfree; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + platforms = [ "x86_64-linux" ]; + maintainers = with lib.maintainers; [ rhysmdnz ]; + }; +} diff --git a/pkgs/by-name/ms/msalsdk-dbusclient/update.sh b/pkgs/by-name/ms/msalsdk-dbusclient/update.sh new file mode 100755 index 000000000000..e804eeb935ee --- /dev/null +++ b/pkgs/by-name/ms/msalsdk-dbusclient/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}" == "msalsdk-dbusclient" ]]; 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 msalsdk-dbusclient $version)