Skip to content

Commit

Permalink
Remove AppImage logic and build system (spacedriveapp#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff authored May 4, 2024
1 parent 2d78ede commit 4447820
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 464 deletions.
17 changes: 6 additions & 11 deletions .github/actions/publish-artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type OS = 'darwin' | 'windows' | 'linux';
type Arch = 'x64' | 'arm64';
type TargetConfig = { bundle: string; ext: string };
type BuildTarget = {
updater: { bundle: string; bundleExt: string; archiveExt: string };
updater: false | { bundle: string; bundleExt: string; archiveExt: string };
standalone: Array<TargetConfig>;
};

Expand All @@ -29,15 +29,8 @@ const OS_TARGETS = {
standalone: [{ ext: 'msi', bundle: 'msi' }]
},
linux: {
updater: {
bundle: 'appimage',
bundleExt: 'AppImage',
archiveExt: 'tar.gz'
},
standalone: [
{ ext: 'deb', bundle: 'deb' },
{ ext: 'AppImage', bundle: 'appimage' }
]
updater: false,
standalone: [{ ext: 'deb', bundle: 'deb' }]
}
} satisfies Record<OS, BuildTarget>;

Expand All @@ -57,7 +50,9 @@ async function globFiles(pattern: string) {
return await globber.glob();
}

