Coverage report: /home/ellis/comp/core/lib/box/archiso.lisp

KindCoveredAll%
expression070 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; box/archiso.lisp --- archiso installation interface
2
 
3
 ;;
4
 
5
 ;;; Code:
6
 (in-package :box/archiso)
7
 
8
 #| default config
9
 {
10
     "__separator__": null,
11
     "additional-repositories": [],
12
     "archinstall-language": "English",
13
     "audio_config": null,
14
     "bootloader": "Systemd-boot",
15
     "config_version": "2.6.0",
16
     "debug": false,
17
     "disk_config": {
18
         "config_type": "manual_partitioning",
19
         "device_modifications": [
20
             {
21
                 "device": "/dev/sda",
22
                 "partitions": [
23
                     {
24
                         "btrfs": [],
25
                         "flags": [
26
                             "Boot"
27
                         ],
28
                         "fs_type": "fat32",
29
                         "length": {
30
                             "sector_size": null,
31
                             "total_size": null,
32
                             "unit": "B",
33
                             "value": 99982592
34
                         },
35
                         "mount_options": [],
36
                         "mountpoint": "/boot",
37
                         "obj_id": "369f31a8-2781-4d6b-96e7-75680552b7c9",
38
                         "start": {
39
                             "sector_size": {
40
                                 "sector_size": null,
41
                                 "total_size": null,
42
                                 "unit": "B",
43
                                 "value": 512
44
                             },
45
                             "total_size": null,
46
                             "unit": "sectors",
47
                             "value": 34
48
                         },
49
                         "status": "create",
50
                         "type": "primary"
51
                     },
52
                     {
53
                         "btrfs": [],
54
                         "flags": [],
55
                         "fs_type": "fat32",
56
                         "length": {
57
                             "sector_size": null,
58
                             "total_size": null,
59
                             "unit": "B",
60
                             "value": 100000000
61
                         },
62
                         "mount_options": [],
63
                         "mountpoint": "/efi",
64
                         "obj_id": "13cf2c96-8b0f-4ade-abaa-c530be589aad",
65
                         "start": {
66
                             "sector_size": {
67
                                 "sector_size": null,
68
                                 "total_size": null,
69
                                 "unit": "B",
70
                                 "value": 512
71
                             },
72
                             "total_size": {
73
                                 "sector_size": null,
74
                                 "total_size": null,
75
                                 "unit": "B",
76
                                 "value": 16106127360
77
                             },
78
                             "unit": "MB",
79
                             "value": 100
80
                         },
81
                         "status": "create",
82
                         "type": "primary"
83
                     },
84
                     {
85
                         "btrfs": [],
86
                         "flags": [],
87
                         "fs_type": "ext4",
88
                         "length": {
89
                             "sector_size": null,
90
                             "total_size": null,
91
                             "unit": "B",
92
                             "value": 15805127360
93
                         },
94
                         "mount_options": [],
95
                         "mountpoint": "/",
96
                         "obj_id": "3e75d045-21a4-429d-897e-8ec19a006e8b",
97
                         "start": {
98
                             "sector_size": {
99
                                 "sector_size": null,
100
                                 "total_size": null,
101
                                 "unit": "B",
102
                                 "value": 512
103
                             },
104
                             "total_size": {
105
                                 "sector_size": null,
106
                                 "total_size": null,
107
                                 "unit": "B",
108
                                 "value": 16106127360
109
                             },
110
                             "unit": "MB",
111
                             "value": 301
112
                         },
113
                         "status": "create",
114
                         "type": "primary"
115
                     }
116
                 ],
117
                 "wipe": false
118
             }
119
         ]
120
     },
121
     "disk_encryption": {
122
         "encryption_type": "luks",
123
         "partitions": [
124
             "3e75d045-21a4-429d-897e-8ec19a006e8b"
125
         ]
126
     },
127
     "hostname": "archlinux",
128
     "kernels": [
129
         "linux"
130
     ],
131
     "locale_config": {
132
         "kb_layout": "us",
133
         "sys_enc": "UTF-8",
134
         "sys_lang": "en_US"
135
     },
136
     "mirror_config": {
137
         "custom_mirrors": [],
138
         "mirror_regions": {
139
             "Sweden": [
140
                 "https://mirror.osbeck.com/archlinux/$repo/os/$arch",
141
                 "https://mirror.bahnhof.net/pub/archlinux/$repo/os/$arch",
142
                 "https://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch",
143
                 "https://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch",
144
                 "https://ftp.ludd.ltu.se/mirrors/archlinux/$repo/os/$arch",
145
                 "https://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch",
146
                 "http://mirror.bahnhof.net/pub/archlinux/$repo/os/$arch",
147
                 "http://ftpmirror.infania.net/mirror/archlinux/$repo/os/$arch",
148
                 "http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch",
149
                 "http://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch",
150
                 "http://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch"
151
             ]
152
         }
153
     },
154
     "network_config": {},
155
     "no_pkg_lookups": false,
156
     "ntp": true,
157
     "offline": false,
158
     "packages": [],
159
     "parallel downloads": 0,
160
     "profile_config": null,
161
     "save_config": null,
162
     "script": "guided",
163
     "silent": false,
164
     "swap": true,
165
     "timezone": "UTC",
166
     "version": "2.6.0"
167
 }
