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 CFBundleTypeIconFile icon.icns CFBundleIdentifier - org.stashapp.stash + cc.stashapp.stash NSHighResolutionCapable True LSUIElement 1 - \ No newline at end of file + diff --git a/scripts/upload-pull-request.sh b/scripts/upload-pull-request.sh deleted file mode 100644 index 358880c76..000000000 --- a/scripts/upload-pull-request.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# assumes cross-compile.sh has already been run successfully -uploadFile() -{ - FILE=$1 - BASENAME="$(basename "${FILE}")" - - # get available server from gofile api - serverApi=$(curl -m 15 https://apiv2.gofile.io/getServer) - resp=$(echo "$serverApi" | cut -d "\"" -f 4) - - # if no server is available abort - if [ $resp != "ok" ] ; then - echo "Upload of $BASENAME failed! Server not available." - echo - return - fi - server=$(echo "$serverApi" | cut -d "," -f 2 | cut -d "\"" -f 6) - - # abort if it takes more than two minutes to upload - uploadedTo=$(curl -m 120 -F "email=stash@stashapp.cc" -F "file=@$FILE" "https://$server.gofile.io/uploadFile") - resp=$(echo "$uploadedTo" | cut -d "\"" -f 4) - if [ $resp = "ok" ] ; then - URL=$(echo "$uploadedTo"|cut -d "," -f 2 | cut -d "\"" -f 6) - echo "$BASENAME uploaded to url: \"https://gofile.io/d/$URL\"" - fi - # print an extra newline - echo - -} - -uploadFile "dist/stash-osx" -uploadFile "dist/stash-win.exe" -uploadFile "dist/stash-linux" - -echo "SHA1 Checksums" -cat CHECKSUMS_SHA1 | grep -v '\-pi\|\-arm' diff --git a/ui/v2.5/src/components/Setup/Setup.tsx b/ui/v2.5/src/components/Setup/Setup.tsx index 7774b2452..f6462427b 100644 --- a/ui/v2.5/src/components/Setup/Setup.tsx +++ b/ui/v2.5/src/components/Setup/Setup.tsx @@ -54,12 +54,32 @@ export const Setup: React.FC = () => { const [showBlobsDialog, setShowBlobsDialog] = useState(false); const { data: systemStatus, loading: statusLoading } = useSystemStatus(); + const status = systemStatus?.systemStatus; + + const windows = status?.os === "windows"; + const pathSep = windows ? "\\" : "/"; + const homeDir = windows ? "%USERPROFILE%" : "$HOME"; + const pwd = windows ? "%CD%" : "$PWD"; + + function pathJoin(...paths: string[]) { + return paths.join(pathSep); + } + + const workingDir = status?.workingDir ?? "."; + + // When running Stash.app, the working directory is (usually) set to /. + // Assume that the user doesn't want to set up in / (it's usually mounted read-only anyway), + // so in this situation disallow setting up in the working directory. + const macApp = status?.os === "darwin" && workingDir === "/"; + + const fallbackStashDir = pathJoin(homeDir, ".stash"); + const fallbackConfigPath = pathJoin(fallbackStashDir, "config.yml"); useEffect(() => { - if (systemStatus?.systemStatus.configPath) { - setConfigLocation(systemStatus.systemStatus.configPath); + if (status?.configPath) { + setConfigLocation(status.configPath); } - }, [systemStatus]); + }, [status?.configPath]); useEffect(() => { if (configuration) { @@ -181,6 +201,8 @@ export const Setup: React.FC = () => { } function renderWelcome() { + const homeDirPath = pathJoin(status?.homeDir ?? homeDir, ".stash"); + return ( <>
@@ -195,6 +217,7 @@ export const Setup: React.FC = () => { id="setup.welcome.config_path_logic_explained" values={{ code: (chunks: string) => {chunks}, + fallback_path: fallbackConfigPath, }} />

@@ -225,14 +248,50 @@ export const Setup: React.FC = () => { id="setup.welcome.in_current_stash_directory" values={{ code: (chunks: string) => {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 ( - - ); - } - async function onSave() { try { setLoading(true); @@ -582,6 +616,42 @@ export const Setup: React.FC = () => { } function renderConfirm() { + let cfgPath = ""; + let config = configLocation; + if (configLocation === "config.yml") { + cfgPath = pwd; + config = pathJoin(cfgPath, "config.yml"); + } else if (configLocation === "") { + cfgPath = fallbackStashDir; + config = pathJoin(cfgPath, "config.yml"); + } + + let database = databaseFile; + if (database === "") { + database = pathJoin(cfgPath, "stash-go.sqlite"); + } + + let generated = generatedLocation; + if (generated === "") { + generated = pathJoin(cfgPath, "generated"); + } + + let cache = cacheLocation; + if (cache === "") { + cache = pathJoin(cfgPath, "cache"); + } + + let blobs; + if (storeBlobsInDatabase) { + blobs = intl.formatMessage({ + id: "setup.confirm.blobs_use_database", + }); + } else if (blobsLocation !== "") { + blobs = blobsLocation; + } else { + blobs = pathJoin(cfgPath, "blobs"); + } + return ( <>
@@ -595,26 +665,31 @@ export const Setup: React.FC = () => {
-
{renderConfigLocation()}
+
+ {config} +
-
{renderStashLibraries()}
+
+
    + {stashes.map((s) => ( +
  • + {s.path} + {maybeRenderExclusions(s)} +
  • + ))} +
+
- - {databaseFile !== "" - ? databaseFile - : intl.formatMessage({ - id: "setup.confirm.default_db_location", - })} - + {database}
@@ -622,13 +697,7 @@ export const Setup: React.FC = () => {
- - {generatedLocation !== "" - ? generatedLocation - : intl.formatMessage({ - id: "setup.confirm.default_generated_content_location", - })} - + {generated}
@@ -636,29 +705,15 @@ export const Setup: React.FC = () => {
- - {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}
@@ -803,18 +858,14 @@ export const Setup: React.FC = () => { return ; } - if ( - step === 0 && - systemStatus && - systemStatus.systemStatus.status !== GQL.SystemStatusEnum.Setup - ) { + if (step === 0 && status && status.status !== GQL.SystemStatusEnum.Setup) { // redirect to main page history.push("/"); return ; } const welcomeStep = - systemStatus && systemStatus.systemStatus.configPath !== "" + status && status.configPath !== "" ? renderWelcomeSpecificConfig : renderWelcome; const steps = [welcomeStep, renderSetPaths, renderConfirm, renderFinish]; diff --git a/ui/v2.5/src/docs/en/Manual/Contributing.md b/ui/v2.5/src/docs/en/Manual/Contributing.md index 885253a0c..9e55dbd6d 100644 --- a/ui/v2.5/src/docs/en/Manual/Contributing.md +++ b/ui/v2.5/src/docs/en/Manual/Contributing.md @@ -6,41 +6,23 @@ Financial contributions are welcomed and are accepted using [Open Collective](ht ## Development-related -The Stash backend is written in golang with a sqlite database. The UI is written in react. Bug fixes, improvements and new features are welcomed. Please see the [README.md](https://github.com/stashapp/stash/blob/develop/docs/DEVELOPMENT.md) file for details on how to get started. Assistance can be provided via our [Discord](https://discord.gg/2TsNFKt). +The Stash backend is written in Go, using a SQLite database. The UI is written in Typescript, using React. Bug fixes, improvements and new features are welcomed. Please see the [DEVELOPMENT.md](https://github.com/stashapp/stash/blob/develop/docs/DEVELOPMENT.md) file for details on how to get started. Assistance is available via our [Discord](https://discord.gg/2TsNFKt). ## Documentation -Efforts to improve documentation in stash helps new users and reduces the amount of questions we have to field in Discord. Contributions to documentation are welcomed. While submitting documentation changes via git pull requests is ideal, we will gladly accept submissions via [github issues](https://github.com/stashapp/stash/issues) or on [Discord](https://discord.gg/2TsNFKt). +Efforts to improve documentation in Stash helps new users and reduces the number of questions we have to field in Discord. Contributions to documentation are welcomed. While submitting documentation changes via GitHub pull requests is ideal, we will gladly accept submissions via [GitHub issues](https://github.com/stashapp/stash/issues) or on [Discord](https://discord.gg/2TsNFKt). For those with web page experience, we also welcome contributions to our [website](https://stashapp.cc/) (which as of writing is very undeveloped). ## Testing features, improvements and bug fixes -Testing is currently covered by a very small group, so new testers are welcomed. Being able to build stash locally is ideal, but custom binaries for pull requests are available by navigating to the `continuous-integration/travis-ci/pr` travis check details. +Testing is currently covered by a very small group, so new testers are welcomed. Being able to build Stash locally is ideal, but binaries for pull requests are also available. -The link to the custom binary for each platform can be found at the end of the build log, and looks like the following: -``` -$ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/upload-pull-request.sh; fi - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed -100 43.1M 100 35 100 43.1M 3 3812k 0:00:11 0:00:11 --:--:-- 5576k -stash-osx uploaded to url: https://transfer.sh/.../stash-osx - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed -100 60.7M 100 39 100 60.7M 3 5391k 0:00:13 0:00:11 0:00:02 7350k -stash-win.exe uploaded to url: https://transfer.sh/.../stash-win.exe - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed -100 44.6M 100 37 100 44.6M 2 3648k 0:00:18 0:00:12 0:00:06 7504k -stash-linux uploaded to url: https://transfer.sh/.../stash-linux - -``` -The `if` line will need to be expanded to see the details. +First, you will need to be signed in to GitHub. Find and open the relevant pull request, and then click on the `Checks` tab. On the right, there should be a button titled `Artifacts` - click that, and you should get a dropdown with links to download binaries built from that pull request for Linux, Windows and macOS. ## Submitting and contributing to bug reports, improvements and new features -We welcome contributions for future improvements and features, and bug reports help everyone. These can all be found in the [github issues](https://github.com/stashapp/stash/issues). - +We welcome ideas for future improvements and features, and bug reports help everyone. These can all be found on [GitHub](https://github.com/stashapp/stash/issues). ## Providing support diff --git a/ui/v2.5/src/locales/en-GB.json b/ui/v2.5/src/locales/en-GB.json index 073ce9043..29828bd5c 100644 --- a/ui/v2.5/src/locales/en-GB.json +++ b/ui/v2.5/src/locales/en-GB.json @@ -1162,14 +1162,10 @@ "confirm": { "almost_ready": "We're almost ready to complete the configuration. Please confirm the following settings. You can click back to change anything incorrect. If everything looks good, click Confirm to create your system.", "blobs_directory": "Binary data directory", - "blobs_use_database": "", + "blobs_use_database": "", "cache_directory": "Cache directory", "configuration_file_location": "Configuration file location:", "database_file_path": "Database file path", - "default_blobs_location": "/blobs", - "default_cache_location": "/cache", - "default_db_location": "/stash-go.sqlite", - "default_generated_content_location": "/generated", "generated_directory": "Generated directory", "nearly_there": "Nearly there!", "stash_library_directories": "Stash library directories" @@ -1237,10 +1233,12 @@ "your_system_has_been_created": "Success! Your system has been created!" }, "welcome": { - "config_path_logic_explained": "Stash tries to find its configuration file (config.yml) from the current working directory first, and if it does not find it there, it falls back to $HOME/.stash/config.yml (on Windows, this will be %USERPROFILE%\\.stash\\config.yml). You can also make Stash read from a specific configuration file by running it with the -c '' or --config '' options.", - "in_current_stash_directory": "In the $HOME/.stash directory", - "in_the_current_working_directory": "In the current working directory", - "next_step": "With all of that out of the way, if you're ready to proceed with setting up a new system, choose where you'd like to store your configuration file and click Next.", + "config_path_logic_explained": "Stash tries to find its configuration file (config.yml) from the current working directory first, and if it does not find it there, it falls back to {fallback_path}. You can also make Stash read from a specific configuration file by running it with the -c '' or --config '' options.", + "in_current_stash_directory": "In the {path} directory:", + "in_the_current_working_directory": "In {path}, the working directory, currently:", + "in_the_current_working_directory_disabled": "In {path}, the working directory:", + "in_the_current_working_directory_disabled_macos": "Unsupported when running Stash.app,

run stash-macos to set up in the working directory", + "next_step": "With all of that out of the way, if you're ready to proceed with setting up a new system, please choose where you'd like to store your configuration file.", "store_stash_config": "Where do you want to store your Stash configuration?", "unable_to_locate_config": "If you're reading this, then Stash couldn't find an existing configuration. This wizard will guide you through the process of setting up a new configuration.", "unexpected_explained": "If you're getting this screen unexpectedly, please try restarting Stash in the correct working directory or with the -c flag."