Skip to content

Commit

Permalink
cd: use dart tar archive for creating tar file
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed May 7, 2024
1 parent bb3f83d commit f021c4f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
38 changes: 26 additions & 12 deletions cli/commands/build/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:io/io.dart';
import 'package:args/command_runner.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart';
import 'package:archive/archive.dart';

import '../../core/env.dart';
import 'common.dart';
Expand Down Expand Up @@ -48,26 +49,39 @@ class LinuxBuildCommand extends Command with BuildCommandCommonSteps {
final bundleDirPath =
join(cwd.path, "build", "linux", "x64", "release", "bundle");

final tarPath = join(
final tarFile = File(join(
cwd.path,
"build",
"dist",
"spotube-linux-"
"${CliEnv.channel == BuildChannel.nightly ? "nightly" : versionWithoutBuildNumber}"
"-x86_64.tar.xz",
);
));

await copyPath(bundleDirPath, tempDir);

await shell.run(
"""
cp ${join(cwd.path, "linux", "spotube.desktop")} $tempDir
cp ${join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml")} $tempDir
cp ${join(cwd.path, "assets", "spotube-logo.png")} $tempDir
tar -cJf $tarPath -C $tempDir .
""",
await copyPath(join(cwd.path, "linux", "spotube.desktop"), tempDir);
await copyPath(
join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"),
tempDir,
);
await copyPath(join(cwd.path, "assets", "spotube-logo.png"), tempDir);

final archive = Archive();

for (final entity in Directory(tempDir).listSync(recursive: true)) {
if (entity is File) {
final fileRelPath = relative(entity.path, from: tempDir);
final file = File(entity.path);
final fileData = file.readAsBytesSync();
archive.addFile(ArchiveFile(fileRelPath, fileData.length, fileData));
}
}

// convert to tar.xz
final tarEncoder = TarEncoder();
final xzEncoder = XZEncoder();
final tarXzData = xzEncoder.encode(tarEncoder.encode(archive));

await File(tarPath).copy(join(cwd.path, "dist"));
await tarFile.writeAsBytes(tarXzData);

final ogDeb = File(
join(
Expand Down
14 changes: 3 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ packages:
source: hosted
version: "4.0.1"
archive:
dependency: transitive
dependency: "direct dev"
description:
name: archive
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
url: "https://pub.dev"
source: hosted
version: "3.4.10"
version: "3.5.1"
args:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1702,14 +1702,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333"
url: "https://pub.dev"
source: hosted
version: "3.8.0"
pool:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ dev_dependencies:
process_run: ^0.14.2
xml: ^6.5.0
io: ^1.0.4
archive: ^3.5.1

dependency_overrides:
uuid: ^4.4.0
Expand Down

0 comments on commit f021c4f

Please sign in to comment.