168
 |#
169
 
170
 #|
171
 (dat/proto:serialize
172
 '(("__separator__" NIL) ("additional-repositories" NIL)
173
  ("archinstall-language" "English") ("audio_config" NIL)
174
  ("bootloader" "Systemd-boot") ("config_version" "2.6.0")
175
  ("debug" NIL) ("disk_config" nil)
176
  ("disk_encryption" nil)
177
  ("hostname" "archlinux") ("kernels" ("linux"))
178
  ("locale_config" nil)
179
  ("mirror_config" nil)
180
  ("network_config" nil)
181
  ("no_pkg_lookups" NIL) ("ntp" T) ("offline" NIL) ("packages" NIL)
182
  ("parallel downloads" 0) ("profile_config" NIL)
183
  ("save_config" NIL) ("script" "guided") ("silent" NIL) ("swap" T)
184
   ("timezone" "UTC") ("version" "2.6.0"))
185
 :json)
186
 |#
187
 
188
 #|
189
 profile/
190
 ├── airootfs/
191
 ├── efiboot/
192
 ├── syslinux/
193
 ├── grub/
194
 ├── bootstrap_packages.arch
195
 ├── packages.arch
196
 ├── pacman.conf
197
 └── profiledef.sh
198
 |#
199
 ;;; Types
200
 (deftype archiso-profile-designator () '(member :releng :baseline))
201
 (deftype airootfs-image-type () '(member :squashfs :ext4+squashfs :erofs))
202
 (deftype archiso-build-mode () '(member :bootstrap :iso :netboot))
203
 (deftype archiso-boot-mode () 
204
   '(member 
205
     :bios.syslinux.mbr
206
     :bios.syslinux.eltorito
207
     :uefi-ia32.grub.esp
208
     :uefi.ia32.grub.eltorito
209
     :uefi-x64.grub.esp
210
     :uefi-x64.grub.eltorito
211
     :uefi-ia32.systemd-boot.esp
212
     :uefi-ia32.systemd-boot.eltorito
213
     :uefi-x64.systemd-boot.esp
214
     :uefi-x64.systemd-boot.eltorito))
215
 
216
 ;;; Vars
217
 (defvar *archiso-config*)
218
 
219
 (defvar *archiso-creds*)
220
 
221
 (declaim (archiso-profile-designator *default-archiso-profile*))
222
 (defvar *default-archiso-profile* :releng)
223
 
224
 ;; TODO 2024-05-31: 
225
 ;;; Config
226
 (defconfig archiso-config (box-config)
227
   ((config-version :initform "2.6.0" :type string)
228
    (hostname :type string)
229
    (kernels :initform '("linux") :type list)
230
    locale-config
231
    mirror-config
232
    network-config
233
    (no-pkg-lookups :initform nil :type boolean)
234
    (ntp :initform t :type boolean)
235
    network
236
    (offline :initform nil :type boolean)
237
    packages
238
    (archinstall-language :initform "English" :type string)
239
    (bootloader :initform "Systemd-boot" :type string)
240
    (debug :initform nil :type boolean)
241
    parallel-downloads
242
    disk-config
243
    disk-encryption
244
    profile-config
245
    save-config
246
    audio-config
247
    (additional-repositories :initform nil :type list)
248
    script
249
    silent
250
    (swap :initform t :type boolean)
251
    timezone
252
    (version :initform "2.6.0" :type string)))
253
 
254
 ;;; CLI
255
 (defun mkarchiso (profile-dir 
256
                   &key config install-dir out-dir work-dir
257
                        application label publisher
258
                        cert gpg mbox modes packages
259
                        delete verbose output)
260
   (sb-ext:run-program 
261
    (cli:find-exe "mkarchiso") 
262
    `(,@(when config `("-C" ,config))
263
      ,@(when install-dir `("-D" ,install-dir))
264
      ,@(when out-dir `("-o" ,out-dir))
265
      ,@(when work-dir `("-w" ,work-dir))
266
      ,@(when application `("-A" ,application))
267
      ,@(when label `("-L" ,label))
268
      ,@(when publisher `("-P" ,publisher))
269
      ,@(when cert `("-c" ,cert))
270
      ,@(when gpg `("-g" ,gpg))
271
      ,@(when mbox `("-G" ,mbox))
272
      ,@(when modes `("-m" ,@modes))
273
      ,@(when packages `("-p" ,@packages))
274
      ,@(when delete '("-r"))
275
      ,@(when verbose '("-v"))
276
      ,profile-dir)
277
    :output output))
278
 
279
 (defun run-archiso (iso &key (uefi t) additional-iso vnc secure-boot disk accessibility (output t))
280
   (sb-ext:run-program 
281
    (cli:find-exe "run_archiso")
282
    `("-i" ,iso
283
      ,@(when uefi '("-u"))
284
      ,@(when additional-iso `("-c" ,additional-iso))
285
      ,@(when vnc '("-v"))
286
      ,@(when secure-boot '("-s"))
287
      ,@(when disk '("-d"))
288
      ,@(when accessibility '("-a")))
289
    :output output))
290
 
291
 ������������������������������������������������