about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/in/intune-portal/update.sh
blob: 4908bcf4379412805982a769341a1f58859559f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)