- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / Documentation / acpi / initramfs-add-dsdt.sh
1 #!/bin/bash
2 # Adds a DSDT file to the initrd (if it's an initramfs)
3 # first argument is the name of archive
4 # second argument is the name of the file to add
5 # The file will be copied as /DSDT.aml
6
7 # 20060126: fix "Premature end of file" with some old cpio (Roland Robic)
8 # 20060205: this time it should really work
9
10 # check the arguments
11 if [ $# -ne 2 ]; then
12         program_name=$(basename $0)
13         echo "\
14 $program_name: too few arguments
15 Usage: $program_name initrd-name.img DSDT-to-add.aml
16 Adds a DSDT file to an initrd (in initramfs format)
17
18   initrd-name.img: filename of the initrd in initramfs format
19   DSDT-to-add.aml: filename of the DSDT file to add
20   " 1>&2
21     exit 1
22 fi
23
24 # we should check it's an initramfs
25
26 tempcpio=$(mktemp -d)
27 # cleanup on exit, hangup, interrupt, quit, termination
28 trap 'rm -rf $tempcpio' 0 1 2 3 15
29
30 # extract the archive
31 gunzip -c "$1" > "$tempcpio"/initramfs.cpio || exit 1
32
33 # copy the DSDT file at the root of the directory so that we can call it "/DSDT.aml"
34 cp -f "$2" "$tempcpio"/DSDT.aml
35
36 # add the file
37 cd "$tempcpio"
38 (echo DSDT.aml | cpio --quiet -H newc -o -A -O "$tempcpio"/initramfs.cpio) || exit 1
39 cd "$OLDPWD"
40
41 # re-compress the archive
42 gzip -c "$tempcpio"/initramfs.cpio > "$1"
43