geoffreybennett/alsa-scarlett-gui

Missing version in flatpak app

Closed this issue · 6 comments

image

The About window does not show the version in flatpak.
Build run logs :

Starting build of vu.b4.alsa-scarlett-gui
========================================================================
Building module alsa-scarlett-gui in /__w/alsa-scarlett-gui/alsa-scarlett-gui/.flatpak-builder/build/alsa-scarlett-gui-1
========================================================================
Running: make install PREFIX=$FLATPAK_DEST
fatal: not a git repository (or any parent up to mount point /run/build)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
cc -MT about.o -MMD -MP -MF .deps/about.d -Wall -Werror -ggdb -fno-omit-frame-pointer -O2 -D_FORTIFY_SOURCE=2 -DVERSION=\"\" -Wno-error=deprecated-declarations -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/webp -I/usr/include/blkid -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/libmount -I/usr/include/sysprof-6 -pthread -c -o about.o about.c

We can see the -DVERSION=\"\" after a git error fatal: not a git repository. The error occurs in the Makefile when trying to get the version with following line:

VERSION := $(shell git describe --abbrev=4 --always --tags | sed 's/-/./g')

But as we can see, flatpak-builder copied the source code in a temp workspace without copying the .git directory, so the command fails.

I see in the logs:

Run flatpak/flatpak-github-actions/flatpak-builder@v6
...
  env:
    APP_NAME: alsa-scarlett-gui
    APP_VERSION: 0.3

I presume this can be accessed from the Makefile? I pushed a change, hoping that's the case.

I tried something similar, but the problem is that flatpak-builder does not transfer environment variables (I'm still looking for the option)

$ flatpak-builder --force-clean build-dir ./vu.b4.alsa-scarlett-gui.yml 

Emptying app dir 'build-dir'
Downloading sources
Starting build of vu.b4.alsa-scarlett-gui
Cache miss, checking out last cache hit
========================================================================
Building module alsa-scarlett-gui in /home/guillaume/git/alsa-scarlett-gui/.flatpak-builder/build/alsa-scarlett-gui-14
========================================================================
Running: echo "APP_VERSION=$APP_VERSION"; make -j4 install PREFIX=$FLATPAK_DEST
APP_VERSION=

fatal: not a git repository (or any parent up to mount point /run/build)

How about:

build-options:
  secret-env:
    - APP_VERSION

?

I created this test,yml:

app-id: test.test.test
runtime: org.gnome.Platform
runtime-version: "45"
sdk: org.gnome.Sdk
build-options:
  secret-env:
    - APP_VERSION
modules:
  - name: test
    buildsystem: simple
    build-commands:
      - env
    sources:
      - type: dir
        path: .

Then ran:

$ APP_VERSION=itworks flatpak-builder --force-clean build-dir ./test.yml | grep APP_VERSION
APP_VERSION=itworks

Alright, it works,
My flatpak-builder (from debian bulleyes) is outdated and don't know that option...
I tried on a test branch and combined with your Makefile change, that works!

You can add

build-options:
  secret-env:
    - APP_VERSION

Okay, done. Let's see if it works...

Seems to work for me. Thanks @gwilherm!