Open XOmniverse opened 6 years ago
First time contributor. Would this be okay to work on?
Hi @fish-dango,
We'd love it if a someone wanted to contribute a package. Though we are hoping that a contributor who is a Flatpak user with some existing domain knowledge can step up to do so. Our team does not currently have any Flatpak users, so we would not be able to help guide a contributor new to Flatpak since we are too!
I've done the initial work on this and it runs.. I've yet to test it but have spent enough hours in front of my PC for today.
app-id: com.digitalocean.doctl
command: doctl
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.golang
cleanup:
- /include
- /lib/pkgconfig
- /lib/*.a
- /lib/*.la
- /share/man
finish-args:
- --device=dri
- --filesystem=host
- --share=ipc
- --share=network
modules:
- name: doctl
buildsystem: simple
build-options:
prefix: /usr/lib/sdk/golang
prepend-path: /usr/lib/sdk/golang/bin
build-commands:
- GO111MODULE=on CGO_ENABLED=0 go build -ldflags "${ldFlags}" -mod=vendor -o doctl cmd/doctl/main.go
- install -Dm 755 doctl ${FLATPAK_DEST}/bin/doctl
sources:
- type: archive
url: https://github.com/digitalocean/doctl/archive/refs/tags/v1.65.0.tar.gz
sha256: b2ab4f123813ee3fdcc750b7c8f7bd9764dfa1647c54514413940449ef78cab5
Feel free to comment on this, make suggestions, alterations etc.
Unsure why it doesn't report the correct version, something to look into..
flatpak run com.digitalocean.doctl version
doctl version 0.0.0-dev
release 1.65.0 is available, check it out!
I assume it has to do with this (where I stole other bits of code from): https://github.com/digitalocean/doctl/blob/main/snap/snapcraft.yaml#L35
Hey @Justinzobel,
The doctl version is set using LDFLAGs at compile time. scripts/version.sh
just attempts to detect the version by looking at git tags. Looks like this builds from the released tarball. So that probably won't work. Does flatpak has any built-in way of detecting the version from the downloaded file name?
You could hard-code it with something like:
build-commands:
- ldFlags="-X github.com/digitalocean/doctl.Major=1"
- ldFlags="${ldFlags} -X github.com/digitalocean/doctl.Minor=65"
- ldFlags="${ldFlags} -X github.com/digitalocean/doctl.Patch=0"
- GO111MODULE=on CGO_ENABLED=0 go build -ldflags "${ldFlags}" -mod=vendor -o doctl cmd/doctl/main.go
- install -Dm 755 doctl ${FLATPAK_DEST}/bin/doctl
Thanks for working on this!
Thank you @andrewsomething, I used your snippet and then tinkered a bit and got it to display 1.65.0 but it appends -dev to it:
doctl version 1.65.0-dev
release 1.65.0 is available, check it out!
I looked at the snap and found -X github.com/digitalocean/doctl.Label=release
and that appended it ith -release
and doesn't show the update available string.
Have tested it and got it to auth and list my droplets. Also tested --context for alternate teams I'm a part of.
However, since flatpak isn't quite 100% for command-line applications users will still need to run it using flatpak run com.digitalocean.com
however if you're already working from a Terminal that much you are likely familiar with aliases and I just created alias doctl='flatpak run com.digitalocean.doctl
and it works fine.
Andrew are you happy for me to submit the finished product to Flathub or would you prefer it go under the management of DO? I'm happy to do either. Managing updates shouldn't be hard as I can subscribe to the releases on Github.
Full flatpak manifest for anyone's use:
app-id: com.digitalocean.doctl
command: doctl
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.golang
cleanup:
- /include
- /lib/pkgconfig
- /lib/*.a
- /lib/*.la
- /share/man
finish-args:
- --device=dri
- --filesystem=host
- --share=ipc
- --share=network
modules:
- name: doctl
buildsystem: simple
build-options:
prefix: /usr/lib/sdk/golang
prepend-path: /usr/lib/sdk/golang/bin
build-commands:
- GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-X github.com/digitalocean/doctl.Label=release -X github.com/digitalocean/doctl.Major=1 -X github.com/digitalocean/doctl.Minor=65 -X github.com/digitalocean/doctl.Patch=0" -mod=vendor -o doctl cmd/doctl/main.go
- install -Dm 755 doctl ${FLATPAK_DEST}/bin/doctl
sources:
- type: archive
url: https://github.com/digitalocean/doctl/archive/refs/tags/v1.65.0.tar.gz
sha256: b2ab4f123813ee3fdcc750b7c8f7bd9764dfa1647c54514413940449ef78cab5
To build and install:
flatpak-builder --force-clean --delete-build-dirs --arch=x86_64 --ccache --sandbox --user --install-deps-from=flathub --repo=staging-repo/ app com.digitalocean.doctl.yml
flatpak build-bundle staging-repo/ com.digitalocean.doctl.flatpak com.digitalocean.doctl
flatpak --user install -y com.digitalocean.doctl.flatpak
Still no movement on this? I created a manifest two years ago. I'm happy to help maintain this if you'll allow me to submit it to Flathub?
I'm coming across my need for doctl as a Flatpak again and searched for it because my brain is horrible at remembering things and came across this... Any chance we can get permission to submit @andrewsomething?
app-id: com.digitalocean.doctl
command: doctl
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.golang
cleanup:
- /include
- /lib/pkgconfig
- /lib/*.a
- /lib/*.la
- /share/man
finish-args:
- --device=dri
- --filesystem=host
- --share=ipc
- --share=network
modules:
- name: doctl
buildsystem: simple
build-options:
prefix: /usr/lib/sdk/golang
prepend-path: /usr/lib/sdk/golang/bin
build-commands:
- GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-X github.com/digitalocean/doctl.Label=release -X github.com/digitalocean/doctl.Major=1 -X github.com/digitalocean/doctl.Minor=65 -X github.com/digitalocean/doctl.Patch=0" -mod=vendor -o doctl cmd/doctl/main.go
- install -Dm 755 doctl ${FLATPAK_DEST}/bin/doctl
sources:
- type: archive
url: https://github.com/digitalocean/doctl/archive/refs/tags/v1.111.0.tar.gz
sha256: 8bbb6c632f15338f2bd38124e6ee479bd39cee0779570762f776779db0132130
Updated the runtime and doctl version to the latest, haven't thoroughly tested it yet though.
Since Flatpak is more or less the native app container solution on Fedora, it would be nice if doctl was available as a flatpak so that Fedora users don't have to have both flatpak and snap installed on their system in order to install/update doctl via a package manager.