From a5521a0d6bce20a5c58fd000b60e4281e3e6a0a2 Mon Sep 17 00:00:00 2001 From: Scott Mattan Date: Sun, 13 Oct 2024 22:14:05 +0900 Subject: [PATCH] add scripts --- builder.go | 10 +++++++++- scripts.go | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 scripts.go diff --git a/builder.go b/builder.go index 191ede9..4a96a37 100644 --- a/builder.go +++ b/builder.go @@ -13,9 +13,10 @@ import ( ) type Builder struct { - rpmpack.RPMMetaData BinDir string DistDir string + rpmpack.RPMMetaData + Scripts Scripts Files []PackageFile } @@ -118,6 +119,13 @@ func (b *Builder) Package() error { } } + r.AddPretrans(b.Scripts.PreTransact) + r.AddPosttrans(b.Scripts.PostTransact) + r.AddPrein(b.Scripts.PreInstall) + r.AddPostin(b.Scripts.PostInstall) + r.AddPreun(b.Scripts.PreUninstall) + r.AddPostun(b.Scripts.PostUninstall) + // TODO: need to verify before write? if err := r.Write(out); err != nil { return err diff --git a/scripts.go b/scripts.go new file mode 100644 index 0000000..784047f --- /dev/null +++ b/scripts.go @@ -0,0 +1,13 @@ +package rpmbuild + +// Scripts are shell (/bin/sh) executable commands and not a filename +// +// TODO: add post processing if necessary... +type Scripts struct { + PreTransact string + PostTransact string + PreInstall string + PostInstall string + PreUninstall string + PostUninstall string +}