Skip to content

Commit 206877e

Browse files
committed
Update: Add package list
1 parent d6432fc commit 206877e

7 files changed

Lines changed: 196 additions & 7 deletions

File tree

alteriso5/cmd/build.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/build"
5-
"github.com/Hayao0819/nahi/cobrautils"
65
)
76

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

alteriso5/config/pkg/package.go

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"log/slog"
55
"os"
66
"path"
7+
"strings"
78

9+
"github.com/FascodeNet/alterlinux/alteriso5/utils"
810
"github.com/Hayao0819/nahi/osutils"
911
)
1012

@@ -38,7 +40,7 @@ func FindPkgListFiles(profile string, arch string) ([]string, error) {
3840
slog.Debug("Found pkglist", "files", files)
3941
for _, f := range files {
4042
p := path.Join(profile, d, f.Name())
41-
slog.Info("Found pkglist", "file",p)
43+
slog.Info("Found pkglist", "file", p)
4244
findFiles = append(findFiles, p)
4345
}
4446
}
@@ -54,3 +56,41 @@ func FindPkgListFiles(profile string, arch string) ([]string, error) {
5456

5557
return retunPaths, nil
5658
}
59+
60+
func ReadPkgListFile(file string) ([]string, error) {
61+
pkgs := []string{}
62+
63+
lines, err := utils.ReadFileLine(file)
64+
if err != nil {
65+
return nil, err
66+
}
67+
68+
for _, l := range lines {
69+
if l == "" || strings.HasPrefix(l, "#") {
70+
continue
71+
}
72+
pkgs = append(pkgs, l)
73+
}
74+
75+
return pkgs, nil
76+
}
77+
78+
func GetPkgList(profile string, arch string) ([]string, error) {
79+
files, err := FindPkgListFiles(profile, arch)
80+
if err != nil {
81+
return nil, err
82+
}
83+
84+
pkgs := []string{}
85+
86+
for _, f := range files {
87+
p, err := ReadPkgListFile(f)
88+
if err != nil {
89+
return nil, err
90+
}
91+
92+
pkgs = append(pkgs, p...)
93+
}
94+
95+
return pkgs, nil
96+
}

alteriso5/config/profile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/json"
55
"os"
66
"path"
7+
8+
"github.com/FascodeNet/alterlinux/alteriso5/config/pkg"
79
)
810

