abstract [This module will install a ready to operate FullPliant system.]
module "/pliant/language/context.pli" module "/pliant/language/stream.pli" module "/pliant/admin/file.pli" module "/pliant/admin/execute.pli" module "/pliant/admin/shell.pli" module "/pliant/linux/kernel/module.pli" module "/pliant/linux/kernel/device.pli" module "/pliant/linux/storage/partition.pli" module "/pliant/linux/storage/raid.pli" module "/pliant/linux/storage/filesystem.pli" module "/pliant/linux/storage/cdrom.pli" module "/pliant/linux/kernel/library.pli"
module "/pliant/protocol/http/site.pli" module "/pliant/protocol/dns/name.pli" module "/pliant/util/crypto/rsa.pli"
|
module "/pliant/util/crypto/legal.pli"
|
module "/pliant/fullpliant/user.pli"
module "/pliant/language/stream/filesystembase.pli" module "/pliant/language/stream/multi.pli"
module "kernel.pli" module "debian.pli" module "embedded/install.pli" submodule "computer.pli"
public constant fullpliant_source_path "file:/fullpliant/unix/src/" constant fullpliant_binary_path "file:/fullpliant/unix/bin/"
#--------------------------------------------------------------------
function grub_copy path arg Str path file_tree_copy "file:/usr/share/grub/i386-pc/" path+"boot/grub/" file_tree_copy "file:/usr/lib/grub/i386-pc/" path+"boot/grub/"
|
file_tree_copy "file:/lib/grub/i386-pc/" path+"boot/grub/"
|
file_tree_copy "file:/boot/grub/" path+"boot/grub/"
function grub_install root_path grub_boot_drive grub_boot_partition -> status arg Str root_path grub_boot_drive grub_boot_partition ; arg Status status var Str temp := file_temporary (var Stream kbd) open temp out+safe kbd writeline "root ("+grub_boot_partition+")"
|
var Str stage1 := shunt (grub_boot_drive parse "fd" any) "stage1" "stage1_lba"
|
var Str stage1 := "stage1" # shunt (grub_boot_drive parse "fd" any) "stage1" "stage1_lba"
|
var Str stage2 := "stage2" kbd writeline "install /boot/grub/"+stage1+" ("+grub_boot_drive+") /boot/grub/"+stage2+" p" kbd writeline "quit" kbd close
|
var Int err := execute "grub --batch" input temp quiet
|
var Int err := execute "grub --batch" input temp # quiet
|
file_delete temp status := shunt err=0 success failure
function grub_configure c root_path grub_boot_drive grub_boot_partition kernel_root kernel_options grub_options arg Data:Computer c ; arg Str root_path grub_boot_drive grub_boot_partition ; arg Str kernel_root kernel_options grub_options (var Stream menu) open root_path+"boot/grub/menu.lst" out+safe+mkdir menu writeline "timeout 2" menu writeline "title FullPliant" menu writeline "root ("+grub_boot_partition+")"
|
menu writeline "kernel /boot/kernel root="+file_os_name:kernel_root+(shunt kernel_options<>"" " " "")+kernel_options
|
if (file_query root_path+"boot/initrd.img" standard)=success menu writeline "kernel /boot/kernel root=/dev/ram0"+(shunt kernel_options<>"" " " "")+kernel_options menu writeline "initrd /boot/initrd.img" else menu writeline "kernel /boot/kernel root="+file_os_name:kernel_root+(shunt kernel_options<>"" " " "")+kernel_options each p c:env:"partition" filter keyof:p<>"root" if p:"os"<>"" and (p:"device" parse any (var Int i)) menu writeline "title "+keyof:p menu writeline "rootnoverify (hd0,"+(string i-1)+")" menu writeline "makeactive" menu writeline "chainloader +1"
|
menu close
function lilo_install c root_path lilo_boot_device kernel_root kernel_options lilo_options -> status arg Data:Computer c ; arg Str root_path lilo_boot_device kernel_root kernel_options lilo_options ; arg Status status (var Stream s) open root_path+"boot/lilo.conf" out+safe if s=failure console "Failed to create lilo configuration file" eol return failure
|
s writeline "read-only"
|
s writeline "ignore-table" s writeline "boot="+file_os_name:lilo_boot_device
|
s writeline "delay=50" s writeline "lock"
|
s writeline "boot="+file_os_name:lilo_boot_device
|
s writeline "read-only"
|
s writeline "image=/boot/kernel" s writeline " label=fullpliant"
|
s writeline " root="+file_os_name:kernel_root
|
if (file_query root_path+"boot/initrd.img" standard)=success s writeline " initrd=/boot/initrd.img" s writeline " root=/dev/ram0" else s writeline " root="+file_os_name:kernel_root
|
s writeline " append=[dq]"+kernel_options+"[dq]" if c:env:"partition":"root":"video_bios_mode"<>"" s writeline " vga="+c:env:"partition":"root":"video_bios_mode" eif c:env:"hardware":"video":"bios_mode"<>"" s writeline " vga="+c:env:"hardware":"video":"bios_mode" if (file_query root_path+"boot/recover" standard)=defined s writeline "image=/boot/recover" s writeline " label=recover" s writeline " root="+file_os_name:kernel_root s writeline " append=[dq]"+kernel_options+"[dq]" if c:env:"partition":"root":"video_bios_mode"<>"" s writeline " vga="+c:env:"partition":"root":"video_bios_mode" eif c:env:"hardware":"video":"bios_mode"<>"" s writeline " vga="+c:env:"hardware":"video":"bios_mode"
|
if (file_query root_path+"boot/once" standard)=defined s writeline "image=/boot/once" s writeline " label=once" s writeline " root="+file_os_name:kernel_root s writeline " append=[dq]"+kernel_options+"[dq]" if c:env:"partition":"root":"video_bios_mode"<>"" s writeline " vga="+c:env:"partition":"root":"video_bios_mode" eif c:env:"hardware":"video":"bios_mode"<>"" s writeline " vga="+c:env:"hardware":"video":"bios_mode"
|
each p c:env:"partition" filter keyof:p<>"root" if p:"kernel"<>"" if (filesystem_mount p:"device" "file:/mnt/"+keyof:p+"/" "nocheck")=failure console "Failed to mount " p:"device" " partition" eol s writeline "image=/mnt/"+keyof:p+"/boot/"+p:"kernel" s writeline " label="+keyof:p s writeline " root="+(file_os_name p:"device") s writeline " append=[dq]"+p:"kernel_options"+"[dq]" if p:"video_bios_mode"<>"" s writeline " vga="+p:"video_bios_mode" eif c:env:"hardware":"video":"bios_mode"<>"" s writeline " vga="+c:env:"hardware":"video":"bios_mode" eif p:"os"<>""
|
s writeline "other="+(file_os_name p:"device") s writeline " label="+keyof:p
|
(var Stream disk) open p:"device" in+safe var Str sector := repeat 512 " " disk raw_read sector:characters sector:len disk close if sector:1FEh=character:55h and sector:1FFh=character:0AAh s writeline "other="+(file_os_name p:"device") s writeline " label="+keyof:p s writeline " optional"
|
if (file_query root_path+"boot/memtest86.bin" standard)=success s writeline "image=/boot/memtest86.bin" s writeline " label=memtest" s close var Str flags := "" var Str geometry := lilo_options option "geometry" Str flags += (shunt geometry="chs" "" geometry="lba32" " -L" " -l") var Int err := execute "lilo -C /boot/lilo.conf"+flags root root_path if err<>0 and geometry="" err := execute "lilo -C /boot/lilo.conf -L" root root_path if err<>0 and geometry="" err := execute "lilo -C /boot/lilo.conf" root root_path # file_delete root_path+"boot/lilo.conf" each p c:env:"partition" if p:"kernel"<>"" filesystem_dismount "file:/mnt/"+keyof:p+"/" status := shunt err=0 success failure
|
if status=success and (file_query root_path+"boot/once" standard)=defined execute "lilo -C /boot/lilo.conf -R once" file_delete "file:/boot/twice" file_move "file:/boot/once" "file:/boot/twice"
|
function update_rights c root_path arg Data:Computer c ; arg Str root_path file_tree_rights root_path+"bin/" undefined undefined 8^2 0 0 0 file_tree_rights root_path+"pliant/binary/" undefined undefined 8^2 0 0 0 var Array:FileInfo files := file_list root_path+"pliant/binary/" standard for (var Int i) 0 files:size-1 if files:i:extension=".dump" file_delete files:i:name
export grub_copy grub_install grub_configure lilo_install update_rights
#--------------------------------------------------------------------
|
function install_initrd c path loindex -> status arg Data:Computer c ; arg Str path ; arg Int loindex ; arg ExtendedStatus status kernel_make_device path+"dev/ram0" var Str temp := file_temporary (var Stream s) open temp out+safe var Address buf := memory_zallocate 1024 null for (var Int i) 0 1023 s raw_write buf 1024 s close memory_free buf partition_format temp "ext2" "standard" kernel_load_module "loop" kernel_make_device "device:/loop"+string:loindex execute "losetup /dev/loop"+string:loindex+" "+file_os_name:temp if (filesystem_mount "device:/loop"+string:loindex "file:/mnt/loop/" "")=failure return failure:"Failed to mount initrd image (maybe loopback device is not supported by this kernel)" if (file_copy fullpliant_binary_path+"linuxrc" "file:/mnt/loop/bin/init" extended)=failure filesystem_dismount "file:/mnt/loop/" return failure:"Failed to build /linuxrc" kernel_make_device "file:/mnt/loop/dev/console" kernel_make_device "file:/mnt/loop/dev/tty0" for (var Int i) 0 3 kernel_make_device "file:/mnt/loop/dev/hd"+(character "a":number+i) for (var Int i) 0 11 kernel_make_device "file:/mnt/loop/dev/sd"+(character "a":number+i) file_tree_create "file:/mnt/loop/mnt/root/" filesystem_dismount "file:/mnt/loop/" execute "losetup -d /dev/loop"+string:loindex file_copy temp "gzip:"+path+"boot/initrd.img" reduced file_delete temp file_tree_create path+"mnt/initrd/" status := success
#--------------------------------------------------------------------
|
function copy_floppy src_name dest_name -> status arg Str src_name dest_name ; arg Status status (var Stream src) open src_name in+nocache+safe if src=failure return failure (var Stream dest) open dest_name out+nocache+safe var Address buffer := memory_zallocate 512 null for (var Int i) 1 2880 src raw_read buffer 512 dest raw_write buffer 512 status := shunt src=success and dest=success success failure src close ; dest close if status=failure and not (dest_name parse "device:" any) file_delete dest_name
function build_grub_floppy -> status arg ExtendedStatus status file_tree_create "file:/mnt/floppy/" filesystem_dismount "file:/mnt/floppy/" kernel_make_device "device:/fd0" copy_floppy "device:/zero" "device:/fd0" if (partition_format "device:/fd0" "ext2" "standard nocheck name [dq]FullPliant[dq]")=failure return failure:"Failed to format partition (maybe there is no floppy in the drive)" if (filesystem_mount "device:/fd0" "file:/mnt/floppy/" "")=failure return failure:"Failed to mount floppy" grub_copy "file:/mnt/floppy/" if (grub_install "file:/mnt/floppy/" "fd0" "fd0")=failure status := failure "Failed to install GRUB" else status := success filesystem_dismount "file:/mnt/floppy/" if status=success if (copy_floppy "device:/fd0" "file:/fullpliant/unix/bin/floppy")=failure status := failure "Failed to read the floppy"
function install_floppy c file kernel_root kernel_options -> status arg Data:Computer c ; arg Str file kernel_root kernel_options ; arg ExtendedStatus status kernel_load_module "floppy" if (file_query "file:/fullpliant/unix/bin/floppy" standard)=undefined status := build_grub_floppy if status=failure return if (file_copy "file:/fullpliant/unix/bin/floppy" file)=failure return failure:"No boot floppy image available" file_tree_create "file:/mnt/floppy/" filesystem_dismount "file:/mnt/floppy/" if (file parse "device:" any) if (filesystem_mount file "file:/mnt/floppy/" "")=failure return failure:"Failed to mount boot floppy image" else kernel_load_module "loop" kernel_make_device "device:/loop0" execute "losetup /dev/loop0"+" "+file_os_name:file if (filesystem_mount "device:/loop0" "file:/mnt/floppy/" "")=failure return failure:"Failed to mount boot floppy image (maybe loopback device is not supported by this kernel)"
|
grub_configure c "file:/mnt/floppy/" "fd0" "fd0" kernel_root kernel_options ""
|
var Str kversion := c:env:"kernel":"constant":"linux_version" var Str sign := c:env:"kernel":"constant":"signature" file_tree_delete "file:/tmp/kernel/" file_extract kernel_binary_path+"kernel-"+kversion+"-"+sign+".tgz" "file:/tmp/kernel/" if (file_copy "file:/tmp/kernel/boot/kernel" "file:/mnt/floppy/boot/kernel")=failure status := failure "The kernel image "+kversion+" "+sign+" is not available" else status := success file_tree_delete "file:/tmp/kernel/"
|
status := install_initrd c "file:/mnt/floppy/" 1 if status=failure return grub_configure c "file:/mnt/floppy/" "fd0" "fd0" kernel_root kernel_options ""
|
filesystem_dismount "file:/mnt/floppy/" if not (file parse "device:" any)
|
execute file_os_name:"embedded:/sbin/losetup"+" -d "+file_os_name:"embedded:/dev/loop0"
|
# execute file_os_name:"embedded:/sbin/losetup"+" -d "+file_os_name:"embedded:/dev/loop0" execute "losetup -d /dev/loop0"
|
export build_grub_floppy install_floppy
#--------------------------------------------------------------------
method p disk -> d arg DiskPartition p ; arg Str d if ((reverse p:device) parse (var Int num) any:d) d := reverse d else d := p device
export '. disk'
function enumerate_partitions c partitions disks arg Data:Computer c ; arg_rw Dictionary partitions disks partitions := var Dictionary empty_dictionary disks := var Dictionary empty_dictionary each pa c:env:"partition" var Pointer:DiskPartition p :> partitions kmap pa:"device" DiskPartition p name := keyof pa p device := pa "device" p raid_devices := pa "raid_devices" p mountpoint := pa "mountpoint" if (pa:"size_mb" parse (var Int mb)) p size := mb*2n^20 p filesystem := shunt pa:"filesystem"<>"" pa:"filesystem" "ext2" p options := pa "options"
|
if pa:"disk_image"<>"" p options += " disk_image "+(string pa:"disk_image")
|
disks kmap p:disk Str := p disk var Str devices := p raid_devices while devices<>"" if not (devices parse any:(var Str device) _ any:(var Str remain)) device := devices ; remain := "" var Str device := shunt (device search ":" -1)=(-1) "device:/"+device device var Pointer:DiskPartition p :> partitions kmap device DiskPartition p device := device p filesystem := "raid" disks kmap p:disk Str := p disk devices := remain disks remove "device:/md" null
function install_partition c name arg Data:Computer c ; arg Str name enumerate_partitions c (var Dictionary partitions) (var Dictionary disks) each d disks type Str if d=name or name="" (var Array:DiskPartition a) size := 0 for (var Int i) 1 16 each p partitions type DiskPartition if p:device=d+string:i # p:disk=d a += p if a:size>0 partition_create d a
function install_format c name -> status arg_rw Data:Computer c ; arg Str name ; arg Status status enumerate_partitions c (var Dictionary partitions) (var Dictionary disks) each p partitions type DiskPartition if name="" or name=p:name if p:raid_devices<>"" (var Raid raid) define p:device p:raid_devices p:options raid initialize status := partition_format p:device p:filesystem p:options+(shunt p:name<>"" " name "+(string p:name) "")
export enumerate_partitions install_partition install_format
#--------------------------------------------------------------------
function install_check_libraries binpath libpath -> status arg Str binpath libpath ; arg ExtendedStatus status status := success var Array:FileInfo bins := file_list binpath standard+relative for (var Int i) 0 bins:size-1 var List:Str libs := file_libraries (file_os_name binpath+bins:i:name) each lib libs if (file_query libpath+lib standard)=undefined console bins:i:name+" requires "+lib eol status := failure bins:i:name+" requires "+lib if status=failure console status:message eol
export install_check_libraries
#--------------------------------------------------------------------
function install_tree c path options -> status arg_rw Data:Computer c ; arg Str path options ; arg ExtendedStatus status if not exists:c return (failure "There is no "+keyof:c+" computer in the database.")
var Str distrib := c:env:"pliant":"system":"distribution"
|
if distrib<>"fullpliant"
|
if distrib<>"fullpliant" and not (options option "force")
|
return failure:"This script can only install a FullPliant system."
var Str medium := c:env:"pliant":"system":"medium" var Str this_medium := this_computer:env:"pliant":"system":"medium" var Bool static := c:env:"pliant":"fullpliant":"static"="true" if not (c:env:"pliant":"pliant":"debugging_level" parse (var Int debugging_level)) debugging_level := 1 pliant_multi_file_system mount "target:/" path pliant_default_file_system var Str security := shunt distrib="fullpliant" "target:/pliant_security/" "target:/etc/pliant/" var CBool keep_site_key := options option "keep_site_key" var CBool generate_site_key := options option "generate_site_key"
if keep_site_key console "Fetching the old site key" eol file_tree_create "target:/" file_extract "file:/fullpliant/archive/"+keyof:c+".tgz" "target:/" var Str temp := file_temporary file_copy security+"name_secret.pdb" temp console "Cleaning the target tree " path eol file_tree_delete path file_tree_create path if keep_site_key file_copy temp security+"name_secret.pdb" file_delete temp if (options option "secret" Str)<>"" file_copy (options option "secret" Str) security+"site_secret.pdb"
file_tree_create "target:/bin/" file_tree_create "target:/dev/" file_tree_create "target:/proc/" file_tree_create "target:/tmp/" if medium="nfs" or medium="cdrom" file_tree_create "target:/mnt/target/" file_tree_create security
console "Building devices" eol kernel_make_device "target:/dev/console" if (c:env:"kernel":"make":"CONFIG_BLK_DEV_IDE")="y" for (var Int u) 0 3 kernel_make_device "target:/dev/hd"+(character "a":number+u) for (var Int i) 1 4 kernel_make_device "target:/dev/hd"+(character "a":number+u)+string:i if (c:env:"kernel":"make":"CONFIG_SCSI")="y"or (c:env:"kernel":"make":"CONFIG_SCSI")="m" for (var Int i) 0 7 kernel_make_device "target:/dev/scd"+string:i for (var Int u) 0 7 kernel_make_device "target:/dev/sd"+(character "a":number+u) for (var Int i) 1 4 kernel_make_device "target:/dev/sd"+(character "a":number+u)+string:i kernel_make_device "target:/dev/fdO" if (c:env:"kernel":"make":"CONFIG_BLK_DEV_MD")="y" for (var Int i) 0 15 kernel_make_device "target:/dev/md"+string:i kernel_make_device "target:/dev/fd0" kernel_make_device "target:/dev/null" kernel_make_device "target:/dev/zero" kernel_make_device "target:/dev/random" kernel_make_device "target:/dev/rtc" if medium="cdrom" kernel_make_device "target:/dev/ram1" if (c:env:"kernel":"make":"CONFIG_ISDN")="y" or(c:env:"kernel":"make":"CONFIG_ISDN")="m" kernel_make_device "target:/dev/isdninfo" kernel_make_device "target:/dev/isdnctrl" for (var Int i) 0 15 kernel_make_device "target:/dev/ippp"+string:i kernel_make_device "target:/dev/isdnctrl"+string:i
console "Resolving shared libraries dependencies" eol var (Dictionary Str Str) dlls (var DebianDistribution debian) bind c (var Stream log) open "file:/tmp/packages.log" out+safe (var Stream log2) open "file:/tmp/dll.log" out+safe each p c:env:"package" var Str name := keyof p if (debian unpack1 name p:"file" "file:/tmp/package/")=success var Str list := file_temporary if (execute "tar -zt -f "+file_os_name:"file:/tmp/package/data.tar.gz" output list)=0 (var Stream s) open list in+safe while not s:atend if (s:readline parse "." any:(var Str filename)) and (filename search "/lib/" -1)<>(-1) var Str libpath := filename 0 (filename search_last "/" -1)+1 var Str libname := filename (filename search_last "/" -1)+1 filename:len if libpath="/lib/" or libpath="/usr/lib/" dlls insert libname string:name+" "+string:filename else console "Failed to list package " name eol log writeline name+": failed to list" file_delete list else console "Failed to unpack package " name eol log writeline name+": failed to unpack" each p c:env:"package" var Str name := keyof p var CBool some := false each f p if (keyof:f parse "/" any) and (f parse "/bin/" any) some := true if some if (debian unpack1 name p:"file" "file:/tmp/package/")=success file_tree_delete "file:/tmp/files/" file_extract "file:/tmp/package/data.tar.gz" "file:/tmp/files/" each f p
|
if (keyof:f parse "/" any) and ((f parse "/bin/" any) or (f parse "/lib/" any))
|
if (keyof:f parse "/" any) and (f parse "/bin/" any)
|
var List:Str libraries := file_libraries (file_os_name "file:/tmp/files"+keyof:f) each lib libraries if exists:(dlls first lib) and ((dlls first lib) parse (var Str packname) (var Str filename)) log2 writeline f+" requires "+lib+" in "+packname c "package" packname filename := "/lib/"+lib else console "Failed to find package containing library " lib eol log writeline name+": find package containing library "+lib
console "Extracting Debian files" eol each p c:env:"package" var Str name := keyof p var CBool some := false each f p if (keyof:f parse "/" any) some := true if some if (debian unpack1 name p:"file" "file:/tmp/package/")=success file_tree_delete "file:/tmp/files/" file_extract "file:/tmp/package/data.tar.gz" "file:/tmp/files/" each f p if (keyof:f parse "/" any) var Str src := keyof f var Str link := (file_query "file:/tmp/files"+src extended):link if (link 0 1)="/" src := "file:/tmp/files"+link eif link<>"" src := "file:/tmp/files"+(src 0 (src search_last "/" -1)+1)+link else src := "file:/tmp/files"+src var Str dest := "target:"+f if src:len>0 and (src src:len-1)="*" and dest:len>0 and (dest dest:len-1)="/" var Int cut := (src search_last "/" 0)+1 var Str src_path := src 0 cut var Str src_base := src cut src:len-1-cut var Array:FileInfo files := file_list src_path extended+relative var Int count := 0 for (var Int i) 0 files:size-1 if (files:i:name 0 src_base:len)=src_base count += 1 if (file_copy src_path+files:i:name dest+files:i:name extended)=failure console "Failed to copy file " src_path+files:i:name " to " dest+files:i:name eol log writeline name+": "+src_path+files:i:name+" -> "+dest+files:i:name if count=0 console "There is no "+src+" file in package "+name eol log writeline name+": "+src else if (file_copy src dest extended)=failure console "Failed to copy file " keyof:f " to " f eol log writeline name+": "+keyof:f+" -> "+f var Array:FileInfo files := file_list "file:/tmp/files/" extended+recursive+relative for (var Int i) 0 files:size-1 log writeline " "+files:i:name+" "+(string files:i:size)+(shunt files:i:is_link " ("+files:i:link+")" "") # file_link "file:libdl.so.2" "target:/lib/libdl.so" file_tree_delete "file:/tmp/files/" file_tree_delete "file:/tmp/package/"
if static if (file_query fullpliant_binary_path+"e2fsck" standard)=undefined console "Building static e2fsck" eol if not (c:env:"package":"e2fsprogs":"version" parse any:(var Str version) "-" any) version := "1.18" var Str ext2utils := "e2fsprogs-"+version var Str local := fullpliant_source_path+ext2utils+".tar.gz" var Str remote := "http://web.mit.edu/tytso/www/linux/dist/"+ext2utils+".tar.gz" if (file_query local standard)=undefined console "downloading " remote eol if (file_copy remote local standard)=failure return (failure "Failed to download ext2 utils source from "+remote) file_tree_delete "file:/usr/src/"+ext2utils+"/" file_extract local "file:/usr/src/" console " building e2fsck." eol # we cannot redirect ./configure output to /dev/null since it would build buggy make files shell "cd /usr/src/"+ext2utils+"/ ; ./configure --disable-shared ; make clean >/dev/null ; make >/dev/null 2>/dev/null" if (file_copy "file:/usr/src/"+ext2utils+"/e2fsck/e2fsck" fullpliant_binary_path+"e2fsck" extended)=failure return failure:"Failed to build e2fsck." if (file_copy "file:/usr/src/"+ext2utils+"/misc/mke2fs" fullpliant_binary_path+"mke2fs" extended)=failure return failure:"Failed to build mke2fs." if (file_copy "file:/usr/src/"+ext2utils+"/misc/tune2fs" fullpliant_binary_path+"tune2fs" extended)=failure return failure:"Failed to build mke2fs." file_copy fullpliant_binary_path+"e2fsck" "target:/bin/e2fsck" extended file_copy fullpliant_binary_path+"mke2fs" "target:/bin/mke2fs" extended file_copy fullpliant_binary_path+"tune2fs" "target:/bin/tune2fs" extended if c:env:"kernel":"make":"CONFIG_PCMCIA"="y" and c:env:"kernel":"constant":"pcmcia_version"="" file_extract "file:/fullpliant/download/pcmcia.tgz" "target:/" status := install_check_libraries "target:/bin/" "target:/lib/" if status=failure return
|
console "Building the custom Linux kernel" eol status := kernel_compile c if status=failure return var Str kversion := c:env:"kernel":"constant":"linux_version" var Str sign := c:env:"kernel":"constant":"signature" file_extract kernel_binary_path+"kernel-"+kversion+"-"+sign+".tgz" "target:/" file_tree_delete "target:/sbin/" file_tree_delete "target:/etc/" file_tree_delete "target:/usr/" file_tree_delete "target:/var/" file_copy kernel_binary_path+"kernel-"+kversion+"-"+sign+".tgz" "target:/boot/modules.tgz"
|
if not (options option "nokernel") console "Building the custom Linux kernel" eol status := kernel_compile c if status=failure return var Str kversion := c:env:"kernel":"constant":"linux_version" var Str sign := c:env:"kernel":"constant":"signature" file_extract kernel_binary_path+"kernel-"+kversion+"-"+sign+".tgz" "target:/" file_tree_delete "target:/sbin/" file_tree_delete "target:/etc/" file_tree_delete "target:/usr/" file_tree_delete "target:/var/" file_copy kernel_binary_path+"kernel-"+kversion+"-"+sign+".tgz" "target:/boot/modules.tgz"
|
console "Copying Pliant tree" eol file_tree_copy "/pliant/" "target:/pliant/pliant/" extended+recursive file_copy "/index.page" "target:/pliant/index.page" var Str compiler := "gcc" var Str include_options := "" var Str compiler_options := "-O2 -m486 -mregparm=3 -mrtd -D_REGISTERS_" var Str debug0_options := "-s -D_NOCHECK_ -fomit-frame-pointer -D_LISTING_" var Str debug1_options := "-s -D_NOCHECK_ -D_LISTING_" var Str debug2_options := "-s -D_CHECK_" var Str debug_options := shunt debugging_level=0 debug0_options debugging_level=1 debug1_options debug2_options var Str link_options := "-nostdlib" var Str exe_options := pliant_root_path+"pliant/language/startup/start.s"
|
if not static
|
if false # not static
|
exe_options += " -ldl -D_SO2_" if (file_query "file:/lib/libdl.so" standard)=undefined file_link "file:/lib/libdl.so.2" "file:/lib/libdl.so" var Str context_options := "-D_i386_ -D_LINUX_API_ -D_LINUX_ -D_GCC_" if static context_options += " -D_STATIC_" var Str extra_options := "" var Str detail := "-debug"+(string debugging_level)+"-static.exe" if (file_query fullpliant_binary_path+"init" standard)=undefined console "Compiling init executable" eol file_tree_create fullpliant_binary_path execute compiler+" "+compiler_options+" "+include_options+" "+debug_options+" "+link_options+" "+exe_options+" "+context_options+" "+extra_options+" -o "+(file_os_name fullpliant_binary_path+"init")+" "+file_os_name:"/pliant/fullpliant/init.c" (var Stream t) open "file:/tmp/compile.log" out+safe t writeline compiler+" "+compiler_options+" "+include_options+" "+debug_options+" "+link_options+" "+exe_options+" "+context_options+" "+extra_options+" -o "+(file_os_name fullpliant_binary_path+"init")+" "+file_os_name:"/pliant/fullpliant/init.c" t close file_configure fullpliant_binary_path+"init" "mode "+(string 7*8^2+5*8+5) if (file_copy fullpliant_binary_path+"init" "target:/bin/init" extended)=failure return failure:"Failed to build /bin/init"
|
if (file_query fullpliant_binary_path+"linuxrc" standard)=undefined console "Compiling linuxrc executable" eol file_tree_create fullpliant_binary_path execute compiler+" "+compiler_options+" "+include_options+" "+debug_options+" "+link_options+" "+exe_options+" "+context_options+" "+extra_options+" -o "+(file_os_name fullpliant_binary_path+"linuxrc")+" "+file_os_name:"/pliant/fullpliant/linuxrc.c" (var Stream t) open "file:/tmp/compile.log" out+safe t writeline compiler+" "+compiler_options+" "+include_options+" "+debug_options+" "+link_options+" "+exe_options+" "+context_options+" "+extra_options+" -o "+(file_os_name fullpliant_binary_path+"linuxrc")+" "+file_os_name:"/pliant/fullpliant/linuxrc.c" t close file_configure fullpliant_binary_path+"linuxrc" "mode "+(string 7*8^2+5*8+5)
|
if static file_tree_delete "target:/pliant/binary/" file_tree_create "target:/pliant/binary/" if (file_query fullpliant_binary_path+"pliant"+detail standard)=undefined console "Compiling static Pliant executable" eol file_tree_create fullpliant_binary_path execute compiler+" "+compiler_options+" "+include_options+" "+debug_options+" "+link_options+" "+exe_options+" "+context_options+" "+extra_options+" -Dc_debugging_level="+string:debugging_level+" -o "+(file_os_name fullpliant_binary_path+"pliant"+detail)+" "+file_os_name:"/pliant/install/pliant.c" file_copy fullpliant_binary_path+"pliant"+detail "target:/bin/pliant" extended else file_tree_copy "/binary/" "target:/pliant/binary/" extended var Array:FileInfo files := file_list "target:/pliant/binary/" standard for (var Int i) 0 files:size-1 if files:i:extension=".dump" file_delete files:i:name file_link "/binary/pliant-debug"+string:debugging_level+".exe" "target:/bin/pliant"
if generate_site_key and (c:env:"pliant":"http":"site_key_bits" parse (var Int bits)) and not keep_site_key console "Generating site " bits " bits RSA key" eol if exists:(name_database:data:name keyof:c) if not exists:(name_database:data:host keyof:c) name_database:data:host create keyof:c name_database:data:host:(keyof c) ip := name_database:data:name:(keyof c) ip name_database:data:name delete keyof:c site_database:data:site delete keyof:c site_secret_database:data:site delete keyof:c rsa_generate "target:"+keyof:c bits ""
console "Building configuration files" eol var (Link Database:Computer) target_db :> new Database:Computer target_db load "target:/pliant_security/this_computer.pdb" data_copy c target_db:data target_db store data_store file_copy "security:/computer.pdb" security+"computer.pdb" file_copy "security:/name.pdb" security+"name.pdb" file_copy "security:/site.pdb" security+"site.pdb" file_copy "security:/user.pdb" security+"user.pdb" var (Link Database:UserSecretDatabase) user_secret_db :> new Database:UserSecretDatabase user_secret_db load "target:/pliant_security/user_secret.pdb" each us user_secret_database:data:user if us:password_md5<>"" user_secret_db:data:user create keyof:us user_secret_db:data:user:(keyof us) password_md5 := us password_md5 user_secret_db store data_store file_copy "security:/mail.pdb" security+"mail.pdb" file_copy "security:/password_secret.pdb" security+"password_secret.pdb" file_copy "security:/keyboard.pdb" security+"keyboard.pdb"
if medium="cdrom"
|
file_copy "data:/pliant/fullpliant/pci_device_listing1.txt" "target:/pliant_data/pliant/fullpliant/pci_device_listing1.txt" file_copy "data:/pliant/fullpliant/pci_device_listing2.txt" "target:/pliant_data/pliant/fullpliant/pci_device_listing2.txt"
|
(var Stream s) open "target:/etc/mtab" out+mkdir+safe # get around a bug in raidtools and tune2fs s close
|
|
if medium="cdrom" or medium="usb" file_copy "data:/pliant/fullpliant/pci_device_listing.txt" "target:/pliant_data/pliant/fullpliant/pci_device_listing.txt" console "Building initrd image" eol status := install_initrd c "target:/" 0 if status=failure return if c:env:"pliant":"browser":"console"="true" console "Copying browser extra files" eol file_copy "security:/keyboard.pdb" security+"keyboard.pdb" file_copy "security:/font.pdb" security+"font.pdb" file_tree_copy "file:/pliant_data/pliant/font/free/" "target:/pliant_data/pliant/font/free/" kernel_make_device "target:/dev/tty0" kernel_make_device "target:/dev/tty2" # kernel_make_device "target:/dev/input/keyboard" kernel_make_device "target:/dev/input/mice" kernel_make_device "target:/dev/fb0" each tb c:env:"tarball" var Str tbfile := tb "file" if tbfile<>"" if (tbfile search "/" -1)=(-1) tbfile := "file:/fullpliant/download/"+tbfile var Str tbpath := tb "path" if tbpath="" tbpath := "target:/" file_extract tbfile tbpath
|
pliant_multi_file_system dismount "target:/" console "done." eol status := success export install_tree
|