name: powerstat
summary: computer power measuring tool
description: Powerstat measures the power consumption of a computer that has a battery power source or an Intel RAPL power domain.  The output is like vmstat but also shows power consumption statistics.  At the end of a run, powerstat will calculate the average, standard deviation and min/max of the gathered data.
confinement: strict
type: app
grade: stable
assumes: [snapd2.45]
base: core20
adopt-info: powerstat

architectures:
    - build-on: s390x
    - build-on: ppc64el
    - build-on: arm64
    - build-on: armhf
    - build-on: amd64
    - build-on: i386

parts:
    powerstat:
        plugin: make
        source: git://kernel.ubuntu.com/cking/powerstat
        override-pull: |
            snapcraftctl pull
            description="$(git describe HEAD --tags)"
            sha=$(echo $description | tr '-' ' ' | awk '{print $NF}')
            version=${description%$sha}
            commits=$(git log --oneline | wc -l)
            date=$(date +'%Y%m%d')
            if test "$description" = "$sha"
            then
                version="$description"
            else
                version=$(echo $version$date-$commits-$sha | cut -c1-32)
            fi
            snapcraftctl set-version "$version"
        build-packages:
            - gcc
            - make

apps:
    powerstat:
        command: usr/bin/powerstat
        plugs: [hardware-observe,netlink-connector,system-observe]

