From 03cdc8d528490f85b2656cca7a83a3cf2c3885c8 Mon Sep 17 00:00:00 2001 From: Kamil Date: Sat, 27 Dec 2025 23:13:31 +0100 Subject: [PATCH] fix(rpm): enable post-install scripts and fix post-uninstall logic - Added support for `%post` scripts in RPM spec generation (previously missing). - Fixed `%postun` implementation which was ignoring configuration fields due to hardcoded values. - Aligned configuration API with Debian packager by supporting `postinstall_scripts` and `postuninstall_scripts` lists. - Added backward compatibility for legacy string key (`postun`). --- .../lib/src/makers/rpm/make_rpm_config.dart | 30 +++++++++++++++---- packages/flutter_app_packager/pubspec.yaml | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/flutter_app_packager/lib/src/makers/rpm/make_rpm_config.dart b/packages/flutter_app_packager/lib/src/makers/rpm/make_rpm_config.dart index 87a8381c..1e703691 100644 --- a/packages/flutter_app_packager/lib/src/makers/rpm/make_rpm_config.dart +++ b/packages/flutter_app_packager/lib/src/makers/rpm/make_rpm_config.dart @@ -30,12 +30,14 @@ class MakeRPMConfig extends MakeConfig { this.prep, this.build, this.install, - this.postun, + List? postinstallScripts, + List? postuninstallScripts, this.files, this.defattr, this.attr, this.changelog, - }); + }) : _postinstallScripts = postinstallScripts ?? [], + _postuninstallScripts = postuninstallScripts ?? []; factory MakeRPMConfig.fromJson(Map json) { return MakeRPMConfig( @@ -63,7 +65,12 @@ class MakeRPMConfig extends MakeConfig { prep: json['prep'] as String?, build: json['build'] as String?, install: json['install'] as String?, - postun: json['postun'] as String?, + postinstallScripts: json['postinstall_scripts'] != null + ? List.castFrom(json['postinstall_scripts']) + : null, + postuninstallScripts: json['postuninstall_scripts'] != null + ? List.castFrom(json['postuninstall_scripts']) + : (json['postun'] != null ? [json['postun'] as String] : null), files: json['files'] as String?, defattr: json['defattr'] as String?, attr: json['attr'] as String?, @@ -80,6 +87,8 @@ class MakeRPMConfig extends MakeConfig { List? supportedMimeType; List? actions; List? categories; + List _postinstallScripts; + List _postuninstallScripts; //RPM preamble Spec file fields String? summary; @@ -97,12 +106,21 @@ class MakeRPMConfig extends MakeConfig { String? prep; String? build; String? install; - String? postun; String? files; String? defattr; String? attr; String? changelog; + List get postScripts => [ + 'update-mime-database %{_datadir}/mime &> /dev/null || :', + ..._postinstallScripts, + ]; + + List get postunScripts => [ + 'update-mime-database %{_datadir}/mime &> /dev/null || :', + ..._postuninstallScripts, + ]; + @override Map toJson() { return { @@ -138,8 +156,8 @@ class MakeRPMConfig extends MakeConfig { 'cp -r %{name}*.xml %{buildroot}%{_datadir}/metainfo || :', 'update-mime-database %{_datadir}/mime &> /dev/null || :', ].join('\n'), - '%postun': ['update-mime-database %{_datadir}/mime &> /dev/null || :'] - .join('\n'), + '%post': postScripts.join('\n'), + '%postun': postunScripts.join('\n'), '%files': [ '%{_bindir}/%{name}', '%{_datadir}/%{name}', diff --git a/packages/flutter_app_packager/pubspec.yaml b/packages/flutter_app_packager/pubspec.yaml index 691ac9a0..f2d812cb 100644 --- a/packages/flutter_app_packager/pubspec.yaml +++ b/packages/flutter_app_packager/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_app_packager description: Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. -version: 0.6.5 +version: 0.6.6 homepage: https://github.com/fastforgedev/fastforge environment: