1 \ DebXO installer script
3 : disk-size ( devspec$ -- #MB )
4 open-dev ?dup 0<> if ( ih )
5 dup " #blocks" rot $call-method ( ih #blocks )
7 \ we're assuming a block size of 512 bytes
8 d# 512 um* ( ih bytes.lo bytes.hi )
10 dup " size" rot $call-method ( ih size.lo size.hi )
12 d# 1,000,000 um/mod ( ih rem #MB )
13 rot close-dev nip ( #MB )
19 : target-big-enough? ( devspec$ -- flag )
21 \ we only support devices >= 1GB
23 " Installation target too small, must be at least 1GB. Aborting..."
31 d# 128 buffer: verifystr
33 : user-verified? ( tgt$ -- flag )
34 \ ensure the user *actually* wanted to reformat the device..
35 " WARNING: this will overwrite all data on " ( tgt$ str$ )
37 " . Are you sure that you want to do this?" ( str2$ )
39 verifystr count ( finalstr$ )
42 " Installation cancelled."
47 : verify-target ( tgt$ devspec$ -- )
48 \ XXX: For some reason refresh isn't called after a dialog-alert
49 \ (or menu item callback). This means the menu display is incorrect
50 \ until go-vertical is called. Calling refresh manually here doesn't
51 \ work... so for now, kill the menu and restart it later.
52 menu-done ( tgt$ devspec$ )
54 target-big-enough? -rot ( flag tgt$ )
58 \ installation cancelled/failed, redisplay menu
65 " the internal NAND storage" " /nandflash" verify-target if
66 " installing!" dialog-alert
72 " the internal MMC device" " int:0" verify-target if
73 " installing!" dialog-alert
79 " this SD card" " ext:0" verify-target if
80 " installing!" dialog-alert
109 : has-target? ( devspec$ -- flag )
113 nr-targets 1+ to nr-targets
120 : debxo-find-targets ( -- help0$ 'func0 'icon0 ... helpk$ 'funck 'iconk )
123 \ check for the existence of nandflash (XO-1)
124 " /nandflash" has-target? if
126 ['] choose-nand-item spi.icon
128 \ check for internal EMMC (XO-1.5, XO-1.75)
129 " int:0" has-target? if
131 " int:0" disk-size decimal ( #MB )
132 <# " MB)" hold$ u#s " Internal MMC (" hold$ u#>
135 ['] choose-emmc-item spi.icon
139 " ext:0" has-target? if
141 " ext:0" disk-size decimal ( #MB )
142 <# " MB)" hold$ u#s " SD Card (" hold$ u#>
145 ['] choose-sd-item sdcard.icon
148 \ check for up to 4 USB drives
150 i <# " /disk" hold$ u# " /usb/scsi@" hold$ u#> string2 pack
154 64 alloc-mem >r ( i )
155 <# u# " USB Disk #" hold$ u#> r@ place
156 string2 count disk-size decimal ( #MB )
157 <# " MB)" hold$ u#s " (" hold$ u#> r@ $cat
160 i <# u# " ['] choose-usb-item-" hold$ u#> evaluate usb.icon
164 \ TODO: multiple usb disks?
165 \ differentiate between installer disk & extra disk..
169 : debxo-installer-menu ( -- )
170 \ populate stack w/ icon/target list
173 \ last entry on the list
174 " Abort installation"
175 ['] quit-item quit.icon
179 nr-targets 1+ to cols
189 ['] debxo-installer-menu to root-menu