Add scripts to package
This commit is contained in:
parent
cd6990fe45
commit
503328bf11
50
build.go
50
build.go
|
@ -66,6 +66,18 @@ type BuildVars struct {
|
||||||
Sources []string `sh:"sources"`
|
Sources []string `sh:"sources"`
|
||||||
Checksums []string `sh:"checksums"`
|
Checksums []string `sh:"checksums"`
|
||||||
Backup []string `sh:"backup"`
|
Backup []string `sh:"backup"`
|
||||||
|
Scripts Scripts `sh:"scripts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Scripts struct {
|
||||||
|
PreInstall string `sh:"preinstall"`
|
||||||
|
PostInstall string `sh:"postinstall"`
|
||||||
|
PreRemove string `sh:"preremove"`
|
||||||
|
PostRemove string `sh:"postinstall"`
|
||||||
|
PreUpgrade string `sh:"preupgrade"`
|
||||||
|
PostUpgrade string `sh:"postupgrade"`
|
||||||
|
PreTrans string `sh:"pretrans"`
|
||||||
|
PostTrans string `sh:"posttrans"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCmd(c *cli.Context) error {
|
func buildCmd(c *cli.Context) error {
|
||||||
|
@ -221,6 +233,8 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setScripts(&vars, pkgInfo, filepath.Dir(script))
|
||||||
|
|
||||||
if pkgInfo.Arch == "arm" {
|
if pkgInfo.Arch == "arm" {
|
||||||
pkgInfo.Arch = checkARMVariant()
|
pkgInfo.Arch = checkARMVariant()
|
||||||
}
|
}
|
||||||
|
@ -393,6 +407,42 @@ func checkARMVariant() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setScripts(vars *BuildVars, info *nfpm.Info, scriptDir string) {
|
||||||
|
if vars.Scripts.PreInstall != "" {
|
||||||
|
info.Scripts.PreInstall = filepath.Join(scriptDir, vars.Scripts.PreInstall)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PostInstall != "" {
|
||||||
|
info.Scripts.PostInstall = filepath.Join(scriptDir, vars.Scripts.PostInstall)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PreRemove != "" {
|
||||||
|
info.Scripts.PreRemove = filepath.Join(scriptDir, vars.Scripts.PreRemove)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PostRemove != "" {
|
||||||
|
info.Scripts.PostRemove = filepath.Join(scriptDir, vars.Scripts.PostRemove)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PreUpgrade != "" {
|
||||||
|
info.ArchLinux.Scripts.PreUpgrade = filepath.Join(scriptDir, vars.Scripts.PreUpgrade)
|
||||||
|
info.APK.Scripts.PreUpgrade = filepath.Join(scriptDir, vars.Scripts.PreUpgrade)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PostUpgrade != "" {
|
||||||
|
info.ArchLinux.Scripts.PostUpgrade = filepath.Join(scriptDir, vars.Scripts.PostUpgrade)
|
||||||
|
info.APK.Scripts.PostUpgrade = filepath.Join(scriptDir, vars.Scripts.PostUpgrade)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PreTrans != "" {
|
||||||
|
info.RPM.Scripts.PreTrans = filepath.Join(scriptDir, vars.Scripts.PreTrans)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars.Scripts.PostTrans != "" {
|
||||||
|
info.RPM.Scripts.PostTrans = filepath.Join(scriptDir, vars.Scripts.PostTrans)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func uniq(ss ...*[]string) {
|
func uniq(ss ...*[]string) {
|
||||||
for _, s := range ss {
|
for _, s := range ss {
|
||||||
slices.Sort(*s)
|
slices.Sort(*s)
|
||||||
|
|
Loading…
Reference in New Issue