Skip to content

Commit d6432fc

Browse files
committed
Add: Move files
1 parent be3cade commit d6432fc

33 files changed

Lines changed: 213 additions & 29 deletions

alteriso5/cmd/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import (
66
)
77

88
func init() {
9-
cobrautils.AddSubCmds(build.Cmd())
9+
cobrautils.RegisterSubCmd(build.Cmd())
1010
}

alteriso5/cmd/build/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"os"
55
"path"
66

7-
"github.com/FascodeNet/alterlinux/alteriso5/cmd/build/config"
8-
"github.com/FascodeNet/alterlinux/alteriso5/cmd/build/work"
7+
"github.com/FascodeNet/alterlinux/alteriso5/config"
8+
"github.com/FascodeNet/alterlinux/alteriso5/work"
99
"github.com/FascodeNet/alterlinux/alteriso5/cmd/check"
1010
"github.com/FascodeNet/alterlinux/alteriso5/utils"
1111
"github.com/spf13/cobra"

alteriso5/cmd/build/config/pkg/package.go

Lines changed: 0 additions & 4 deletions
This file was deleted.

alteriso5/cmd/check.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package cmd
22

33
import (
44
"github.com/FascodeNet/alterlinux/alteriso5/cmd/check"
5-
"github.com/Hayao0819/nahi/cobrautils"
65
)
76

87
func init() {
9-
cobrautils.AddSubCmds(check.Cmd())
8+
rootSubCmds.RegisterSubCmd(check.Cmd())
109
}

alteriso5/cmd/clean.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package cmd
22

33
import (
44
"github.com/FascodeNet/alterlinux/alteriso5/cmd/clean"
5-
"github.com/Hayao0819/nahi/cobrautils"
65
)
76

87
func init() {
9-
cobrautils.AddSubCmds(clean.Cmd())
8+
rootSubCmds.RegisterSubCmd(clean.Cmd())
109
}

alteriso5/cmd/profile.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cmd
2+
3+
import "github.com/FascodeNet/alterlinux/alteriso5/cmd/profile"
4+
5+
func init() {
6+
rootSubCmds.RegisterSubCmd(profile.Cmd())
7+
}

alteriso5/cmd/profile/pkglist.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package profile
2+
3+
import (
4+
"github.com/FascodeNet/alterlinux/alteriso5/config/pkg"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func pkgListCmd() *cobra.Command {
9+
cmd := cobra.Command{
10+
Use: "pkglist profile arch",
11+
Short: "List packages in the profile",
12+
Args: cobra.ExactArgs(2),
13+
RunE: func(cmd *cobra.Command, args []string) error {
14+
files, err := pkg.FindPkgListFiles(profile.Base, args[1])
15+
if err != nil{
16+
return err
17+
}
18+
19+
cmd.Println(files)
20+
return nil
21+
22+
},
23+
}
24+
25+
return &cmd
26+
}
27+
28+
func init() {
29+
subCmds.RegisterSubCmd(pkgListCmd())
30+
}

alteriso5/cmd/profile/root.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package profile
2+
3+
import (
4+
"github.com/FascodeNet/alterlinux/alteriso5/config"
5+
"github.com/FascodeNet/alterlinux/alteriso5/utils"
6+
"github.com/Hayao0819/nahi/cobrautils"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var subCmds = cobrautils.Registory{}
11+
var profile *config.Profile
12+
13+
func Cmd() *cobra.Command {
14+
cmd := cobra.Command{
15+
Use: "profile",
16+
Short: "Debug your profile",
17+
PersistentPreRunE: utils.WithParentPersistentPreRunE(func(cmd *cobra.Command, args []string) error {
18+
p, err := config.ReadProfile(args[0])
19+
if err != nil {
20+
return err
21+
}
22+
23+
profile = p
24+
25+
return nil
26+
}),
27+
}
28+
29+
subCmds.BindSubCmds(&cmd)
30+
31+
return &cmd
32+
}

alteriso5/cmd/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
package cmd
22

33
import (
4+
"github.com/FascodeNet/alterlinux/alteriso5/log"
5+
"github.com/FascodeNet/alterlinux/alteriso5/utils"
46
"github.com/Hayao0819/nahi/cobrautils"
57
"github.com/spf13/cobra"
68
)
79

10+
var rootSubCmds = cobrautils.Registory{}
11+
812
func Root() *cobra.Command {
913
root := cobra.Command{
1014
Use: "alteriso5",
1115
Short: "AlterISO5 is a tool to build Arch Linux live ISO images",
16+
PersistentPreRunE: utils.WithParentPersistentPreRunE(func(cmd *cobra.Command, args []string) error {
17+
log.Setup()
18+
return nil
19+
}),
1220
SilenceUsage: true,
1321
}
1422

15-
cobrautils.AddSubCmdsToRoot(&root)
23+
rootSubCmds.BindSubCmds(&root)
1624

1725
return &root
1826
}

alteriso5/config/pkg/package.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package pkg
2+
3+
import (
4+
"log/slog"
5+
"os"
6+
"path"
7+
8+
"github.com/Hayao0819/nahi/osutils"
9+
)
10+
11+
// 指定されたプロファイルとアーキテクチャに対応するパッケージリストファイルを検索し、そのファイルのパスを返します。
12+
func FindPkgListFiles(profile string, arch string) ([]string, error) {
13+
findFiles := []string{
14+
"packages." + arch,
15+
"packages.any",
16+
}
17+
18+
findDirs := []string{
19+
"packages." + arch + ".d",
20+
"packages.any.d",
21+
}
22+
23+
// パッケージリストファイルを検索
24+
for _, d := range findDirs {
25+
dir := path.Join(profile, d)
26+
slog.Debug("Check pkglist", "subdir", dir)
27+
if !osutils.IsDir(dir) {
28+
continue
29+
}
30+
31+
slog.Debug("Found pkglist", "subdir", dir)
32+
33+
files, err := os.ReadDir(dir)
34+
if err != nil {
35+
slog.Warn("Failed to list directory", "dir", dir, "error", err)
36+
continue
37+
}
38+
slog.Debug("Found pkglist", "files", files)
39+
for _, f := range files {
40+
p := path.Join(profile, d, f.Name())
41+
slog.Info("Found pkglist", "file",p)
42+
findFiles = append(findFiles, p)
43+
}
44+
}
45+
46+
retunPaths := []string{}
47+
48+
for _, f := range findFiles {
49+
slog.Debug("Check pkglist", "file", path.Join(profile, f))
50+
if osutils.IsFile(path.Join(profile, f)) {
51+
retunPaths = append(retunPaths, path.Join(profile, f))
52+
}
53+
}
54+
55+
return retunPaths, nil
56+
}

0 commit comments

Comments
 (0)