commit fa48702
chld
·
2026-02-07 16:41:26 +0000 UTC
parent 7810f6c
why is deps appendig
2 files changed,
+20,
-9
M
main.go
M
main.go
+19,
-4
1@@ -21,13 +21,13 @@ func help() {
2 // package mamagement
3 fmt.Printf("\t")
4 fmt.Printf("\033[m\033[1m%s \033[m\033[32m", filepath.Base(os.Args[0]))
5- fmt.Printf("[m]")
6+ fmt.Printf("[m|i|c|r]")
7 fmt.Printf("\033[m\t\tmanage ports\n")
8
9 // package management without compiling
10 fmt.Printf("\t")
11 fmt.Printf("\033[m\033[1m%s \033[m\033[32m", filepath.Base(os.Args[0]))
12- fmt.Printf("[sp|ld]")
13+ fmt.Printf("[sp|ld|li]")
14 fmt.Printf("\033[m\t\tmanage ports tree\n")
15
16 // misc
17@@ -56,8 +56,9 @@ func main() {
18 cr("DTR_DIR", "/ports")
19 cr("DTR_ROOT", "/")
20 cr("DTR_DB", "/var/db/dtr")
21- if _, err := os.Stat(filepath.Join(os.Getenv("DTR_DB"), "installed")); err != nil {
22- os.Create(filepath.Join(os.Getenv("DTR_DB"), "installed"))
23+ pki := filepath.Join(os.Getenv("DTR_DB"), "installed")
24+ if _, err := os.Stat(pki); err != nil {
25+ os.Create(pki)
26 }
27
28 act := os.Args[1]
29@@ -99,6 +100,20 @@ func main() {
30 continue
31 }
32 }
33+ case "li":
34+ f, err := os.ReadFile(pki)
35+ if err != nil {
36+ dgr.Die("could not read from file", pki, 1)
37+ } else if string(f) == "" {
38+ dgr.Die("file is empty", pki, 1)
39+ }
40+ dgr.Msg("installed ", filepath.Base(os.Args[0]), " packages:")
41+ fx := strings.Fields(string(f))
42+
43+ for i := range len(fx) {
44+ fmt.Printf("\t%s\n", string(fx[i]))
45+ }
46+
47 case "s":
48 dgr.Msg("cloning", "codeberg.org/derivelinux/ports")
49 os.RemoveAll(os.Getenv("DTR_DIR"))
+1,
-5
1@@ -34,11 +34,7 @@ func DepRes(pkg string) []string {
2 installedPath := filepath.Join(os.Getenv("DTR_DB"), "installed")
3 installed, _ := os.ReadFile(installedPath)
4
5- inst := string(installed) + "new content" // whatever you want to append
6-
7- in, _ := os.OpenFile(installedPath, os.O_WRONLY|os.O_TRUNC, 0644) // truncate if needed
8- defer in.Close()
9- in.WriteString(inst)
10+ inst := string(installed)
11
12 var out []string
13 for _, dep := range nf {