fix(release): a snap built in a clone of its own is packed without --output, into the clone
snapcraft builds in LXD with the project mounted at /root/project and passes --output on unchanged: naming the clone itself, it took the clone for a file in the folder above, outside the project, and refused it again. Without --output it packs into the clone (checked with snapcraft 9.2.1 in Todo's clone), from where the release tool moves it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
34001b1aff
commit
c8d94d0ceb
3 changed files with 17 additions and 29 deletions
|
|
@ -167,18 +167,12 @@ void main() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('is packed inside its clone, as snapcraft packs nowhere outside the '
|
test('is packed without --output, into its clone, as snapcraft takes the '
|
||||||
"project, and Learn's into the release's folder", () {
|
"clone's own path for a file outside the project; Learn's into the "
|
||||||
|
"release's folder", () {
|
||||||
|
expect(snap.packOutput(root: '/repo', out: 'build/x'), isNull);
|
||||||
expect(
|
expect(
|
||||||
snap.packPath(home: '/home/someone', root: '/repo', out: 'build/x'),
|
learnRelease.snap!.packOutput(root: '/repo', out: 'build/x'),
|
||||||
'/home/someone/.cache/halkyon-release/snap/halkyon-todo',
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
learnRelease.snap!.packPath(
|
|
||||||
home: '/home/someone',
|
|
||||||
root: '/repo',
|
|
||||||
out: 'build/x',
|
|
||||||
),
|
|
||||||
'/repo/build/x',
|
'/repo/build/x',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -216,13 +216,12 @@ final class const SnapRelease({
|
||||||
/// otherwise analyse.
|
/// otherwise analyse.
|
||||||
String projectPath(String home) => '$home/.cache/halkyon-release/snap/$name';
|
String projectPath(String home) => '$home/.cache/halkyon-release/snap/$name';
|
||||||
|
|
||||||
/// Where `snapcraft pack` writes the snap: the release's folder ([out] in
|
/// The folder `snapcraft pack --output` names: the release's folder ([out]
|
||||||
/// [root]) for the root's, its clone for any other, as snapcraft packs
|
/// in [root]) for the root's; none for any other, which snapcraft then packs
|
||||||
/// nowhere outside the project it builds (found releasing Todo 0.1.0, 3 Nov
|
/// into its clone, where the release tool takes it from. snapcraft builds in
|
||||||
/// 2026); the release tool moves it into the release's folder from there.
|
/// LXD with the project mounted elsewhere, and takes an `--output` naming the
|
||||||
String packPath({
|
/// clone itself for a file in the folder above it, outside the project, so
|
||||||
required String home,
|
/// refuses it (found releasing Todo 0.1.0, 3 Nov 2026).
|
||||||
required String root,
|
String? packOutput({required String root, required String out}) =>
|
||||||
required String out,
|
atRoot ? '$root/$out' : null;
|
||||||
}) => atRoot ? '$root/$out' : projectPath(home);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -454,18 +454,13 @@ final class Releaser({
|
||||||
'clean',
|
'clean',
|
||||||
snap.part,
|
snap.part,
|
||||||
], workingDirectory: project);
|
], workingDirectory: project);
|
||||||
final packed = snap.packPath(
|
final output = snap.packOutput(root: root.path, out: out);
|
||||||
home: Platform.environment['HOME'] ?? '',
|
|
||||||
root: root.path,
|
|
||||||
out: out,
|
|
||||||
);
|
|
||||||
await _run('snapcraft', [
|
await _run('snapcraft', [
|
||||||
'pack',
|
'pack',
|
||||||
'--output',
|
if (output != null) ...['--output', output],
|
||||||
packed,
|
|
||||||
], workingDirectory: project);
|
], workingDirectory: project);
|
||||||
if (!snap.atRoot) {
|
if (output == null) {
|
||||||
File(p.join(packed, snapFile))
|
File(p.join(project, snapFile))
|
||||||
..copySync(p.join(root.path, out, snapFile))
|
..copySync(p.join(root.path, out, snapFile))
|
||||||
..deleteSync();
|
..deleteSync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue