Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into fix_login
  • Loading branch information
Trial97 committed Oct 1, 2024
2 parents 0af639c + fa92e6b commit b676a67
Show file tree
Hide file tree
Showing 52 changed files with 672 additions and 320 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# tabs -> spaces
bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9

# (nix) alejandra -> nixfmt
4c81d8c53d09196426568c4a31a4e752ed05397a
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ on:
APPLE_NOTARIZE_PASSWORD:
description: Password used for notarizing macOS builds
required: false
CACHIX_AUTH_TOKEN:
description: Private token for authenticating against Cachix cache
required: false
GPG_PRIVATE_KEY:
description: Private key for AppImage signing
required: false
Expand Down Expand Up @@ -631,3 +634,53 @@ jobs:
with:
bundle: "Prism Launcher.flatpak"
manifest-path: flatpak/org.prismlauncher.PrismLauncher.yml

nix:
name: Nix (${{ matrix.system }})

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
system: x86_64-linux

- os: macos-13
system: x86_64-darwin

- os: macos-14
system: aarch64-darwin

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v27

# For PRs
- name: Setup Nix Magic Cache
uses: DeterminateSystems/magic-nix-cache-action@v8

# For in-tree builds
- name: Setup Cachix
uses: cachix/cachix-action@v15
with:
name: prismlauncher
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Run flake checks
run: |
nix flake check --print-build-logs --show-trace
- name: Build debug package
if: ${{ inputs.build_type == 'Debug' }}
run: |
nix build --print-build-logs .#prismlauncher-debug
- name: Build release package
if: ${{ inputs.build_type != 'Debug' }}
run: |
nix build --print-build-logs .#prismlauncher
1 change: 1 addition & 0 deletions .github/workflows/trigger_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ jobs:
APPLE_NOTARIZE_APPLE_ID: ${{ secrets.APPLE_NOTARIZE_APPLE_ID }}
APPLE_NOTARIZE_TEAM_ID: ${{ secrets.APPLE_NOTARIZE_TEAM_ID }}
APPLE_NOTARIZE_PASSWORD: ${{ secrets.APPLE_NOTARIZE_PASSWORD }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_KEY_ID: ${{ secrets.GPG_PRIVATE_KEY_ID }}
1 change: 1 addition & 0 deletions .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
APPLE_NOTARIZE_APPLE_ID: ${{ secrets.APPLE_NOTARIZE_APPLE_ID }}
APPLE_NOTARIZE_TEAM_ID: ${{ secrets.APPLE_NOTARIZE_TEAM_ID }}
APPLE_NOTARIZE_PASSWORD: ${{ secrets.APPLE_NOTARIZE_PASSWORD }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_KEY_ID: ${{ secrets.GPG_PRIVATE_KEY_ID }}

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ endif()
set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")
set(Launcher_LOGIN_CALLBACK_URL "https://prismlauncher.org/successful-login" CACHE STRING "URL that gets opened when the user successfully logins.")
set(Launcher_FMLLIBS_BASE_URL "https://files.prismlauncher.org/fmllibs/" CACHE STRING "URL for FML Libraries.")

######## Set version numbers ########
set(Launcher_VERSION_MAJOR 9)
Expand Down Expand Up @@ -205,6 +207,7 @@ set(Launcher_BUG_TRACKER_URL "https://github.com/PrismLauncher/PrismLauncher/iss

# Translations Platform URL
set(Launcher_TRANSLATIONS_URL "https://hosted.weblate.org/projects/prismlauncher/launcher/" CACHE STRING "URL for the translations platform.")
set(Launcher_TRANSLATION_FILES_URL "https://i18n.prismlauncher.org/" CACHE STRING "URL for the translations files.")

# Matrix Space
set(Launcher_MATRIX_URL "https://prismlauncher.org/matrix" CACHE STRING "URL to the Matrix Space")
Expand Down
3 changes: 3 additions & 0 deletions buildconfig/BuildConfig.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ Config::Config()
NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@";
NEWS_OPEN_URL = "@Launcher_NEWS_OPEN_URL@";
HELP_URL = "@Launcher_HELP_URL@";
LOGIN_CALLBACK_URL = "@Launcher_LOGIN_CALLBACK_URL@";
IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@";
MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@";
FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
META_URL = "@Launcher_META_URL@";
FMLLIBS_BASE_URL = "@Launcher_FMLLIBS_BASE_URL@";

GLFW_LIBRARY_NAME = "@Launcher_GLFW_LIBRARY_NAME@";
OPENAL_LIBRARY_NAME = "@Launcher_OPENAL_LIBRARY_NAME@";

BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@";
TRANSLATIONS_URL = "@Launcher_TRANSLATIONS_URL@";
TRANSLATION_FILES_URL = "@Launcher_TRANSLATION_FILES_URL@";
MATRIX_URL = "@Launcher_MATRIX_URL@";
DISCORD_URL = "@Launcher_DISCORD_URL@";
SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@";
Expand Down
9 changes: 7 additions & 2 deletions buildconfig/BuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ class Config {
*/
QString HELP_URL;

/**
* URL that gets opened when the user succesfully logins.
*/
QString LOGIN_CALLBACK_URL;

/**
* Client ID you can get from Imgur when you register an application
*/
Expand Down Expand Up @@ -165,8 +170,8 @@ class Config {
QString RESOURCE_BASE = "https://resources.download.minecraft.net/";
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
QString FMLLIBS_BASE_URL = "https://files.prismlauncher.org/fmllibs/"; // FIXME: move into CMakeLists
QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
QString FMLLIBS_BASE_URL;
QString TRANSLATION_FILES_URL;

QString MODPACKSCH_API_BASE_URL = "https://api.modpacks.ch/";

Expand Down
25 changes: 23 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)";

nixConfig = {
extra-substituters = [ "https://cache.garnix.io" ];
extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
extra-substituters = [ "https://prismlauncher.cachix.org" ];
extra-trusted-public-keys = [
"prismlauncher.cachix.org-1:9/n/FGyABA2jLUVfY+DEp4hKds/rwO+SCOtbOkDzd+c="
];
};

inputs = {
Expand Down Expand Up @@ -118,5 +120,24 @@
# Only output them if they're available on the current system
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
);

# We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems (
system:
let
prismPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system};
in
{
prismlauncher-debug = prismPackages.prismlauncher.override {
prismlauncher-unwrapped = legacyPackages.prismlauncher-unwrapped-debug;
};

prismlauncher-unwrapped-debug = prismPackages.prismlauncher-unwrapped.overrideAttrs {
cmakeBuildType = "Debug";
dontStrip = true;
};
}
);
};
}
10 changes: 0 additions & 10 deletions garnix.yaml

