spotube/cli/commands/build/linux.dart
Alessio fece073def This pull request primarily involves the removal of several configuration files and assets, as well as minor updates to documentation. The most significant changes are the deletion of various .vscode configuration files and the removal of unused assets from the project.
Configuration File Removals:

    .vscode/c_cpp_properties.json: Removed the entire configuration for C/C++ properties.
    .vscode/launch.json: Removed the Dart launch configurations for different environments and modes.
    .vscode/settings.json: Removed settings related to CMake, spell checking, file nesting, and Dart Flutter SDK path.
    .vscode/snippets.code-snippets: Removed code snippets for Dart, including PaginatedState and PaginatedNotifier templates.
    .vscode/tasks.json: Removed the tasks configuration file.

Documentation Updates:

    CONTRIBUTION.md: Removed heart emoji from the introductory text.
    README.md: Updated the logo image and made minor text adjustments, including removing emojis and updating section titles. [1] [2] [3] [4] [5]

Asset Removals:

    lib/collections/assets.gen.dart: Removed multiple unused asset references, including images related to Spotube logos and banners. [1] [2] [3]

Minor Code Cleanups:

    cli/commands/build/linux.dart, cli/commands/build/windows.dart, cli/commands/translated.dart, cli/commands/untranslated.dart: Adjusted import statements for consistency. [1] [2] [3] [4]
    integration_test/app_test.dart: Removed an unnecessary blank line.
    lib/collections/routes.dart: Commented out the TrackRoute configuration.
2025-04-13 18:40:37 +02:00

122 lines
2.9 KiB
Dart

import 'dart:async';
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:intl/intl.dart';
import 'package:io/io.dart';
import 'package:path/path.dart';
import '../../core/env.dart';
import 'common.dart';
class LinuxBuildCommand extends Command with BuildCommandCommonSteps {
@override
String get description => "Linux build command";
@override
String get name => "linux";
@override
FutureOr? run() async {
stdout.writeln("Replacing versions");
final appDataFile = File(
join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"),
);
appDataFile.writeAsStringSync(
appDataFile.readAsStringSync().replaceAll(
versionVarRegExp,
'<release'
' version="$versionWithoutBuildNumber"'
' date="${DateFormat("yyyy-MM-dd").format(DateTime.now())}"'
'/>',
),
);
await bootstrap();
await shell.run(
"flutter_distributor package --platform=linux --targets=deb",
);
if (architecture == "x86") {
await shell.run(
"flutter_distributor package --platform=linux --targets=rpm",
);
}
final tempDir = join(Directory.systemTemp.path, "spotube-tar");
final bundleArchName = architecture == "x86" ? "x86_64" : "aarch64";
final bundleDirPath = join(
cwd.path,
"build",
"linux",
architecture == "x86" ? "x64" : architecture,
"release",
"bundle",
);
final tarFile = File(join(
cwd.path,
"dist",
"spotube-linux-"
"${CliEnv.channel == BuildChannel.nightly ? "nightly" : versionWithoutBuildNumber}"
"-$bundleArchName.tar.xz",
));
await copyPath(bundleDirPath, tempDir);
await File(join(cwd.path, "linux", "spotube.desktop")).copy(
join(tempDir, "spotube.desktop"),
);
await File(
join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"),
).copy(
join(tempDir, "com.github.KRTirtho.Spotube.appdata.xml"),
);
await File(join(cwd.path, "assets", "spotube-logo.png")).copy(
join(tempDir, "spotube-logo.png"),
);
await shell.run(
"tar -cJf ${tarFile.path} -C $tempDir .",
);
final ogDeb = File(
join(
cwd.path,
"dist",
pubspec.version.toString(),
"spotube-${pubspec.version}-linux.deb",
),
);
await ogDeb.copy(
join(
cwd.path,
"dist",
"Spotube-linux-$bundleArchName.deb",
),
);
await ogDeb.delete();
if (architecture == "x86") {
final ogRpm = File(
join(
cwd.path,
"dist",
pubspec.version.toString(),
"spotube-${pubspec.version}-linux.rpm",
),
);
await ogRpm.copy(
join(cwd.path, "dist", "Spotube-linux-$bundleArchName.rpm"),
);
await ogRpm.delete();
}
stdout.writeln("✅ Linux building done");
}
}