internal/archive: make archiveItem.add private
This commit is contained in:
@@ -140,9 +140,9 @@ func getInitfsExtraFiles(devinfo deviceinfo.DeviceInfo) (files []string, err err
|
||||
log.Println("== Generating initramfs extra ==")
|
||||
|
||||
// Hook files & scripts
|
||||
if misc.Exists("/etc/postmarketos-mkinitfs/files-extra") {
|
||||
if misc.Exists("/etc/mkinitfs/files-extra") {
|
||||
log.Println("- Including hook files")
|
||||
hookFiles := hookfiles.New("/etc/postmarketos-mkinitfs/files-extra")
|
||||
hookFiles := hookfiles.New("/etc/mkinitfs/files-extra")
|
||||
|
||||
if list, err := hookFiles.List(); err != nil {
|
||||
return nil, err
|
||||
@@ -151,9 +151,9 @@ func getInitfsExtraFiles(devinfo deviceinfo.DeviceInfo) (files []string, err err
|
||||
}
|
||||
}
|
||||
|
||||
if misc.Exists("/etc/postmarketos-mkinitfs/hooks-extra") {
|
||||
if misc.Exists("/etc/mkinitfs/hooks-extra") {
|
||||
log.Println("- Including extra hook scripts")
|
||||
hookScripts := hookscripts.New("/etc/postmarketos-mkinitfs/hooks-extra")
|
||||
hookScripts := hookscripts.New("/etc/mkinitfs/hooks-extra")
|
||||
|
||||
if list, err := hookScripts.List(); err != nil {
|
||||
return nil, err
|
||||
@@ -173,11 +173,11 @@ func getInitfsExtraFiles(devinfo deviceinfo.DeviceInfo) (files []string, err err
|
||||
return
|
||||
}
|
||||
|
||||
func getInitfsFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
||||
func getInitfsFiles(devinfo deviceinfo.DeviceInfo, files misc.Items) (err error) {
|
||||
log.Println("== Generating initramfs ==")
|
||||
|
||||
// Hook files & scripts
|
||||
if misc.Exists("/etc/postmarketos-mkinitfs/files") {
|
||||
if misc.Exists("/etc/mkinitfs/files") {
|
||||
log.Println("- Including hook files")
|
||||
hookFiles := hookfiles.New("/etc/postmarketos-mkinitfs/files")
|
||||
|
||||
@@ -188,9 +188,9 @@ func getInitfsFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if misc.Exists("/etc/postmarketos-mkinitfs/hooks") {
|
||||
if misc.Exists("/etc/mkinitfs/hooks") {
|
||||
log.Println("- Including hook scripts")
|
||||
hookScripts := hookscripts.New("/etc/postmarketos-mkinitfs/hooks")
|
||||
hookScripts := hookscripts.New("/etc/mkinitfs/hooks")
|
||||
|
||||
if list, err := hookScripts.List(); err != nil {
|
||||
return nil, err
|
||||
@@ -287,7 +287,7 @@ func generateInitfs(name string, path string, kernVer string, devinfo deviceinfo
|
||||
}
|
||||
|
||||
// initfs_functions
|
||||
if err := initfsArchive.AddItem("/usr/share/postmarketos-mkinitfs/init_functions.sh", "/init_functions.sh"); err != nil {
|
||||
if err := initfsArchive.AddItem("/usr/share/mkinitfs/init_functions.sh", "/init_functions.sh"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ type archiveItems struct {
|
||||
|
||||
// Adds the given item to the archiveItems, only if it doesn't already exist in
|
||||
// the list. The items are kept sorted in ascending order.
|
||||
func (a *archiveItems) Add(item archiveItem) {
|
||||
func (a *archiveItems) add(item archiveItem) {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
|
||||
@@ -170,7 +170,7 @@ func (archive *Archive) addFile(source string, dest string) error {
|
||||
|
||||
destFilename := strings.TrimPrefix(dest, "/")
|
||||
|
||||
archive.items.Add(archiveItem{
|
||||
archive.items.add(archiveItem{
|
||||
sourcePath: source,
|
||||
header: &cpio.Header{
|
||||
Name: destFilename,
|
||||
@@ -200,7 +200,7 @@ func (archive *Archive) addFile(source string, dest string) error {
|
||||
|
||||
destFilename := strings.TrimPrefix(dest, "/")
|
||||
|
||||
archive.items.Add(archiveItem{
|
||||
archive.items.add(archiveItem{
|
||||
sourcePath: source,
|
||||
header: &cpio.Header{
|
||||
Name: destFilename,
|
||||
@@ -295,7 +295,7 @@ func (archive *Archive) addDir(dir string) error {
|
||||
subdirs := strings.Split(strings.TrimPrefix(dir, "/"), "/")
|
||||
for i, subdir := range subdirs {
|
||||
path := filepath.Join(strings.Join(subdirs[:i], "/"), subdir)
|
||||
archive.items.Add(archiveItem{
|
||||
archive.items.add(archiveItem{
|
||||
sourcePath: path,
|
||||
header: &cpio.Header{
|
||||
Name: path,
|
||||
|
@@ -180,7 +180,7 @@ func TestArchiveItemsAdd(t *testing.T) {
|
||||
for _, st := range subtests {
|
||||
t.Run(st.name, func(t *testing.T) {
|
||||
a := archiveItems{items: st.inItems}
|
||||
a.Add(st.inItem)
|
||||
a.add(st.inItem)
|
||||
if !reflect.DeepEqual(st.expected, a.items) {
|
||||
t.Fatal("expected:", st.expected, " got: ", a.items)
|
||||
}
|
||||
|
Reference in New Issue
Block a user