mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
Merge pull request #16 from dirkmueller/openela
Support the openELA "PATCHES" directory format as well
This commit is contained in:
commit
f2864a875a
@ -23,7 +23,7 @@ package srpmproc
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -48,10 +48,16 @@ import (
|
|||||||
|
|
||||||
func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
||||||
// check CFG patches
|
// check CFG patches
|
||||||
_, err := patchTree.Filesystem.Stat("ROCKY/CFG")
|
// use PATCHES directory if it exists otherwise ROCKY/CFG
|
||||||
|
cfgdir := "PATCHES"
|
||||||
|
_, err := patchTree.Filesystem.Stat(cfgdir)
|
||||||
|
if err != nil {
|
||||||
|
cfgdir = "ROCKY/CFG"
|
||||||
|
}
|
||||||
|
_, err = patchTree.Filesystem.Stat(cfgdir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// iterate through patches
|
// iterate through patches
|
||||||
infos, err := patchTree.Filesystem.ReadDir("ROCKY/CFG")
|
infos, err := patchTree.Filesystem.ReadDir(cfgdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not walk patches: %v", err)
|
return fmt.Errorf("could not walk patches: %v", err)
|
||||||
}
|
}
|
||||||
@ -63,12 +69,12 @@ func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree
|
|||||||
}
|
}
|
||||||
|
|
||||||
pd.Log.Printf("applying directive %s", info.Name())
|
pd.Log.Printf("applying directive %s", info.Name())
|
||||||
filePath := filepath.Join("ROCKY/CFG", info.Name())
|
filePath := filepath.Join(cfgdir, info.Name())
|
||||||
directive, err := patchTree.Filesystem.Open(filePath)
|
directive, err := patchTree.Filesystem.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not open directive file %s: %v", info.Name(), err)
|
return fmt.Errorf("could not open directive file %s: %v", info.Name(), err)
|
||||||
}
|
}
|
||||||
directiveBytes, err := ioutil.ReadAll(directive)
|
directiveBytes, err := io.ReadAll(directive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not read directive file: %v", err)
|
return fmt.Errorf("could not read directive file: %v", err)
|
||||||
}
|
}
|
||||||
@ -96,7 +102,12 @@ func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree
|
|||||||
|
|
||||||
func applyPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
func applyPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
||||||
// check if patches exist
|
// check if patches exist
|
||||||
_, err := patchTree.Filesystem.Stat("ROCKY")
|
cfgdir := "PATCHES"
|
||||||
|
_, err := patchTree.Filesystem.Stat(cfgdir)
|
||||||
|
if err != nil {
|
||||||
|
cfgdir = "ROCKY"
|
||||||
|
}
|
||||||
|
_, err = patchTree.Filesystem.Stat(cfgdir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err := cfgPatches(pd, md, patchTree, pushTree)
|
err := cfgPatches(pd, md, patchTree, pushTree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -315,7 +326,7 @@ func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadAll(f)
|
content, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not read modulemd file: %v", err)
|
return fmt.Errorf("could not read modulemd file: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not open ignored source file %s: %v", sourcePath, err)
|
return nil, fmt.Errorf("could not open ignored source file %s: %v", sourcePath, err)
|
||||||
}
|
}
|
||||||
sourceFileBts, err := ioutil.ReadAll(sourceFile)
|
sourceFileBts, err := io.ReadAll(sourceFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not read the whole of ignored source file: %v", err)
|
return nil, fmt.Errorf("could not read the whole of ignored source file: %v", err)
|
||||||
}
|
}
|
||||||
@ -1299,7 +1299,7 @@ func processLookasideSources(pd *data.ProcessData, md *data.ModeData, localDir s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not open ignored source file %s: %v", sourcePath, err)
|
return fmt.Errorf("could not open ignored source file %s: %v", sourcePath, err)
|
||||||
}
|
}
|
||||||
sourceFileBts, err := ioutil.ReadAll(sourceFile)
|
sourceFileBts, err := io.ReadAll(sourceFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not read the whole of ignored source file: %v", err)
|
return fmt.Errorf("could not read the whole of ignored source file: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user