Skip to content

Commit 7707d1b

Browse files
Merge 152247f into master
2 parents c2c535c + 152247f commit 7707d1b

File tree

8 files changed

+79
-68
lines changed

8 files changed

+79
-68
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ my use cases.
1616
`exe2dist` works on Linux and MacOS. Compressible binaries can be for other
1717
platforms as well.
1818

19+
## Install
20+
21+
Compiled executables can be downloaded manually from the [releases page](https://github.com/rtmigo/exe2dist_dart/releases).
22+
23+
For use as part of CI/CD, a command-line installation is more suitable.
24+
25+
Download and unpack the Linux version to the current directory in one line.
26+
27+
```bash
28+
# install
29+
wget -c https://github.com/rtmigo/exe2dist_dart/releases/download/0.2.2/exe2dist_linux_amd64.tgz -O - | tar -xz
30+
31+
# run
32+
./exe2dist
33+
```
34+
35+
Same for the newest version instead of the fixed one.
36+
37+
```bash
38+
wget -c https://github.com/rtmigo/exe2dist_dart/releases/latest/download/exe2dist_linux_amd64.tgz -O - | tar -xz
39+
```
40+
1941
## Use
2042

2143
Archive file `./native_exe` to a distributable

bin/source/architecture.dart

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import 'dart:io';
22

33
class Architecture {
4-
final String string;
4+
final String os;
5+
final String platform;
56

6-
Architecture(this.string);
7+
String get combined => "${os}_$platform";
78

8-
bool get isWindows => string.startsWith("windows");
9+
Architecture(this.os, this.platform);
10+
11+
bool get isWindows => os == "windows";
912
}
1013

1114
class UnknownArchitectureException extends Error {
12-
UnknownArchitectureException({
13-
required this.processResult
14-
});
15+
UnknownArchitectureException({required this.processResult});
16+
1517
final ProcessResult processResult;
1618

1719
@override
@@ -20,21 +22,47 @@ class UnknownArchitectureException extends Error {
2022
}
2123
}
2224

25+
/*
26+
Вопрос, как называть архитектуры:
27+
28+
RedHat, Fedora, Suse за x86_64:
29+
Fedora-Workstation-Live-x86_64-36-1.5.iso
30+
Fedora-Workstation-Live-aarch64-36-1.5.iso
31+
archlinux-2022.10.01-x86_64.iso
32+
SLE-15-SP4-Full-x86_64-GM-Media1.iso
33+
SLE-15-SP4-Full-aarch64-GM-Media1.iso
34+
35+
Википедия пишет:
36+
x86-64 (also known as x64, x86_64, AMD64, and Intel 64)
37+
38+
Debian и производные, FreeBSD за amd64:
39+
debian-11.5.0-amd64-netinst.iso
40+
debian-11.5.0-arm64-netinst.iso
41+
ubuntu-20.04.5-live-server-amd64.iso
42+
ubuntu-22.04.1-live-server-arm64.iso
43+
FreeBSD-13.1-RELEASE-amd64-disc1.iso
44+
FreeBSD-13.1-RELEASE-arm64-aarch64-dvd1.iso
45+
46+
MX целится только в x86, причём называется своеобразно:
47+
MX-21.2.1_x64.iso
48+
MX-21.2.1_386.iso
49+
50+
Я предпочитаю именования Debian, поскольку они не содержат знаков препинания.
51+
*/
52+
2353
Architecture detectArchitecture(File file) {
2454
final pr = Process.runSync("file", [file.path]);
2555
final stdout = pr.stdout.toString();
2656
bool containsAll(List<String> l) => l.every((s) => stdout.contains(s));
2757

2858
if (containsAll(["Mach-O", "x86_64", "executable"])) {
29-
return Architecture("macos_x86-64");
30-
} if (containsAll(["Mach-O", "arm64", "executable"])) {
31-
return Architecture("macos_arm64");
59+
return Architecture("macos", "amd64");
60+
} else if (containsAll(["Mach-O", "arm64", "executable"])) {
61+
return Architecture("macos", "arm64");
3262
} else if (containsAll(["for GNU/Linux", "x86-64"])) {
33-
return Architecture("linux_x86-64");
63+
return Architecture("linux", "amd64");
3464
} else if (containsAll(["for MS Windows", "PE32+", "x86-64"])) {
35-
return Architecture("windows_x86-64");
65+
return Architecture("windows", "amd64");
3666
}
37-
throw UnknownArchitectureException(
38-
processResult: pr
39-
);
40-
}
67+
throw UnknownArchitectureException(processResult: pr);
68+
}