This file was deleted.

13 changes: 11 additions & 2 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,9 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// FTBApp instances
m_settings->registerSetting("FTBAppInstancesPath", "");

// Custom Technic Client ID
m_settings->registerSetting("TechnicClientID", "");

// Init page provider
{
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
Expand Down Expand Up @@ -1022,7 +1025,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
}

// notify user if /tmp is mounted with `noexec` (#1693)
{
QString jvmArgs = m_settings->get("JvmArgs").toString();
if (jvmArgs.indexOf("java.io.tmpdir") == -1) { /* java.io.tmpdir is a valid workaround, so don't annoy */
bool is_tmp_noexec = false;

#if defined(Q_OS_LINUX)
Expand All @@ -1042,7 +1046,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
if (is_tmp_noexec) {
auto infoMsg =
tr("Your /tmp directory is currently mounted with the 'noexec' flag enabled.\n"
"Some versions of Minecraft may not launch.\n");
"Some versions of Minecraft may not launch.\n"
"\n"
"You may solve this issue by remounting /tmp as 'exec' or setting "
"the java.io.tmpdir JVM argument to a writeable directory in a "
"filesystem where the 'exec' flag is set (e.g., /home/user/.local/tmp)\n");
auto msgBox = new QMessageBox(QMessageBox::Information, tr("Incompatible system configuration"), infoMsg, QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
Expand Down Expand Up @@ -1870,6 +1878,7 @@ QUrl Application::normalizeImportUrl(QString const& url)
return QUrl::fromUserInput(url);
}
}

const QString Application::javaPath()
{
return m_settings->get("JavaDir").toString();
Expand Down
2 changes: 2 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ set(JAVA_SOURCES
java/download/ArchiveDownloadTask.h
java/download/ManifestDownloadTask.cpp
java/download/ManifestDownloadTask.h
java/download/SymlinkTask.cpp
java/download/SymlinkTask.h

ui/java/InstallJavaDialog.h
ui/java/InstallJavaDialog.cpp
Expand Down
6 changes: 5 additions & 1 deletion launcher/InstanceCopyTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ void InstanceCopyTask::copyFinished()
allowed_symlinks_file
.filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.

FS::write(allowed_symlinks_file.filePath(), allowed_symlinks);
try {
FS::write(allowed_symlinks_file.filePath(), allowed_symlinks);
} catch (const FS::FileSystemException& e) {
qCritical() << "Failed to write symlink :" << e.cause();
}
}

emitSucceeded();
Expand Down
1 change: 1 addition & 0 deletions launcher/LaunchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <QLineEdit>
#include <QList>
#include <QPushButton>
#include <QRegularExpression>
#include <QStringList>

#include "BuildConfig.h"
Expand Down
4 changes: 2 additions & 2 deletions launcher/VersionProxyModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ QVariant VersionProxyModel::headerData(int section, Qt::Orientation orientation,
case Path:
return tr("Filesystem path to this version");
case JavaName:
return tr("The alternative name of the java version");
return tr("The alternative name of the Java version");
case JavaMajor:
return tr("The java major version");
return tr("The Java major version");
case Time:
return tr("Release date of this version");
}
Expand Down
4 changes: 2 additions & 2 deletions launcher/java/download/ArchiveDownloadTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ArchiveDownloadTask::executeTask()

void ArchiveDownloadTask::extractJava(QString input)
{
setStatus(tr("Extracting java"));
setStatus(tr("Extracting Java"));
if (input.endsWith("tar")) {
setStatus(tr("Extracting Java (Progress is not reported for tar archives)"));
QFile in(input);
Expand Down Expand Up @@ -95,7 +95,7 @@ void ArchiveDownloadTask::extractJava(QString input)
}
auto files = zip->getFileNameList();
if (files.isEmpty()) {
emitFailed(tr("No files were found in the supplied zip file,"));
emitFailed(tr("No files were found in the supplied zip file."));
return;
}
m_task = makeShared<MMCZip::ExtractZipTask>(zip, m_final_path, files[0]);
Expand Down
81 changes: 81 additions & 0 deletions launcher/java/download/SymlinkTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2023-2024 Trial97 <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "java/download/SymlinkTask.h"
#include <QFileInfo>

#include "FileSystem.h"

namespace Java {
SymlinkTask::SymlinkTask(QString final_path) : m_path(final_path) {}

QString findBinPath(QString root, QString pattern)
{
auto path = FS::PathCombine(root, pattern);
if (QFileInfo::exists(path)) {
return path;
}

auto entries = QDir(root).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
for (auto& entry : entries) {
path = FS::PathCombine(entry.absoluteFilePath(), pattern);
if (QFileInfo::exists(path)) {
return path;
}
}

return {};
}

void SymlinkTask::executeTask()
{
setStatus(tr("Checking for Java binary path"));
const auto binPath = FS::PathCombine("bin", "java");
const auto wantedPath = FS::PathCombine(m_path, binPath);
if (QFileInfo::exists(wantedPath)) {
emitSucceeded();
return;
}

setStatus(tr("Searching for Java binary path"));
const auto contentsPartialPath = FS::PathCombine("Contents", "Home", binPath);
const auto relativePathToBin = findBinPath(m_path, contentsPartialPath);
if (relativePathToBin.isEmpty()) {
emitFailed(tr("Failed to find Java binary path"));
return;
}
const auto folderToLink = relativePathToBin.chopped(binPath.length());

setStatus(tr("Collecting folders to symlink"));
auto entries = QDir(folderToLink).entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries);
QList<FS::LinkPair> files;
setProgress(0, entries.length());
for (auto& entry : entries) {
files.append({ entry.absoluteFilePath(), FS::PathCombine(m_path, entry.fileName()) });
}

setStatus(tr("Symlinking Java binary path"));
FS::create_link folderLink(files);
connect(&folderLink, &FS::create_link::fileLinked, [this](QString src, QString dst) { setProgress(m_progress + 1, m_progressTotal); });
if (!folderLink()) {
emitFailed(folderLink.getOSError().message().c_str());
} else {
emitSucceeded();
}
}

} // namespace Java
Loading

0 comments on commit b676a67

Please sign in to comment.