Replace version and binlocation strings in nfpm config
This commit is contained in:
parent
20c33abd15
commit
0508d9880b
|
@ -22,3 +22,4 @@ files/
|
|||
!pkg/files/
|
||||
vikunja-dump*
|
||||
vendor/
|
||||
os-packages/
|
||||
|
|
26
magefile.go
26
magefile.go
|
@ -668,7 +668,7 @@ func (Release) Reprepro() {
|
|||
runAndStreamOutput("reprepro_expect", "debian", "includedeb", "strech", RootPath+"/"+Executable+"-"+Version+"_amd64.deb")
|
||||
}
|
||||
|
||||
func (Release) Packages() {
|
||||
func (Release) Packages() error {
|
||||
mg.Deps(initVars)
|
||||
if err := exec.Command("nfpm").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") {
|
||||
fmt.Println("Please manually install nfpm by running")
|
||||
|
@ -676,8 +676,28 @@ func (Release) Packages() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
runAndStreamOutput("nfpm", "pkg", "--packager", "deb", "--target", "release/deb")
|
||||
runAndStreamOutput("nfpm", "pkg", "--packager", "rpm", "--target", "release/rpm")
|
||||
// Because nfpm does not support templating, we replace the values in the config file and restore it after running
|
||||
nfpmConfigPath := RootPath + "/nfpm.yaml"
|
||||
nfpmconfig, err := ioutil.ReadFile(nfpmConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fixedConfig := strings.ReplaceAll(string(nfpmconfig), "<version>", VersionNumber)
|
||||
fixedConfig = strings.ReplaceAll(fixedConfig, "<binlocation>", BinLocation)
|
||||
if err := ioutil.WriteFile(nfpmConfigPath, []byte(fixedConfig), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
releasePath := RootPath + "/os-packages/"
|
||||
if err := os.MkdirAll(releasePath, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
runAndStreamOutput("nfpm", "pkg", "--packager", "deb", "--target", releasePath)
|
||||
runAndStreamOutput("nfpm", "pkg", "--packager", "rpm", "--target", releasePath)
|
||||
|
||||
return ioutil.WriteFile(nfpmConfigPath, nfpmconfig, 0)
|
||||
}
|
||||
|
||||
type Dev mg.Namespace
|
||||
|
|
Loading…
Reference in New Issue