From 4dd4c3c6586b16a067da85421711cec34cad826c Mon Sep 17 00:00:00 2001
From: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date: Sun, 19 Nov 2023 01:36:13 +0200
Subject: [PATCH] Improved/fixed macOS support (#4153)
* Fix macOS notifications
* Change CFBundleIdentifier to match domain
* Distribute Stash.app
* Also build universal phasher binary
* Fix binary name in check_version.go
* Expose GOOS, working dir and home dir in systemStatus endpoint
* Disable setup in working directory when running Stash.app
* More Makefile improvements, remove unused scripts
* Improve READMEs and documentation
---
.github/workflows/build.yml | 29 +-
.gitignore | 1 +
Makefile | 276 ++++++++----------
README.md | 9 +-
docker/ci/x86_64/README.md | 2 +-
docker/compiler/README.md | 2 +-
docs/DEVELOPMENT.md | 33 ++-
go.mod | 2 +-
go.sum | 4 +-
.../queries/settings/metadata.graphql | 3 +
graphql/schema/types/metadata.graphql | 3 +
internal/api/check_version.go | 4 +-
internal/desktop/desktop_platform_darwin.go | 3 +-
internal/manager/manager.go | 15 +-
pkg/fsutil/dir.go | 10 +
scripts/cross-compile.sh | 55 ----
scripts/macos-bundle/Contents/Info.plist | 4 +-
scripts/upload-pull-request.sh | 38 ---
ui/v2.5/src/components/Setup/Setup.tsx | 189 +++++++-----
ui/v2.5/src/docs/en/Manual/Contributing.md | 28 +-
ui/v2.5/src/locales/en-GB.json | 16 +-
21 files changed, 345 insertions(+), 381 deletions(-)
delete mode 100755 scripts/cross-compile.sh
delete mode 100644 scripts/upload-pull-request.sh
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3927d9438..e4157e1b4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -84,13 +84,12 @@ jobs:
- name: Compile for all supported platforms
run: |
- docker exec -t build /bin/bash -c "make cross-compile-windows"
- docker exec -t build /bin/bash -c "make cross-compile-macos-intel"
- docker exec -t build /bin/bash -c "make cross-compile-macos-applesilicon"
- docker exec -t build /bin/bash -c "make cross-compile-linux"
- docker exec -t build /bin/bash -c "make cross-compile-linux-arm64v8"
- docker exec -t build /bin/bash -c "make cross-compile-linux-arm32v7"
- docker exec -t build /bin/bash -c "make cross-compile-linux-arm32v6"
+ docker exec -t build /bin/bash -c "make build-cc-windows"
+ docker exec -t build /bin/bash -c "make build-cc-macos"
+ docker exec -t build /bin/bash -c "make build-cc-linux"
+ docker exec -t build /bin/bash -c "make build-cc-linux-arm64v8"
+ docker exec -t build /bin/bash -c "make build-cc-linux-arm32v7"
+ docker exec -t build /bin/bash -c "make build-cc-linux-arm32v6"
- name: Cleanup build container
run: docker rm -f -v build
@@ -98,7 +97,7 @@ jobs:
- name: Generate checksums
run: |
git describe --tags --exclude latest_develop | tee CHECKSUMS_SHA1
- sha1sum dist/stash-* | sed 's/dist\///g' | tee -a CHECKSUMS_SHA1
+ sha1sum dist/Stash.app.zip dist/stash-* | sed 's/dist\///g' | tee -a CHECKSUMS_SHA1
echo "STASH_VERSION=$(git describe --tags --exclude latest_develop)" >> $GITHUB_ENV
echo "RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_ENV
@@ -110,13 +109,13 @@ jobs:
name: stash-win.exe
path: dist/stash-win.exe
- - name: Upload OSX binary
+ - name: Upload macOS binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/develop' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
- name: stash-macos-intel
- path: dist/stash-macos-intel
+ name: stash-macos
+ path: dist/stash-macos
- name: Upload Linux binary
# only upload binaries for pull requests
@@ -139,8 +138,8 @@ jobs:
automatic_release_tag: latest_develop
title: "${{ env.STASH_VERSION }}: Latest development build"
files: |
- dist/stash-macos-intel
- dist/stash-macos-applesilicon
+ dist/Stash.app.zip
+ dist/stash-macos
dist/stash-win.exe
dist/stash-linux
dist/stash-linux-arm64v8
@@ -157,8 +156,8 @@ jobs:
token: "${{ secrets.GITHUB_TOKEN }}"
allow_override: true
files: |
- dist/stash-macos-intel
- dist/stash-macos-applesilicon
+ dist/Stash.app.zip
+ dist/stash-macos
dist/stash-win.exe
dist/stash-linux
dist/stash-linux-arm64v8
diff --git a/.gitignore b/.gitignore
index 2a259b6ad..99d8dffed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,6 +64,7 @@ node_modules
*.db
/stash
+/Stash.app
/phasher
dist
.DS_Store
diff --git a/Makefile b/Makefile
index 7af04353f..c9fe2ffb0 100644
--- a/Makefile
+++ b/Makefile
@@ -50,29 +50,42 @@ export CGO_ENABLED := 1
release: pre-ui generate ui build-release
# targets to set various build flags
+# use combinations on the make command-line to configure a build, e.g.:
+# for a static-pie release build: `make flags-static-pie flags-release stash`
+# for a static windows debug build: `make flags-static-windows stash`
+
+# shell noop: prevents "nothing to be done" warnings
+.PHONY: flags
+flags:
+ifdef IS_WIN_SHELL
+ @@
+else
+ @:
+endif
.PHONY: flags-release
-flags-release:
+flags-release: flags
$(eval LDFLAGS += -s -w)
$(eval GO_BUILD_FLAGS += -trimpath)
.PHONY: flags-pie
-flags-pie:
+flags-pie: flags
$(eval GO_BUILD_FLAGS += -buildmode=pie)
.PHONY: flags-static
-flags-static:
+flags-static: flags
$(eval LDFLAGS += -extldflags=-static)
$(eval GO_BUILD_TAGS += sqlite_omit_load_extension osusergo netgo)
.PHONY: flags-static-pie
-flags-static-pie:
+flags-static-pie: flags
$(eval LDFLAGS += -extldflags=-static-pie)
$(eval GO_BUILD_FLAGS += -buildmode=pie)
$(eval GO_BUILD_TAGS += sqlite_omit_load_extension osusergo netgo)
+# identical to flags-static-pie, but excluding netgo, which is not needed on windows
.PHONY: flags-static-windows
-flags-static-windows:
+flags-static-windows: flags
$(eval LDFLAGS += -extldflags=-static-pie)
$(eval GO_BUILD_FLAGS += -buildmode=pie)
$(eval GO_BUILD_TAGS += sqlite_omit_load_extension osusergo)
@@ -105,166 +118,141 @@ build-flags: build-info
stash: build-flags
go build $(STASH_OUTPUT) $(BUILD_FLAGS) ./cmd/stash
-.PHONY: stash-release
-stash-release: flags-release
-stash-release: flags-pie
-stash-release: stash
-
-.PHONY: stash-release-static
-stash-release-static: flags-release
-stash-release-static: flags-static-pie
-stash-release-static: stash
-
-.PHONY: stash-release-static-windows
-stash-release-static-windows: flags-release
-stash-release-static-windows: flags-static-windows
-stash-release-static-windows: stash
-
.PHONY: phasher
phasher: build-flags
go build $(PHASHER_OUTPUT) $(BUILD_FLAGS) ./cmd/phasher
-.PHONY: phasher-release
-phasher-release: flags-release
-phasher-release: flags-pie
-phasher-release: phasher
-
-.PHONY: phasher-release-static
-phasher-release-static: flags-release
-phasher-release-static: flags-static-pie
-phasher-release-static: phasher
-
-.PHONY: phasher-release-static-windows
-phasher-release-static-windows: flags-release
-phasher-release-static-windows: flags-static-windows
-phasher-release-static-windows: phasher
-
# builds dynamically-linked debug binaries
.PHONY: build
build: stash phasher
-# builds dynamically-linked release binaries
+# builds dynamically-linked PIE release binaries
.PHONY: build-release
-build-release: stash-release phasher-release
+build-release: flags-release flags-pie build
-# builds statically-linked release binaries
-.PHONY: build-release-static
-build-release-static: stash-release-static phasher-release-static
+# compile and bundle into Stash.app
+# for when on macOS itself
+.PHONY: stash-macapp
+stash-macapp: STASH_OUTPUT := -o stash
+stash-macapp: flags-release flags-pie stash
+ rm -rf Stash.app
+ cp -R scripts/macos-bundle Stash.app
+ mkdir Stash.app/Contents/MacOS
+ cp stash Stash.app/Contents/MacOS/stash
-# build-release-static, but excluding netgo, which is not needed on windows
-.PHONY: build-release-static-windows
-build-release-static-windows: stash-release-static-windows phasher-release-static-windows
+# build-cc- targets should be run within the compiler docker container
-# cross-compile- targets should be run within the compiler docker container
-.PHONY: cross-compile-windows
-cross-compile-windows: export GOOS := windows
-cross-compile-windows: export GOARCH := amd64
-cross-compile-windows: export CC := x86_64-w64-mingw32-gcc
-cross-compile-windows: export CXX := x86_64-w64-mingw32-g++
-cross-compile-windows: STASH_OUTPUT := -o dist/stash-win.exe
-cross-compile-windows: PHASHER_OUTPUT := -o dist/phasher-win.exe
-cross-compile-windows: flags-release
-cross-compile-windows: flags-static-windows
-cross-compile-windows: build
+build-cc-windows: export GOOS := windows
+build-cc-windows: export GOARCH := amd64
+build-cc-windows: export CC := x86_64-w64-mingw32-gcc
+build-cc-windows: export CXX := x86_64-w64-mingw32-g++
+build-cc-windows: STASH_OUTPUT := -o dist/stash-win.exe
+build-cc-windows: PHASHER_OUTPUT :=-o dist/phasher-win.exe
+build-cc-windows: flags-release
+build-cc-windows: flags-static-windows
+build-cc-windows: build
-.PHONY: cross-compile-macos-intel
-cross-compile-macos-intel: export GOOS := darwin
-cross-compile-macos-intel: export GOARCH := amd64
-cross-compile-macos-intel: export CC := o64-clang
-cross-compile-macos-intel: export CXX := o64-clang++
-cross-compile-macos-intel: STASH_OUTPUT := -o dist/stash-macos-intel
-cross-compile-macos-intel: PHASHER_OUTPUT := -o dist/phasher-macos-intel
-cross-compile-macos-intel: flags-release
-# can't use static build for OSX
-cross-compile-macos-intel: flags-pie
-cross-compile-macos-intel: build
+.PHONY: build-cc-macos-intel
+build-cc-macos-intel: export GOOS := darwin
+build-cc-macos-intel: export GOARCH := amd64
+build-cc-macos-intel: export CC := o64-clang
+build-cc-macos-intel: export CXX := o64-clang++
+build-cc-macos-intel: STASH_OUTPUT := -o dist/stash-macos-intel
+build-cc-macos-intel: PHASHER_OUTPUT := -o dist/phasher-macos-intel
+build-cc-macos-intel: flags-release
+# can't use static build for macOS
+build-cc-macos-intel: flags-pie
+build-cc-macos-intel: build
-.PHONY: cross-compile-macos-applesilicon
-cross-compile-macos-applesilicon: export GOOS := darwin
-cross-compile-macos-applesilicon: export GOARCH := arm64
-cross-compile-macos-applesilicon: export CC := oa64e-clang
-cross-compile-macos-applesilicon: export CXX := oa64e-clang++
-cross-compile-macos-applesilicon: STASH_OUTPUT := -o dist/stash-macos-applesilicon
-cross-compile-macos-applesilicon: PHASHER_OUTPUT := -o dist/phasher-macos-applesilicon
-cross-compile-macos-applesilicon: flags-release
-# can't use static build for OSX
-cross-compile-macos-applesilicon: flags-pie
-cross-compile-macos-applesilicon: build
+.PHONY: build-cc-macos-arm
+build-cc-macos-arm: export GOOS := darwin
+build-cc-macos-arm: export GOARCH := arm64
+build-cc-macos-arm: export CC := oa64e-clang
+build-cc-macos-arm: export CXX := oa64e-clang++
+build-cc-macos-arm: STASH_OUTPUT := -o dist/stash-macos-arm
+build-cc-macos-arm: PHASHER_OUTPUT := -o dist/phasher-macos-arm
+build-cc-macos-arm: flags-release
+# can't use static build for macOS
+build-cc-macos-arm: flags-pie
+build-cc-macos-arm: build
+
+.PHONY: build-cc-macos
+build-cc-macos:
+ make build-cc-macos-arm
+ make build-cc-macos-intel
+
+ # Combine into universal binaries
+ lipo -create -output dist/stash-macos dist/stash-macos-intel dist/stash-macos-arm
+ rm dist/stash-macos-intel dist/stash-macos-arm
+ lipo -create -output dist/phasher-macos dist/phasher-macos-intel dist/phasher-macos-arm
+ rm dist/phasher-macos-intel dist/phasher-macos-arm
-.PHONY: cross-compile-macos
-cross-compile-macos:
- rm -rf dist/Stash.app dist/Stash-macos.zip
- make cross-compile-macos-applesilicon
- make cross-compile-macos-intel
- # Combine into one universal binary
- lipo -create -output dist/stash-macos-universal dist/stash-macos-intel dist/stash-macos-applesilicon
- rm dist/stash-macos-intel dist/stash-macos-applesilicon
# Place into bundle and zip up
+ rm -rf dist/Stash.app
cp -R scripts/macos-bundle dist/Stash.app
mkdir dist/Stash.app/Contents/MacOS
- mv dist/stash-macos-universal dist/Stash.app/Contents/MacOS/stash
- cd dist && zip -r Stash-macos.zip Stash.app && cd ..
+ cp dist/stash-macos dist/Stash.app/Contents/MacOS/stash
+ cd dist && rm -f Stash.app.zip && zip -r Stash.app.zip Stash.app
rm -rf dist/Stash.app
-.PHONY: cross-compile-freebsd
-cross-compile-freebsd: export GOOS := freebsd
-cross-compile-freebsd: export GOARCH := amd64
-cross-compile-freebsd: STASH_OUTPUT := -o dist/stash-freebsd
-cross-compile-freebsd: PHASHER_OUTPUT := -o dist/phasher-freebsd
-cross-compile-freebsd: flags-release
-cross-compile-freebsd: flags-static-pie
-cross-compile-freebsd: build
+.PHONY: build-cc-freebsd
+build-cc-freebsd: export GOOS := freebsd
+build-cc-freebsd: export GOARCH := amd64
+build-cc-freebsd: STASH_OUTPUT := -o dist/stash-freebsd
+build-cc-freebsd: PHASHER_OUTPUT := -o dist/phasher-freebsd
+build-cc-freebsd: flags-release
+build-cc-freebsd: flags-static-pie
+build-cc-freebsd: build
-.PHONY: cross-compile-linux
-cross-compile-linux: export GOOS := linux
-cross-compile-linux: export GOARCH := amd64
-cross-compile-linux: STASH_OUTPUT := -o dist/stash-linux
-cross-compile-linux: PHASHER_OUTPUT := -o dist/phasher-linux
-cross-compile-linux: flags-release
-cross-compile-linux: flags-static-pie
-cross-compile-linux: build
+.PHONY: build-cc-linux
+build-cc-linux: export GOOS := linux
+build-cc-linux: export GOARCH := amd64
+build-cc-linux: STASH_OUTPUT := -o dist/stash-linux
+build-cc-linux: PHASHER_OUTPUT := -o dist/phasher-linux
+build-cc-linux: flags-release
+build-cc-linux: flags-static-pie
+build-cc-linux: build
-.PHONY: cross-compile-linux-arm64v8
-cross-compile-linux-arm64v8: export GOOS := linux
-cross-compile-linux-arm64v8: export GOARCH := arm64
-cross-compile-linux-arm64v8: export CC := aarch64-linux-gnu-gcc
-cross-compile-linux-arm64v8: STASH_OUTPUT := -o dist/stash-linux-arm64v8
-cross-compile-linux-arm64v8: PHASHER_OUTPUT := -o dist/phasher-linux-arm64v8
-cross-compile-linux-arm64v8: flags-release
-cross-compile-linux-arm64v8: flags-static-pie
-cross-compile-linux-arm64v8: build
+.PHONY: build-cc-linux-arm64v8
+build-cc-linux-arm64v8: export GOOS := linux
+build-cc-linux-arm64v8: export GOARCH := arm64
+build-cc-linux-arm64v8: export CC := aarch64-linux-gnu-gcc
+build-cc-linux-arm64v8: STASH_OUTPUT := -o dist/stash-linux-arm64v8
+build-cc-linux-arm64v8: PHASHER_OUTPUT := -o dist/phasher-linux-arm64v8
+build-cc-linux-arm64v8: flags-release
+build-cc-linux-arm64v8: flags-static-pie
+build-cc-linux-arm64v8: build
-.PHONY: cross-compile-linux-arm32v7
-cross-compile-linux-arm32v7: export GOOS := linux
-cross-compile-linux-arm32v7: export GOARCH := arm
-cross-compile-linux-arm32v7: export GOARM := 7
-cross-compile-linux-arm32v7: export CC := arm-linux-gnueabi-gcc -march=armv7-a
-cross-compile-linux-arm32v7: STASH_OUTPUT := -o dist/stash-linux-arm32v7
-cross-compile-linux-arm32v7: PHASHER_OUTPUT := -o dist/phasher-linux-arm32v7
-cross-compile-linux-arm32v7: flags-release
-cross-compile-linux-arm32v7: flags-static
-cross-compile-linux-arm32v7: build
+.PHONY: build-cc-linux-arm32v7
+build-cc-linux-arm32v7: export GOOS := linux
+build-cc-linux-arm32v7: export GOARCH := arm
+build-cc-linux-arm32v7: export GOARM := 7
+build-cc-linux-arm32v7: export CC := arm-linux-gnueabi-gcc -march=armv7-a
+build-cc-linux-arm32v7: STASH_OUTPUT := -o dist/stash-linux-arm32v7
+build-cc-linux-arm32v7: PHASHER_OUTPUT := -o dist/phasher-linux-arm32v7
+build-cc-linux-arm32v7: flags-release
+build-cc-linux-arm32v7: flags-static
+build-cc-linux-arm32v7: build
-.PHONY: cross-compile-linux-arm32v6
-cross-compile-linux-arm32v6: export GOOS := linux
-cross-compile-linux-arm32v6: export GOARCH := arm
-cross-compile-linux-arm32v6: export GOARM := 6
-cross-compile-linux-arm32v6: export CC := arm-linux-gnueabi-gcc
-cross-compile-linux-arm32v6: STASH_OUTPUT := -o dist/stash-linux-arm32v6
-cross-compile-linux-arm32v6: PHASHER_OUTPUT := -o dist/phasher-linux-arm32v6
-cross-compile-linux-arm32v6: flags-release
-cross-compile-linux-arm32v6: flags-static
-cross-compile-linux-arm32v6: build
+.PHONY: build-cc-linux-arm32v6
+build-cc-linux-arm32v6: export GOOS := linux
+build-cc-linux-arm32v6: export GOARCH := arm
+build-cc-linux-arm32v6: export GOARM := 6
+build-cc-linux-arm32v6: export CC := arm-linux-gnueabi-gcc
+build-cc-linux-arm32v6: STASH_OUTPUT := -o dist/stash-linux-arm32v6
+build-cc-linux-arm32v6: PHASHER_OUTPUT := -o dist/phasher-linux-arm32v6
+build-cc-linux-arm32v6: flags-release
+build-cc-linux-arm32v6: flags-static
+build-cc-linux-arm32v6: build
-.PHONY: cross-compile-all
-cross-compile-all:
- make cross-compile-windows
- make cross-compile-macos-intel
- make cross-compile-macos-applesilicon
- make cross-compile-linux
- make cross-compile-linux-arm64v8
- make cross-compile-linux-arm32v7
- make cross-compile-linux-arm32v6
+.PHONY: build-cc-all
+build-cc-all:
+ make build-cc-windows
+ make build-cc-macos
+ make build-cc-linux
+ make build-cc-linux-arm64v8
+ make build-cc-linux-arm32v7
+ make build-cc-linux-arm32v6
.PHONY: touch-ui
touch-ui:
@@ -360,14 +348,6 @@ endif
ui: ui-env
cd ui/v2.5 && yarn build
-.PHONY: ui-nolegacy
-ui-nolegacy: STASH_NOLEGACY := true
-ui-nolegacy: ui
-
-.PHONY: ui-sourcemaps
-ui-sourcemaps: STASH_SOURCEMAPS := true
-ui-sourcemaps: ui
-
.PHONY: ui-start
ui-start: ui-env
cd ui/v2.5 && yarn start --host
diff --git a/README.md b/README.md
index 9cc62f9b9..897a0c016 100644
--- a/README.md
+++ b/README.md
@@ -29,8 +29,13 @@ For further information you can consult the [documentation](https://docs.stashap
[Latest Release](https://github.com/stashapp/stash/releases/latest/download/stash-win.exe)
[Development Preview](https://github.com/stashapp/stash/releases/download/latest_develop/stash-win.exe) | [Latest Release (Apple Silicon)](https://github.com/stashapp/stash/releases/latest/download/stash-macos-applesilicon)
[Development Preview (Apple Silicon)](https://github.com/stashapp/stash/releases/download/latest_develop/stash-macos-applesilicon)
[Latest Release (Intel)](https://github.com/stashapp/stash/releases/latest/download/stash-macos-intel)
[Development Preview (Intel)](https://github.com/stashapp/stash/releases/download/latest_develop/stash-macos-intel) | [Latest Release (amd64)](https://github.com/stashapp/stash/releases/latest/download/stash-linux)
[Development Preview (amd64)](https://github.com/stashapp/stash/releases/download/latest_develop/stash-linux)
[More Architectures...](https://github.com/stashapp/stash/releases/latest) | [Instructions](docker/production/README.md)
[Sample docker-compose.yml](docker/production/docker-compose.yml)
## First Run
-#### Windows Users: Security Prompt
-Running the app might present a security prompt since the binary isn't yet signed. Bypass this by clicking "more info" and then the "run anyway" button.
+
+#### Windows/macOS Users: Security Prompt
+
+On Windows or macOS, running the app might present a security prompt since the binary isn't yet signed.
+
+On Windows, bypass this by clicking "more info" and then the "run anyway" button. On macOS, Control+Click the app, click "Open", and then "Open" again.
+
#### FFMPEG
Stash requires ffmpeg. If you don't have it installed, Stash will download a copy for you. It is recommended that Linux users install `ffmpeg` from their distro's package manager.
diff --git a/docker/ci/x86_64/README.md b/docker/ci/x86_64/README.md
index e6dc0abcf..b9d2d7c55 100644
--- a/docker/ci/x86_64/README.md
+++ b/docker/ci/x86_64/README.md
@@ -1 +1 @@
-This dockerfile is used by travis to build the stash image. It must be run after cross-compiling - that is, `stash-linux` must exist in the `dist` directory. This image must be built from the `dist` directory.
\ No newline at end of file
+This Dockerfile is used by CI to build the `stashapp/stash` Docker image. It must be run after cross-compiling - that is, `stash-linux` must exist in the `dist` directory. This image must be built from the `dist` directory.
diff --git a/docker/compiler/README.md b/docker/compiler/README.md
index 6172d5bd9..6bb7d8d99 100644
--- a/docker/compiler/README.md
+++ b/docker/compiler/README.md
@@ -1,3 +1,3 @@
Modified from https://github.com/bep/dockerfiles/tree/master/ci-goreleaser
-When the dockerfile is changed, the version number should be incremented in the Makefile and the new version tag should be pushed to docker hub. The `scripts/cross-compile.sh` script should also be updated to use the new version number tag, and the github workflow files need to be updated to pull the correct image tag.
+When the Dockerfile is changed, the version number should be incremented in the Makefile and the new version tag should be pushed to Docker Hub. The GitHub workflow files also need to be updated to pull the correct image tag.
diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md
index 73a3ae313..7d021776c 100644
--- a/docs/DEVELOPMENT.md
+++ b/docs/DEVELOPMENT.md
@@ -49,7 +49,7 @@ NOTE: The `make` command in Windows will be `mingw32-make` with MinGW. For examp
- Add `--enable-libweb` to the list in `CONFIGURE_ARGS`
- If you've already built ffmpeg from ports before, you may need to also increment `REVISION`
- Run `doas make install`
- - Follow the instructions below to build a release, but replace the final step `make build-release` with `gmake flags-release stash`, to [avoid the PIE buildmode](https://github.com/golang/go/issues/59866).
+ - Follow the instructions below to build a release, but replace the final step `make build-release` with `gmake flags-release stash`, to [avoid the PIE buildmode](https://github.com/golang/go/issues/59866).
NOTE: The `make` command in OpenBSD will be `gmake`. For example, `make pre-ui` will be `gmake pre-ui`.
@@ -60,11 +60,10 @@ NOTE: The `make` command in OpenBSD will be `gmake`. For example, `make pre-ui`
* `make generate-stash-box-client` - Generate Go files for the Stash-box client code.
* `make ui` - Builds the UI. Requires `make pre-ui` to have been run.
* `make stash` - Builds the `stash` binary (make sure to build the UI as well... see below)
-* `make stash-release` - Builds a release version the `stash` binary, with debug information removed
+* `make stash-macapp` - Builds the `Stash.app` macOS app (only works when on macOS, for cross-compilation see below)
* `make phasher` - Builds the `phasher` binary
-* `make phasher-release` - Builds a release version the `phasher` binary, with debug information removed
-* `make build` - Builds both the `stash` and `phasher` binaries
-* `make build-release` - Builds release versions of both the `stash` and `phasher` binaries
+* `make build` - Builds both the `stash` and `phasher` binaries, alias for `make stash phasher`
+* `make build-release` - Builds release versions (debug information removed) of both the `stash` and `phasher` binaries, alias for `make flags-release flags-pie build`
* `make docker-build` - Locally builds and tags a complete 'stash/build' docker image
* `make docker-cuda-build` - Locally builds and tags a complete 'stash/cuda-build' docker image
* `make validate` - Runs all of the tests and checks required to submit a PR
@@ -76,6 +75,14 @@ NOTE: The `make` command in OpenBSD will be `gmake`. For example, `make pre-ui`
* `make server-clean` - Removes the `.local` directory and all of its contents
* `make ui-start` - Runs the UI in development mode. Requires a running Stash server to connect to - the server URL can be changed from the default of `http://localhost:9999` using the environment variable `VITE_APP_PLATFORM_URL`, but keep in mind that authentication cannot be used since the session authorization cookie cannot be sent cross-origin. The UI runs on port `3000` or the next available port.
+When building, you can optionally prepend `flags-*` targets to the target list in your `make` command to use different build flags:
+
+* `flags-release` (e.g. `make flags-release stash`) - Remove debug information from the binary.
+* `flags-pie` (e.g. `make flags-pie build`) - Build a PIE (Position Independent Executable) binary. This provides increased security, but it is unsupported on some systems (notably 32-bit ARM and OpenBSD).
+* `flags-static` (e.g. `make flags-static phasher`) - Build a statically linked binary (the default is a dynamically linked binary).
+* `flags-static-pie` (e.g. `make flags-static-pie stash`) - Build a statically linked PIE binary (using `flags-static` and `flags-pie` separately will not work).
+* `flags-static-windows` (e.g. `make flags-static-windows build`) - Identical to `flags-static-pie`, but does not enable the `netgo` build tag, which is not needed for static builds on Windows.
+
## Local development quickstart
1. Run `make pre-ui` to install UI dependencies
@@ -112,13 +119,19 @@ Simply run `make` or `make release`, or equivalently:
3. Run `make ui` to build the frontend
4. Run `make build-release` to build a release executable for your current platform
-## Cross compiling
+## Cross-compiling
-This project uses a modification of the [CI-GoReleaser](https://github.com/bep/dockerfiles/tree/master/ci-goreleaser) docker container to create an environment
-where the app can be cross-compiled. This process is kicked off by CI via the `scripts/cross-compile.sh` script. Run the following
-command to open a bash shell to the container to poke around:
+This project uses a modification of the [CI-GoReleaser](https://github.com/bep/dockerfiles/tree/master/ci-goreleaser) Docker container for cross-compilation, defined in `docker/compiler/Dockerfile`.
-`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t stashapp/compiler:latest /bin/bash`
+To cross-compile the app yourself:
+
+1. Run `make pre-ui`, `make generate` and `make ui` outside the container, to generate files and build the UI.
+2. Pull the latest compiler image from Docker Hub: `docker pull stashapp/compiler`
+3. Run `docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -it stashapp/compiler /bin/bash` to open a shell inside the container.
+4. From inside the container, run `make build-cc-all` to build for all platforms, or run `make build-cc-{platform}` to build for a specific platform (have a look at the `Makefile` for the list of targets).
+5. You will find the compiled binaries in `dist/`.
+
+NOTE: Since the container is run as UID 0 (root), the resulting binaries (and the `dist/` folder itself, if it had to be created) will be owned by root.
## Profiling
diff --git a/go.mod b/go.mod
index 08396131b..2eda54b1e 100644
--- a/go.mod
+++ b/go.mod
@@ -28,7 +28,7 @@ require (
github.com/jinzhu/copier v0.4.0
github.com/jmoiron/sqlx v1.3.5
github.com/json-iterator/go v1.1.12
- github.com/kermieisinthehouse/gosx-notifier v0.1.1
+ github.com/kermieisinthehouse/gosx-notifier v0.1.2
github.com/kermieisinthehouse/systray v1.2.4
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-sqlite3 v1.14.17
diff --git a/go.sum b/go.sum
index 980e939c4..6fc3b230c 100644
--- a/go.sum
+++ b/go.sum
@@ -358,8 +358,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
-github.com/kermieisinthehouse/gosx-notifier v0.1.1 h1:lVXyKsa1c1RUkckp3KayloNLoI//fUwVYye3RPSPtEw=
-github.com/kermieisinthehouse/gosx-notifier v0.1.1/go.mod h1:xyWT07azFtUOcHl96qMVvKhvKzsMcS7rKTHQyv8WTho=
+github.com/kermieisinthehouse/gosx-notifier v0.1.2 h1:KV0KBeKK2B24kIHY7iK0jgS64Q05f4oB+hUZmsPodxQ=
+github.com/kermieisinthehouse/gosx-notifier v0.1.2/go.mod h1:xyWT07azFtUOcHl96qMVvKhvKzsMcS7rKTHQyv8WTho=
github.com/kermieisinthehouse/systray v1.2.4 h1:pdH5vnl+KKjRrVCRU4g/2W1/0HVzuuJ6WXHlPPHYY6s=
github.com/kermieisinthehouse/systray v1.2.4/go.mod h1:axh6C/jNuSyC0QGtidZJURc9h+h41HNoMySoLVrhVR4=
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
diff --git a/graphql/documents/queries/settings/metadata.graphql b/graphql/documents/queries/settings/metadata.graphql
index c36c51299..2081de96e 100644
--- a/graphql/documents/queries/settings/metadata.graphql
+++ b/graphql/documents/queries/settings/metadata.graphql
@@ -5,5 +5,8 @@ query SystemStatus {
appSchema
status
configPath
+ os
+ workingDir
+ homeDir
}
}
diff --git a/graphql/schema/types/metadata.graphql b/graphql/schema/types/metadata.graphql
index 8081985a4..d1cf32393 100644
--- a/graphql/schema/types/metadata.graphql
+++ b/graphql/schema/types/metadata.graphql
@@ -303,6 +303,9 @@ type SystemStatus {
configPath: String
appSchema: Int!
status: SystemStatusEnum!
+ os: String!
+ workingDir: String!
+ homeDir: String!
}
input MigrateInput {
diff --git a/internal/api/check_version.go b/internal/api/check_version.go
index b19727ab8..6279997d7 100644
--- a/internal/api/check_version.go
+++ b/internal/api/check_version.go
@@ -26,8 +26,8 @@ const defaultSHLength int = 8 // default length of SHA short hash returned by {chunks}
,
+ fallback_path: fallbackConfigPath,
}}
/>
{chunks}
,
+ path: fallbackStashDir,
}}
/>
+ {homeDirPath}
@@ -511,18 +570,6 @@ export const Setup: React.FC = () => {
);
}
- function renderConfigLocation() {
- if (configLocation === "config.yml") {
- return <current working directory>/config.yml
;
- }
-
- if (configLocation === "") {
- return $HOME/.stash/config.yml
;
- }
-
- return {configLocation}
;
- }
-
function maybeRenderExclusions(s: GQL.StashConfig) {
if (!s.excludeImage && !s.excludeVideo) {
return;
@@ -539,19 +586,6 @@ export const Setup: React.FC = () => {
return `(excludes ${excludes.join(" and ")})`;
}
- function renderStashLibraries() {
- return (
- {s.path}
- {maybeRenderExclusions(s)}
- {config}
+ {s.path}
+ {maybeRenderExclusions(s)}
+
- {databaseFile !== ""
- ? databaseFile
- : intl.formatMessage({
- id: "setup.confirm.default_db_location",
- })}
-
+ {database}
- {generatedLocation !== ""
- ? generatedLocation
- : intl.formatMessage({
- id: "setup.confirm.default_generated_content_location",
- })}
-
+ {generated}
- {cacheLocation !== ""
- ? cacheLocation
- : intl.formatMessage({
- id: "setup.confirm.default_cache_location",
- })}
-
+ {cache}
- {storeBlobsInDatabase
- ? intl.formatMessage({
- id: "setup.confirm.blobs_use_database",
- })
- : blobsLocation !== ""
- ? blobsLocation
- : intl.formatMessage({
- id: "setup.confirm.default_blobs_location",
- })}
-
+ {blobs}