a33fa24697c40cd53129a2c64f460dd6602144f7
[petitboot] / utils / ps3-kboot-0.1-petitboot.patch
1 Patch for the Ubuntu (feisty) ps3-kboot package, to add petitboot support.
2
3 Just apply this patch, download libtwin-0.0.1.tar.gz and petitboot-0.0.1.tar.gz
4 to the dl/ directory, and build.
5
6 More info at http://ozlabs.org/~jk/projects/petitboot/
7
8 --- ps3-kboot.orig/ps3-kboot-0.1/Makefile       2007-04-05 20:10:44.000000000 +1000
9 +++ ps3-kboot/ps3-kboot-0.1/Makefile    2007-04-04 20:54:40.000000000 +1000
10 @@ -20,6 +20,8 @@
11  LOCAL_KERNEL_CONFIG=$(PWD)/config/kernel-config
12  LOCAL_KBOOT_CONF=$(PWD)/config/kboot.conf
13  LOCAL_FSTAB=$(PWD)/config/fstab
14 +LOCAL_UDEV_RULES=$(PWD)/config/65-persistent-storage.rules \
15 +                $(PWD)/config/99-petitboot.rules
16  KBOOT_MESSAGE=$(PWD)/config/message
17  KBOOT_FEATURES=$(PWD)/config/kboot-features
18  
19 @@ -38,6 +40,14 @@
20  BUSYBOX_DIR=busybox-$(BUSYBOX_VERSION)
21  BUSYBOX_PACKAGE=busybox-$(BUSYBOX_VERSION).tar.bz2
22  
23 +TWIN_VERSION=0.0.2
24 +TWIN_DIR=libtwin-$(TWIN_VERSION)
25 +TWIN_PACKAGE=libtwin-$(TWIN_VERSION).tar.gz
26 +
27 +PETITBOOT_VERSION=0.0.1
28 +PETITBOOT_DIR=petitboot-$(PETITBOOT_VERSION)
29 +PETITBOOT_PACKAGE=petitboot-$(PETITBOOT_VERSION).tar.gz
30 +
31  # ----- General settings ------------------------------------------------------
32  
33  all: otheros.bld
34 @@ -48,14 +58,21 @@
35  root: root-meta/installed/userspace \
36                 root-meta/installed/kexec-tools \
37                 root-meta/installed/busybox \
38 -               Makefile scripts/kboot \
39 +               root-meta/installed/twin \
40 +               root-meta/installed/petitboot \
41 +               Makefile scripts/kboot scripts/petitboot-init \
42                 utils/readline utils/getctty \
43                 $(LOCAL_KBOOT_CONF) $(KBOOT_MESSAGE) \
44 -               $(KBOOT_FEATURES) $(LOCAL_FSTAB)
45 +               $(KBOOT_FEATURES) $(LOCAL_FSTAB) \
46 +               $(LOCAL_UDEV_RULES)
47         rm -f root/etc/{hosts,passwd,kboot.conf,message}
48         rm -rf root/tmp root/dev
49 +       rm -rf root/include root/usr/include
50 +       find root/ -name '*.a' -o -name '*.la' -exec rm {} \;
51         mkdir -p root/etc root/tmp root/proc root/dev root/sys
52         mkdir -p root/mnt/tmp root/mnt/root root/bin root/sbin
53 +       mkdir -p root/var/tmp/mnt
54 +       mkdir -p root/etc/udev/rules.d
55         [ -e root/dev/console ] || mknod root/dev/console c 5 1
56         [ -e root/dev/null ] || mknod root/dev/null c 1 3
57         [ -e root/dev/tty ] || mknod root/dev/tty c 5 0
58 @@ -66,15 +83,18 @@
59         cp "$(KBOOT_MESSAGE)" root/etc/
60         cp "$(LOCAL_FSTAB)" root/etc/
61         cp "$(KBOOT_FEATURES)" root/etc/
62 +       cp $(LOCAL_UDEV_RULES) root/etc/udev/rules.d/
63         touch root/etc/mtab
64         install -D -m755  scripts/kboot root/sbin/kboot
65 +       install -D -m755  scripts/petitboot-init root/sbin/petitboot-init
66         install -D -s -m755 utils/readline root/bin/readline
67         install -D -s -m755 utils/getctty root/sbin/getctty
68 -       ln -sf /sbin/kboot root/init
69 -       for FILE in $$( find root/bin root/sbin \
70 +       ln -sf /sbin/petitboot-init root/init
71 +       for FILE in $$( find root/bin root/sbin root/lib/udev \
72             -type f -perm -100 ) ; do \
73             LIBS=$$( ldd $$FILE | awk '/=>.*\.so/ { print $$3 }' | grep -v fakeroot ) ; \
74             for LIB in $$LIBS ; do \
75 +               [ -e root/$$LIB ] && continue; \
76                 LIB_PATH=$$( echo $$LIB | sed -e 's/[^/]*$$//' ) ; \
77                 mkdir -p root/$$LIB_PATH ; \
78                 cp $$LIB root/$$LIB_PATH ; \
79 @@ -133,6 +153,10 @@
80         install -m755 -D /sbin/udevtrigger root/sbin/udevtrigger
81         install -m755 -D /sbin/udevsettle root/sbin/udevsettle
82         install -m644 -D /etc/udev/udev.conf root/etc/udev/udev.conf
83 +       # udev helpers
84 +       while read helper; do install -m755 -D /lib/udev/$$helper \
85 +               root/lib/udev/$$helper; done < config/udev-helpers
86 +       cp -a /lib/udev/devices root/lib/udev/
87         # ps3pf-utils stuff
88         install -m755 -D /sbin/other-os-flash-util \
89                 $(PWD)/root/sbin/other-os-flash-util
90 @@ -199,6 +223,57 @@
91                 root/sbin/kexec
92         touch $@
93  
94 +# ----- twin library ----------------------------------------------------------
95 +
96 +$(TWIN_DIR)/.twin-extracted: \
97 +         dl/$(TWIN_PACKAGE)
98 +       tar xfz dl/$(TWIN_PACKAGE)
99 +       for i in `ls patches/twin/$(TWIN_VERSION)/*patch*` ; do \
100 +         patch -d $(TWIN_DIR) -p1 < $$i ; \
101 +       done
102 +       touch $@
103 +
104 +$(TWIN_DIR)/.twin-configured: \
105 +         $(TWIN_DIR)/.twin-extracted
106 +       ( cd $(TWIN_DIR) && \
107 +         ./configure --prefix=/ --disable-x11 $(GNU_ARCH); )
108 +       touch $@
109 +
110 +$(TWIN_DIR)/.twin-built: \
111 +         $(TWIN_DIR)/.twin-configured
112 +       make -C $(TWIN_DIR)
113 +       touch $@
114 +
115 +root-meta/installed/twin: \
116 +         $(TWIN_DIR)/.twin-built
117 +       mkdir -p root root-meta/installed
118 +       make -C $(TWIN_DIR) DESTDIR=$(PWD)/root install
119 +       strip root/lib/libtwin.so
120 +       rm root/lib/libtwin.a
121 +       touch $@
122 +
123 +# ----- petitboot GUI ----------------------------------------------------------
124 +
125 +$(PETITBOOT_DIR)/.petitboot-extracted: \
126 +         dl/$(PETITBOOT_PACKAGE)
127 +       tar xfz dl/$(PETITBOOT_PACKAGE)
128 +       for i in `ls patches/petitboot/$(PETITBOOT_VERSION)/*patch*` ; do \
129 +         patch -d $(PETITBOOT_DIR) -p1 < $$i ; \
130 +       done
131 +       touch $@
132 +
133 +$(PETITBOOT_DIR)/.petitboot-built: \
134 +         $(PETITBOOT_DIR)/.petitboot-extracted root-meta/installed/twin
135 +       make -C $(PETITBOOT_DIR) PREFIX=/ "TWIN_CFLAGS=-I$(PWD)/root/include" \
136 +               "TWIN_LDFLAGS=-L$(PWD)/root/lib -ltwin -ljpeg -lpng -lz"
137 +       touch $@
138 +
139 +root-meta/installed/petitboot: \
140 +         $(PETITBOOT_DIR)/.petitboot-built
141 +       mkdir -p root root-meta/installed
142 +       make -C $(PETITBOOT_DIR) PREFIX=/ DESTDIR=$(PWD)/root/ install
143 +       strip root/sbin/petitboot root/sbin/udev-helper
144 +       touch $@
145  
146  # ----- kboot's utilities -----------------------------------------------------
147  
148 @@ -213,6 +288,7 @@
149  # ---- Cleanup ----------------------------------------------------------------
150  
151  clean:
152 -       rm -rf $(KERNEL_DIR) $(KEXEC_TOOLS_DIR) $(BUSYBOX_DIR)
153 +       rm -rf $(KERNEL_DIR) $(KEXEC_TOOLS_DIR) $(BUSYBOX_DIR) $(TWIN_DIR) \
154 +               $(PETITBOOT_DIR)
155         rm -rf root root-meta otheros.bld initrd.bin
156         rm -f otheros.bld initrd.bin utils/getctty utils/readline
157 diff -urN ps3-kboot.orig/ps3-kboot-0.1/config/65-persistent-storage.rules ps3-kboot/ps3-kboot-0.1/config/65-persistent-storage.rules
158 --- ps3-kboot.orig/ps3-kboot-0.1/config/65-persistent-storage.rules     1970-01-01 10:00:00.000000000 +1000
159 +++ ps3-kboot/ps3-kboot-0.1/config/65-persistent-storage.rules  2007-04-03 10:08:03.000000000 +1000
160 @@ -0,0 +1,61 @@
161 +# persistent storage links: /dev/{disk,tape}/{by-id,by-uuid,by-label,by-path,by-name}
162 +# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>
163 +
164 +SUBSYSTEM!="block", GOTO="persistent_storage_end"
165 +
166 +KERNEL=="md*", ACTION=="add|change", PROGRAM="watershed -i udev-mdadm true", GOTO="persistent_storage_path_uuid"
167 +
168 +KERNEL=="dm-*", ACTION=="add|change", PROGRAM="devmap_name %M %m", NAME="mapper/$result", GOTO="persistent_storage_identify"
169 +KERNEL=="dm-*", ACTION=="add|change", NAME=""
170 +
171 +ACTION!="add", GOTO="persistent_storage_end"
172 +
173 +# skip rules for inappropriate block devices
174 +KERNEL=="ram*|loop*|fd*|nbd*|gnbd*", GOTO="persistent_storage_end"
175 +
176 +# never access non-cdrom removable ide devices, the drivers are causing event loops on open()
177 +KERNEL=="hd*[!0-9]", ATTRS{removable}=="1", DRIVERS=="ide-cs|ide-floppy", GOTO="persistent_storage_end"
178 +KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GOTO="persistent_storage_end"
179 +
180 +# never add uuid information for whole disk
181 +ATTR{whole_disk}=="", GOTO="persistent_storage_end"
182 +
183 +# for partitions import parent information
184 +KERNEL=="*[0-9]", IMPORT{parent}="ID_*"
185 +
186 +# by-id (hardware serial number)
187 +KERNEL=="hd*[!0-9]", IMPORT{program}="ata_id --export $tempnode"
188 +KERNEL=="hd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}"
189 +KERNEL=="hd*[0-9]", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}-part%n"
190 +
191 +KERNEL=="sd*[!0-9]|sr*|st*", ATTRS{ieee1394_id}=="?*", ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394"
192 +KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="usb_id -x"
193 +KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -s %p -d $tempnode"
194 +KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -a -s %p -d $tempnode"
195 +KERNEL=="dasd*[!0-9]", IMPORT{program}="dasd_id --export $tempnode"
196 +KERNEL=="sd*[!0-9]|sr*|dasd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
197 +KERNEL=="sd*[0-9]|dasd*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
198 +KERNEL=="st*", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
199 +
200 +LABEL="persistent_storage_path_uuid"
201 +
202 +# by-path (shortest physical path)
203 +KERNEL=="*[!0-9]|sr*", IMPORT{program}="path_id %p", SYMLINK+="disk/by-path/$env{ID_PATH}"
204 +KERNEL=="st*", IMPORT{program}="path_id %p", SYMLINK+="tape/by-path/$env{ID_PATH}"
205 +KERNEL=="sr*|st*", GOTO="persistent_storage_end"
206 +KERNEL=="*[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
207 +
208 +LABEL="persistent_storage_identify"
209 +
210 +# by-label/by-uuid (filesystem properties)
211 +KERNEL=="*[!0-9]", ATTR{removable}=="1", GOTO="persistent_storage_end"
212 +IMPORT{program}="vol_id --export $tempnode"
213 +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID}"
214 +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_SAFE}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_SAFE}"
215 +
216 +# BIOS Enhanced Disk Device
217 +KERNEL=="*[!0-9]", IMPORT{program}="edd_id --export $tempnode"
218 +KERNEL=="*[!0-9]", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
219 +KERNEL=="*[0-9]", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"
220 +
221 +LABEL="persistent_storage_end"
222 diff -urN ps3-kboot.orig/ps3-kboot-0.1/config/99-petitboot.rules ps3-kboot/ps3-kboot-0.1/config/99-petitboot.rules
223 --- ps3-kboot.orig/ps3-kboot-0.1/config/99-petitboot.rules      1970-01-01 10:00:00.000000000 +1000
224 +++ ps3-kboot/ps3-kboot-0.1/config/99-petitboot.rules   2007-04-03 16:07:23.000000000 +1000
225 @@ -0,0 +1,2 @@
226 +# tell petitboot when we see new block devices ...
227 +SUBSYSTEM=="block",RUN+="/sbin/udev-helper"
228 diff -urN ps3-kboot.orig/ps3-kboot-0.1/config/udev-helpers ps3-kboot/ps3-kboot-0.1/config/udev-helpers
229 --- ps3-kboot.orig/ps3-kboot-0.1/config/udev-helpers    1970-01-01 10:00:00.000000000 +1000
230 +++ ps3-kboot/ps3-kboot-0.1/config/udev-helpers 2007-04-05 14:21:52.000000000 +1000
231 @@ -0,0 +1,12 @@
232 +devmap_name
233 +set_hwclock
234 +cdrom_id
235 +ata_id
236 +path_id
237 +scsi_id
238 +usb_id
239 +usb_device_name
240 +ide_media
241 +iftab_helper
242 +watershed
243 +vol_id
244 diff -urN ps3-kboot.orig/ps3-kboot-0.1/scripts/petitboot-init ps3-kboot/ps3-kboot-0.1/scripts/petitboot-init
245 --- ps3-kboot.orig/ps3-kboot-0.1/scripts/petitboot-init 1970-01-01 10:00:00.000000000 +1000
246 +++ ps3-kboot/ps3-kboot-0.1/scripts/petitboot-init      2007-04-05 15:37:48.000000000 +1000
247 @@ -0,0 +1,49 @@
248 +#!/bin/sh
249 +#
250 +# kboot - Kboot initialization and command-line interface
251 +#
252 +# Written 2005, 2006 by Werner Almesberger
253 +#
254 +
255 +if [ "x$0" = x/init ]; then
256 +    __sysinit=true
257 +else
258 +    __sysinit=false
259 +fi
260 +
261 +###############################################################################
262 +#
263 +# System setup and internal initialization
264 +#
265 +
266 +if $__sysinit; then
267 +    if [ ! -f /proc/partitions ]; then
268 +       mount -n -t proc none /proc
269 +    fi
270 +    if [ ! -d /sys/block ]; then
271 +       mount -n -t sysfs none /sys
272 +
273 +       # Borrowed from initramfs tools. No more hard coded sleep
274 +       echo "" > /proc/sys/kernel/hotplug
275 +       udevd --daemon
276 +       udevtrigger
277 +       udevsettle --timeout=15
278 +    fi
279 +fi
280 +
281 +while /bin/true;
282 +do
283 +       /sbin/petitboot -u
284 +
285 +       # clean up after petitboot
286 +       for dir in /var/tmp/mnt/*;
287 +       do
288 +               umount "$dir"
289 +               rmdir "$dir"
290 +       done
291 +done &
292 +
293 +while /bin/true;
294 +do
295 +       /sbin/getctty /dev/console /bin/sh
296 +done
297 --- ps3-kboot.orig/ps3-kboot-0.1/debian/control 2007-04-05 20:10:44.000000000 +1000
298 +++ ps3-kboot/ps3-kboot-0.1/debian/control      2007-04-03 15:54:04.000000000 +1000
299 @@ -2,7 +2,7 @@
300  Section: base
301  Priority: optional
302  Maintainer: Ben Collins <bcollins@ubuntu.com>
303 -Build-Depends: debhelper (>= 4.1.67), bzip2, cdbs, fakeroot, udev, ps3pf-utils, libc6-dev-ppc64, lib64z1-dev
304 +Build-Depends: debhelper (>= 4.1.67), bzip2, cdbs, fakeroot, udev, ps3pf-utils, libc6-dev-ppc64, lib64z1-dev, libpng12-dev, libjpeg62-dev, pkg-config
305  Standards-Version: 3.6.1
306  
307  Package: ps3-kboot