911
type Profile struct {
@@ -31,3 +33,7 @@ func ReadProfile(dir string) (*Profile, error) {
3133

3234
return &new, nil
3335
}
36+
37+
func (p *Profile) GetPkgList(arch string) ([]string, error) {
38+
return pkg.GetPkgList(p.Base,arch)
39+
}

alteriso5/work/airootfs/chroot.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package airootfs
22

33
import (
4+
"log/slog"
45
"os"
56
"os/exec"
67
)
@@ -34,12 +35,17 @@ func GetChrootDir(dir, arch string) (*Chroot, error) {
3435
return &env, nil
3536
}
3637

37-
func (e *Chroot) Init() error {
38+
func (e *Chroot) Init(pkgs ...string) error {
3839
if err := os.MkdirAll(e.Dir, 0755); err != nil {
3940
return err
4041
}
4142

42-
pacstrap := exec.Command("pacstrap", "-c", e.Dir, "base", "base-devel", "linux", "linux-firmware", "syslinux", "mkinitcpio-archiso")
43+
args := []string{"-c", e.Dir}
44+
args = append(args, pkgs...)
45+
46+
slog.Debug("pacstrap", "args", args)
47+
48+
pacstrap := exec.Command("pacstrap", args...)
4349
pacstrap.Env = append(os.Environ(), "LANG=C")
4450
pacstrap.Stdout = os.Stdout
4551
pacstrap.Stderr = os.Stderr

alteriso5/work/buildtask.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package work
22

33
import (
44
"fmt"
5+
"log/slog"
56
)
67

78
type BuildTask struct {
@@ -21,6 +22,8 @@ func (t *BuildTask) Name() string {
2122
}
2223

2324
func (t *BuildTask) Run(w *Work) error {
25+
slog.Info("Running task", "name", t.name)
26+
2427
err := t.task(*w)
2528
if err != nil {
2629
return fmt.Errorf("error running task %s: %v", t.name, err)

alteriso5/work/task-init.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var makeCustomAirootfs *BuildTask = NewBuildTask("makeCustomAirootfs", func(w Wo
2929
if err := cp.Copy(profileAirootfsDir, w.GetDirs().Pacstrap, cp.Options{
3030
PreserveOwner: true,
3131
Sync: true,
32-
3332
}); err != nil {
3433
return err
3534
}
@@ -42,9 +41,14 @@ var makeChroot *BuildTask = NewBuildTask("makeChroot", func(work Work) error {
4241
env, err := work.GetChroot()
4342
if err != nil {
4443
return err
44+
}
4545

46+
pkglist, err := work.profile.GetPkgList(work.target.Arch)
47+
if err != nil {
48+
return err
4649
}
47-
if err := env.Init(); err != nil {
50+
51+
if err := env.Init(pkglist...); err != nil {
4852
return err
4953

5054
}

profile/packages.x86_64

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
alsa-utils
2+
amd-ucode
3+
arch-install-scripts
4+
archinstall
5+
b43-fwcutter
6+
base
7+
bcachefs-tools
8+
bind
9+
bolt
10+
brltty
11+
broadcom-wl
12+
btrfs-progs
13+
clonezilla
14+
cloud-init
15+
cryptsetup
16+
darkhttpd
17+
ddrescue
18+
dhclient
19+
dhcpcd
20+
diffutils
21+
dmidecode
22+
dmraid
23+
dnsmasq
24+
dosfstools
25+
e2fsprogs
26+
edk2-shell
27+
efibootmgr
28+
espeakup
29+
ethtool
30+
exfatprogs
31+
f2fs-tools
32+
fatresize
33+
foot-terminfo
34+
fsarchiver
35+
gnu-netcat
36+
gpart
37+
gpm
38+
gptfdisk
39+
grml-zsh-config
40+
grub
41+
hdparm
42+
hyperv
43+
intel-ucode
44+
irssi
45+
iw
46+
iwd
47+
jfsutils
48+
kitty-terminfo
49+
ldns
50+
less
51+
lftp
52+
libfido2
53+
libusb-compat
54+
linux
55+
linux-atm
56+
linux-firmware
57+
linux-firmware-marvell
58+
livecd-sounds
59+
lsscsi
60+
lvm2
61+
lynx
62+
man-db
63+
man-pages
64+
mc
65+
mdadm
66+
memtest86+
67+
memtest86+-efi
68+
mkinitcpio
69+
mkinitcpio-archiso
70+
mkinitcpio-nfs-utils
71+
modemmanager
72+
mtools
73+
nano
74+
nbd
75+
ndisc6
76+
nfs-utils
77+
nilfs-utils
78+
nmap
79+
ntfs-3g
80+
nvme-cli
81+
open-iscsi
82+
open-vm-tools
83+
openconnect
84+
openpgp-card-tools
85+
openssh
86+
openvpn
87+
partclone
88+
parted
89+
partimage
90+
pcsclite
91+
ppp
92+
pptpclient
93+
pv
94+
qemu-guest-agent
95+
refind
96+
reflector
97+
reiserfsprogs
98+
rp-pppoe
99+
rsync
100+
rxvt-unicode-terminfo
101+
screen
102+
sdparm
103+
sequoia-sq
104+
sg3_utils
105+
smartmontools
106+
sof-firmware
107+
squashfs-tools
108+
sudo
109+
syslinux
110+
systemd-resolvconf
111+
tcpdump
112+
terminus-font
113+
testdisk
114+
tmux
115+
tpm2-tools
116+
tpm2-tss
117+
udftools
118+
usb_modeswitch
119+
usbmuxd
120+
usbutils
121+
vim
122+
virtualbox-guest-utils-nox
123+
vpnc
124+
wezterm-terminfo
125+
wireless-regdb
126+
wireless_tools
127+
wpa_supplicant
128+
wvdial
129+
xfsprogs
130+
xl2tpd
131+
zsh

0 commit comments

Comments
 (0)