E56D feat(insights): detecting packaging method (#3841) · navidrome/navidrome@131c0c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 131c0c5

Browse files
mintsoftdeluan
andauthored
feat(insights): detecting packaging method (#3841)
* Adding environmental variable so that navidrome can detect if its running as an MSI install for insights * Renaming to be ND_PACKAGE_TYPE so we can reuse this for the .deb/.rpm stats as well * Packaged implies a bool, this is a description so it should be packaging or just package imo * wixl currently doesn't support <Environment> so I'm swapping out to a file next-door to the configuration file, we should be able to reuse this for deb/rpm as well * Using a file we should be able to add support for linux like this also * MSI should copy the package into place for us, it's not a KeyPath as older versions won't have it, so it's presence doesn't indicate the installed status of the package * OK this doesn't exist, need to find another way to do it * package to .package and moving to the datadir * fix(scanner): better log message when AutoImportPlaylists is disabled Fix #3861 Signed-off-by: Deluan <deluan@navidrome.org> * fix(scanner): support ID3v2 embedded images in WAV files Fix #3867 Signed-off-by: Deluan <deluan@navidrome.org> * feat(ui): show bitDepth in song info dialog Signed-off-by: Deluan <deluan@navidrome.org> * fix(server): don't break if the ND_CONFIGFILE does not exist Signed-off-by: Deluan <deluan@navidrome.org> * feat(docker): automatically loads a navidrome.toml file from /data, if available Signed-off-by: Deluan <deluan@navidrome.org> * feat(server): custom ArtistJoiner config (#3873) * feat(server): custom ArtistJoiner config Signed-off-by: Deluan <deluan@navidrome.org> * refactor(ui): organize ArtistLinkField, add tests Signed-off-by: Deluan <deluan@navidrome.org> * feat(ui): use display artist * feat(ui): use display artist Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org> * chore: remove some BFR-related TODOs that are not valid anymore Signed-off-by: Deluan <deluan@navidrome.org> * chore: remove more outdated TODOs Signed-off-by: Deluan <deluan@navidrome.org> * fix(scanner): elapsed time for folder processing is wrong in the logs Signed-off-by: Deluan <deluan@navidrome.org> * Should be able to reuse this mechanism with deb and rpm, I think it would be nice to know which specific one it is without guessing based on /etc/debian_version or something; but it doesn't look like that is exposed by goreleaser into an env or anything :/ * Need to reference the installed file and I think Id's don't require [] * Need to add into the root directory for this to work * That was not deliberately removed * feat: add RPM and DEB package configuration files for Navidrome Signed-off-by: Deluan <deluan@navidrome.org> * Don't need this as goreleaser will sort it out --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan Quintão <deluan@navidrome.org>
1 parent 53ff338 commit 131c0c5

File tree

7 files changed

+30
-0
lines changed

7 files changed

+30
-0
lines changed

core/metrics/insights.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"math"
88
"net/http"
9+
"os"
910
"path/filepath"
1011
"runtime"
1112
"runtime/debug"
@@ -160,6 +161,13 @@ var staticData = sync.OnceValue(func() insights.Data {
160161
data.Build.Settings, data.Build.GoVersion = buildInfo()
161162
data.OS.Containerized = consts.InContainer
162163

164+
// Install info
165+
packageFilename := filepath.Join(conf.Server.DataFolder, ".package")
166+
packageFileData, err := os.ReadFile(packageFilename)
167+
if err == nil {
168+
data.OS.Package = string(packageFileData)
169+
}
170+
163171
// OS info
164172
data.OS.Type = runtime.GOOS
165173
data.OS.Arch = runtime.GOARCH

core/metrics/insights/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Data struct {
1616
Containerized bool `json:"containerized"`
1717
Arch string `json:"arch"`
1818
NumCPU int `json:"numCPU"`
19+
Package string `json:"package,omitempty"`
1920
} `json:"os"`
2021
Mem struct {
2122
Alloc uint64 `json:"alloc"`

release/goreleaser.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ nfpms:
8383
owner: navidrome
8484
group: navidrome
8585

86+
- src: release/linux/.package.rpm # contents: "rpm"
87+
dst: /var/lib/navidrome/.package
88+
type: "config|noreplace"
89+
packager: rpm
90+
- src: release/linux/.package.deb # contents: "deb"
91+
dst: /var/lib/navidrome/.package
92+
type: "config|noreplace"
93+
packager: deb
94+
8695
scripts:
8796
preinstall: "release/linux/preinstall.sh"
8897
postinstall: "release/linux/postinstall.sh"

release/linux/.package.deb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb

release/linux/.package.rpm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rpm

release/wix/build_msi.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ cp "${DOWNLOAD_FOLDER}"/extracted_ffmpeg/${FFMPEG_FILE}/bin/ffmpeg.exe "$MSI_OUT
4949
cp "$WORKSPACE"/LICENSE "$WORKSPACE"/README.md "$MSI_OUTPUT_DIR"
5050
cp "$BINARY" "$MSI_OUTPUT_DIR"
5151

52+
# package type indicator file
53+
echo "msi" > "$MSI_OUTPUT_DIR/.package"
54+
5255
# workaround for wixl WixVariable not working to override bmp locations
5356
cp "$WORKSPACE"/release/wix/bmp/banner.bmp /usr/share/wixl-*/ext/ui/bitmaps/bannrbmp.bmp
5457
cp "$WORKSPACE"/release/wix/bmp/dialogue.bmp /usr/share/wixl-*/ext/ui/bitmaps/dlgbmp.bmp

release/wix/navidrome.wxs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969

7070
</Directory>
7171
</Directory>
72+
73+
<Directory Id="ND_DATAFOLDER" name="[ND_DATAFOLDER]">
74+
<Component Id='PackageFile' Guid='9eec0697-803c-4629-858f-20dc376c960b' Win64="$(var.Win64)">
75+
<File Id='package' Name='.package' DiskId='1' Source='.package' KeyPath='no' />
76+
</Component>
77+
</Directory>
7278
</Directory>
7379

7480
<InstallUISequence>
@@ -81,6 +87,7 @@
8187
<ComponentRef Id='Configuration'/>
8288
<ComponentRef Id='MainExecutable' />
8389
<ComponentRef Id='FFMpegExecutable' />
90+
<ComponentRef Id='PackageFile' />
8491
</Feature>
8592
</Product>
8693
</Wix>

0 commit comments

Comments
 (0)
0