mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
Support the openELA "PATCHES" directory format as well
This commit is contained in:
parent
963b5d25dd
commit
82271f5d9e
@ -23,7 +23,7 @@ package srpmproc
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -48,10 +48,16 @@ import (
|
||||
|
||||
func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
||||
// 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 {
|
||||
// iterate through patches
|
||||
infos, err := patchTree.Filesystem.ReadDir("ROCKY/CFG")
|
||||
infos, err := patchTree.Filesystem.ReadDir(cfgdir)
|
||||
if err != nil {
|
||||
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())
|
||||
filePath := filepath.Join("ROCKY/CFG", info.Name())
|
||||
filePath := filepath.Join(cfgdir, info.Name())
|
||||
directive, err := patchTree.Filesystem.Open(filePath)
|
||||
if err != nil {
|
||||
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 {
|
||||
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 {
|
||||
// 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 {
|
||||
err := cfgPatches(pd, md, patchTree, pushTree)
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
return fmt.Errorf("could not read the whole of ignored source file: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user