Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
107075e8ef | |||
41e3d8119f |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,4 +11,6 @@
|
|||||||
|
|
||||||
e2e-tests/alr
|
e2e-tests/alr
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
commit_msg.txt
|
commit_msg.txt
|
||||||
|
/scripts/.claude/settings.local.json
|
||||||
|
/ALR
|
||||||
|
@@ -402,3 +402,108 @@ func filesFindConfigCmd(hc interp.HandlerContext, cmd string, args []string) err
|
|||||||
|
|
||||||
return outputFiles(hc, configFiles)
|
return outputFiles(hc, configFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func filesFindSystemdCmd(hc interp.HandlerContext, cmd string, args []string) error {
|
||||||
|
namePattern := "*"
|
||||||
|
if len(args) > 0 {
|
||||||
|
namePattern = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
systemdPath := "./usr/lib/systemd/system/"
|
||||||
|
realPath := path.Join(hc.Dir, systemdPath)
|
||||||
|
|
||||||
|
if err := validateDir(realPath, "files-find-systemd"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var systemdFiles []string
|
||||||
|
err := filepath.Walk(realPath, func(p string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !info.IsDir() && matchNamePattern(info.Name(), namePattern) {
|
||||||
|
relPath, relErr := makeRelativePath(hc.Dir, p)
|
||||||
|
if relErr != nil {
|
||||||
|
return relErr
|
||||||
|
}
|
||||||
|
systemdFiles = append(systemdFiles, relPath)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("files-find-systemd: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputFiles(hc, systemdFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
func filesFindSystemdUserCmd(hc interp.HandlerContext, cmd string, args []string) error {
|
||||||
|
namePattern := "*"
|
||||||
|
if len(args) > 0 {
|
||||||
|
namePattern = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
systemdUserPath := "./usr/lib/systemd/user/"
|
||||||
|
realPath := path.Join(hc.Dir, systemdUserPath)
|
||||||
|
|
||||||
|
if err := validateDir(realPath, "files-find-systemd-user"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var systemdUserFiles []string
|
||||||
|
err := filepath.Walk(realPath, func(p string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !info.IsDir() && matchNamePattern(info.Name(), namePattern) {
|
||||||
|
relPath, relErr := makeRelativePath(hc.Dir, p)
|
||||||
|
if relErr != nil {
|
||||||
|
return relErr
|
||||||
|
}
|
||||||
|
systemdUserFiles = append(systemdUserFiles, relPath)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("files-find-systemd-user: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputFiles(hc, systemdUserFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
func filesFindLicenseCmd(hc interp.HandlerContext, cmd string, args []string) error {
|
||||||
|
namePattern := "*"
|
||||||
|
if len(args) > 0 {
|
||||||
|
namePattern = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
licensePath := "./usr/share/licenses/"
|
||||||
|
realPath := path.Join(hc.Dir, licensePath)
|
||||||
|
|
||||||
|
if err := validateDir(realPath, "files-find-license"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var licenseFiles []string
|
||||||
|
err := filepath.Walk(realPath, func(p string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !info.IsDir() && matchNamePattern(info.Name(), namePattern) {
|
||||||
|
relPath, relErr := makeRelativePath(hc.Dir, p)
|
||||||
|
if relErr != nil {
|
||||||
|
return relErr
|
||||||
|
}
|
||||||
|
licenseFiles = append(licenseFiles, relPath)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("files-find-license: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputFiles(hc, licenseFiles)
|
||||||
|
}
|
||||||
|
@@ -56,30 +56,36 @@ var Helpers = handlers.ExecFuncs{
|
|||||||
"install-library": installLibraryCmd,
|
"install-library": installLibraryCmd,
|
||||||
"git-version": gitVersionCmd,
|
"git-version": gitVersionCmd,
|
||||||
|
|
||||||
"files-find": filesFindCmd,
|
"files-find": filesFindCmd,
|
||||||
"files-find-lang": filesFindLangCmd,
|
"files-find-lang": filesFindLangCmd,
|
||||||
"files-find-doc": filesFindDocCmd,
|
"files-find-doc": filesFindDocCmd,
|
||||||
"files-find-bin": filesFindBinCmd,
|
"files-find-bin": filesFindBinCmd,
|
||||||
"files-find-lib": filesFindLibCmd,
|
"files-find-lib": filesFindLibCmd,
|
||||||
"files-find-include": filesFindIncludeCmd,
|
"files-find-include": filesFindIncludeCmd,
|
||||||
"files-find-share": filesFindShareCmd,
|
"files-find-share": filesFindShareCmd,
|
||||||
"files-find-man": filesFindManCmd,
|
"files-find-man": filesFindManCmd,
|
||||||
"files-find-config": filesFindConfigCmd,
|
"files-find-config": filesFindConfigCmd,
|
||||||
|
"files-find-systemd": filesFindSystemdCmd,
|
||||||
|
"files-find-systemd-user": filesFindSystemdUserCmd,
|
||||||
|
"files-find-license": filesFindLicenseCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restricted contains restricted read-only helper commands
|
// Restricted contains restricted read-only helper commands
|
||||||
// that don't modify any state
|
// that don't modify any state
|
||||||
var Restricted = handlers.ExecFuncs{
|
var Restricted = handlers.ExecFuncs{
|
||||||
"git-version": gitVersionCmd,
|
"git-version": gitVersionCmd,
|
||||||
"files-find": filesFindCmd,
|
"files-find": filesFindCmd,
|
||||||
"files-find-lang": filesFindLangCmd,
|
"files-find-lang": filesFindLangCmd,
|
||||||
"files-find-doc": filesFindDocCmd,
|
"files-find-doc": filesFindDocCmd,
|
||||||
"files-find-bin": filesFindBinCmd,
|
"files-find-bin": filesFindBinCmd,
|
||||||
"files-find-lib": filesFindLibCmd,
|
"files-find-lib": filesFindLibCmd,
|
||||||
"files-find-include": filesFindIncludeCmd,
|
"files-find-include": filesFindIncludeCmd,
|
||||||
"files-find-share": filesFindShareCmd,
|
"files-find-share": filesFindShareCmd,
|
||||||
"files-find-man": filesFindManCmd,
|
"files-find-man": filesFindManCmd,
|
||||||
"files-find-config": filesFindConfigCmd,
|
"files-find-config": filesFindConfigCmd,
|
||||||
|
"files-find-systemd": filesFindSystemdCmd,
|
||||||
|
"files-find-systemd-user": filesFindSystemdUserCmd,
|
||||||
|
"files-find-license": filesFindLicenseCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
func installHelperCmd(prefix string, perms os.FileMode) handlers.ExecFunc {
|
func installHelperCmd(prefix string, perms os.FileMode) handlers.ExecFunc {
|
||||||
|
@@ -27,9 +27,9 @@ import (
|
|||||||
|
|
||||||
// createDir создает директорию с правильными правами для production
|
// createDir создает директорию с правильными правами для production
|
||||||
func createDir(itemPath string, mode os.FileMode) error {
|
func createDir(itemPath string, mode os.FileMode) error {
|
||||||
// Используем специальную функцию для создания каталогов с setgid битом только для /tmp/alr
|
// Используем специальную функцию для создания каталогов с setgid битом только для /tmp/alr/ и /var/cache/alr/
|
||||||
// В остальных случаях используем обычное создание директории
|
// Проверяем с слешем в конце, чтобы исключить тестовые директории вроде /tmp/alr-test-XXX
|
||||||
if strings.HasPrefix(itemPath, "/tmp/alr") {
|
if strings.HasPrefix(itemPath, "/tmp/alr/") || strings.HasPrefix(itemPath, "/var/cache/alr/") {
|
||||||
return utils.EnsureTempDirWithRootOwner(itemPath, mode)
|
return utils.EnsureTempDirWithRootOwner(itemPath, mode)
|
||||||
} else {
|
} else {
|
||||||
return os.MkdirAll(itemPath, mode)
|
return os.MkdirAll(itemPath, mode)
|
||||||
|
Reference in New Issue
Block a user