async function uploadUpdater({ bundle, bundleExt, archiveExt }: BuildTarget['updater']) {
async function uploadUpdater(updater: BuildTarget['updater']) {
if (!updater) return;
const { bundle, bundleExt, archiveExt } = updater;
const fullExt = `${bundleExt}.${archiveExt}`;
const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${fullExt}*`);

Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,6 @@ jobs:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

- name: Build AppImage in Docker
if: ${{ runner.os == 'Linux' && ( matrix.settings.target == 'x86_64-unknown-linux-gnu' || matrix.settings.target == 'aarch64-unknown-linux-gnu' ) }}
run: |
set -euxo pipefail
docker run --rm -v $(pwd):/srv -e 'CI=true' -e 'TARGET=${{ matrix.settings.target }}' -w /srv debian:bookworm scripts/appimage/build_appimage.sh
cd 'target/${{ matrix.settings.target }}/release/bundle/appimage'
sudo chown "$(id -u):$(id -g)" -R .
tar -czf Updater.AppImage.tar.gz *.AppImage
pnpm tauri signer sign -k '${{ secrets.TAURI_PRIVATE_KEY }}' -p '${{ secrets.TAURI_KEY_PASSWORD }}' "$(pwd)/Updater.AppImage.tar.gz"
- name: Publish Artifacts
uses: ./.github/actions/publish-artifacts
with:
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ To run the mobile app:
- `xcrun simctl launch --console booted com.spacedrive.app` allows you to view the console output of the iOS app from `tracing`. However, the application must be built in `debug` mode for this.
- `pnpm mobile start` (runs the metro bundler only)

##### AppImage

Specific instructions on how to build an AppImage release are located [here](scripts/appimage/README.md)

### Pull Request

Once you have finished making your changes, create a pull request (PR) to submit them.
Expand Down
25 changes: 0 additions & 25 deletions apps/desktop/crates/linux/src/app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,6 @@ thread_local! {
// )).unwrap_or_default();

let ctx = AppLaunchContext::default();

if let Some(appdir) = std::env::var_os("APPDIR").map(PathBuf::from) {
// Remove AppImage paths from environment variables to avoid external applications attempting to use the AppImage's libraries
// https://github.com/AppImage/AppImageKit/blob/701b711f42250584b65a88f6427006b1d160164d/src/AppRun.c#L168-L194
ctx.unsetenv("PYTHONHOME");
ctx.unsetenv("GTK_DATA_PREFIX");
ctx.unsetenv("GTK_THEME");
ctx.unsetenv("GDK_BACKEND");
ctx.unsetenv("GTK_EXE_PREFIX");
ctx.unsetenv("GTK_IM_MODULE_FILE");
ctx.unsetenv("GDK_PIXBUF_MODULE_FILE");

remove_prefix_from_env_in_ctx(&ctx, "PATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "LD_LIBRARY_PATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "PYTHONPATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "XDG_DATA_DIRS", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "PERLLIB", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "GSETTINGS_SCHEMA_DIR", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "QT_PLUGIN_PATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "GST_PLUGIN_SYSTEM_PATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "GST_PLUGIN_SYSTEM_PATH_1_0", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "GTK_PATH", &appdir);
remove_prefix_from_env_in_ctx(&ctx, "GIO_EXTRA_MODULES", &appdir);
}

ctx
}
}
Expand Down
67 changes: 1 addition & 66 deletions apps/desktop/crates/linux/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
collections::HashSet,
env,
ffi::{CStr, OsStr, OsString},
io, mem,
mem,
os::unix::ffi::OsStrExt,
path::{Path, PathBuf},
ptr,
Expand Down Expand Up @@ -191,56 +191,6 @@ pub fn normalize_environment() {
],
)
.expect("PATH must be successfully normalized");

if let Ok(appdir) = get_appdir() {
println!("Running from APPIMAGE");

// Workaround for https://github.com/AppImageCrafters/appimage-builder/issues/175
env::set_current_dir(appdir.join({
let appimage_libc_version = version(
std::env::var("APPDIR_LIBC_VERSION")
.expect("AppImage Libc version must be set")
.as_str(),
);

let system_lic_version = version({
#[cfg(target_env = "gnu")]
{
use libc::gnu_get_libc_version;

let ptr = unsafe { gnu_get_libc_version() };
if ptr.is_null() {
panic!("Couldn't read glic version");
}

unsafe { CStr::from_ptr(ptr) }
.to_str()
.expect("Couldn't read glic version")
}
#[cfg(not(target_env = "gnu"))]
{
// Use the same version as gcompat
// https://git.adelielinux.org/adelie/gcompat/-/blob/current/libgcompat/version.c
std::env::var("GLIBC_FAKE_VERSION").unwrap_or_else(|_| "2.8".to_string())
}
});

if system_lic_version < appimage_libc_version {
"runtime/compat"
} else {
"runtime/default"
}
}))
.expect("Failed to set current directory to $APPDIR");

// Bubblewrap does not work from inside appimage
env::set_var("WEBKIT_FORCE_SANDBOX", "0");
env::set_var("WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS", "1");

// FIX-ME: This is required because appimage-builder generates a broken GstRegistry, which breaks video playback
env::remove_var("GST_REGISTRY");
env::remove_var("GST_REGISTRY_UPDATE");
}
}

pub(crate) fn remove_prefix_from_pathlist(
Expand Down Expand Up @@ -271,21 +221,6 @@ pub fn is_snap() -> bool {
false
}

fn get_appdir() -> io::Result<PathBuf> {
if let Some(appdir) = std::env::var_os("APPDIR").map(PathBuf::from) {
if appdir.is_absolute() && appdir.is_dir() {
return Ok(appdir);
}
}

Err(io::Error::new(io::ErrorKind::NotFound, "AppDir not found"))
}

// Check if appimage by looking if APPDIR is set and is a valid directory
pub fn is_appimage() -> bool {
get_appdir().is_ok()
}

// Check if flatpak by looking if FLATPAK_ID is set and not empty and that the .flatpak-info file exists
pub fn is_flatpak() -> bool {
if let Some(flatpak_id) = std::env::var_os("FLATPAK_ID") {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/crates/linux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mod app_info;
mod env;

pub use app_info::{list_apps_associated_with_ext, open_file_path, open_files_path_with};
pub use env::{get_current_user_home, is_appimage, is_flatpak, is_snap, normalize_environment};
pub use env::{get_current_user_home, is_flatpak, is_snap, normalize_environment};
15 changes: 0 additions & 15 deletions apps/desktop/src-tauri/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,6 @@ pub async fn open_ephemeral_file_with(paths_and_urls: Vec<PathAndUrl>) -> Result

fn inner_reveal_paths(paths: impl Iterator<Item = PathBuf>) {
for path in paths {
#[cfg(target_os = "linux")]
if sd_desktop_linux::is_appimage() {
// This is a workaround for the app, when package inside an AppImage, crashing when using opener::reveal.
if let Err(e) = sd_desktop_linux::open_file_path(if path.is_file() {
path.parent().unwrap_or(&path)
} else {
&path
}) {
error!("Failed to open logs dir: {e:#?}");
}
} else if let Err(e) = opener::reveal(path) {
error!("Failed to open logs dir: {e:#?}");
}

#[cfg(not(target_os = "linux"))]
if let Err(e) = opener::reveal(path) {
error!("Failed to open logs dir: {e:#?}");
}
Expand Down
5 changes: 1 addition & 4 deletions apps/desktop/src-tauri/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ pub fn plugin<R: Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::new("sd-updater")
.on_page_load(|window, _| {
#[cfg(target_os = "linux")]
let updater_available = {
let env = window.env();
let updater_available = false;

env.appimage.is_some()
};
#[cfg(not(target_os = "linux"))]
let updater_available = true;

Expand Down
34 changes: 0 additions & 34 deletions apps/landing/src/components/AppImage.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/developers/technology/publishing-updates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ index: 11

- Available at `/api/releases/desktop/[version]/[target]/[arch]`
- Same version semantics as Desktop Update API
- Looks for assets starting with `Spacedrive-{Target}-{Arch}` to allow for extensions like `.dmg`, `.AppImage` and `.msi`
- Looks for assets starting with `Spacedrive-{Target}-{Arch}` to allow for extensions like `.dmg`, `.deb` and `.msi`
- Returns a redirect as it's intended to be invoked via `<a>` elements

## Publishing a Release
Expand Down
2 changes: 0 additions & 2 deletions docs/product/getting-started/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,3 @@ C:\Program Files\Spacedrive\Spacedrive.exe
```bash
/opt/Spacedrive/Spacedrive
```

- Alternatively you may launch the AppImage from a terminal to view the logs.
2 changes: 0 additions & 2 deletions scripts/appimage/.gitignore

This file was deleted.

Loading

0 comments on commit 4447820

Please sign in to comment.