bin/source/archive.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Future<void> binaryToDist(
138138
arcFunc = fileToTarGz;
139139
}
140140
final targetFile = File(
141-
path.join(targetDir.path, "${programName}_${arch.string}$arcSuffix"));
141+
path.join(targetDir.path, "${programName}_${arch.combined}$arcSuffix"));
142142
if (targetFile.existsSync()) {
143143
throw TargetFileAlreadyExistsException(targetFile);
144144
}

ghcp.iml

Lines changed: 0 additions & 14 deletions
This file was deleted.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: exe2dist
22
description: Binary executable packaging tool.
3-
version: 0.2.1
3+
version: 0.2.2
44

55
environment:
66
sdk: '>=2.18.0 <3.0.0'

script/archive.dart

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/architecture_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import '../bin/source/architecture.dart';
66

77
void main() {
88
test("detecting architecture", () {
9-
expect(detectArchitecture(File("test/executables/ghcp_linux_amd64")).string,
10-
'linux_x86-64');
11-
expect(detectArchitecture(File("test/executables/ghcp_osx_amd64")).string,
12-
'macos_x86-64');
13-
expect(detectArchitecture(File("test/executables/ghcp_windows_amd64")).string,
14-
'windows_x86-64');
9+
expect(detectArchitecture(File("test/executables/ghcp_linux_amd64")).combined,
10+
'linux_amd64');
11+
expect(detectArchitecture(File("test/executables/ghcp_osx_amd64")).combined,
12+
'macos_amd64');
13+
expect(detectArchitecture(File("test/executables/ghcp_windows_amd64")).combined,
14+
'windows_amd64');
1515
expect(()=>detectArchitecture(File("test/executables/labuda.txt")),
1616
throwsA(isA<UnknownArchitectureException>()));
1717
});

test/pack_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() {
3333
);
3434

3535
expect(tempDir!.listSync().map((e) => path.basename(e.path)).toList(),
36-
['abc_linux_x86-64.tgz']);
36+
['abc_linux_amd64.tgz']);
3737
});
3838

3939
test("macos", () async {
@@ -44,7 +44,7 @@ void main() {
4444
);
4545

4646
expect(tempDir!.listSync().map((e) => path.basename(e.path)).toList(),
47-
['abc_macos_x86-64.tgz']);
47+
['abc_macos_amd64.tgz']);
4848
});
4949

5050
test("windows", () async {
@@ -55,16 +55,16 @@ void main() {
5555
);
5656

5757
expect(tempDir!.listSync().map((e) => path.basename(e.path)).toList(),
58-
['abc_windows_x86-64.zip']);
58+
['abc_windows_amd64.zip']);
5959
});
6060

6161
test("detecting architecture", () {
6262
// expect(detectArchitecture(File("test/executables/ghcp_linux_amd64")).string,
63-
// 'linux_x86-64');
63+
// 'linux_amd64');
6464
// expect(detectArchitecture(File("test/executables/ghcp_osx_amd64")).string,
65-
// 'macos_x86-64');
65+
// 'macos_amd64');
6666
// expect(detectArchitecture(File("test/executables/ghcp_windows_amd64")).string,
67-
// 'windows_x86-64');
67+
// 'windows_amd64');
6868
// expect(()=>detectArchitecture(File("test/executables/labuda.txt")),
6969
// throwsA(isA<UnknownArchitectureException>()));
7070
});

0 commit comments

Comments
 (0)