Difference between revisions of "Patchstick/Testing"

From AwkwardTV
Jump to: navigation, search
m (NOTES: added IOUSBMassStorageClass and deps)
(updated to have 2 file systems)
Line 3: Line 3:
 
However, I think this process is important enough to document, so we can see what steps are needed to build an open, free and 100% legal version of Patchstick. - [[User:Mactijn|Mactijn]] 23:56, 8 April 2007 (CEST)
 
However, I think this process is important enough to document, so we can see what steps are needed to build an open, free and 100% legal version of Patchstick. - [[User:Mactijn|Mactijn]] 23:56, 8 April 2007 (CEST)
  
===Pre-requisites===
+
==Pre-requisites==
 
* USB flashdrive or disk (USB mass storage compatible)
 
* USB flashdrive or disk (USB mass storage compatible)
 
* an Intel machine running MacOSX 10.4.x (I used my macbook) (might also work on non-intel machines)
 
* an Intel machine running MacOSX 10.4.x (I used my macbook) (might also work on non-intel machines)
Line 9: Line 9:
 
* Semthex's OSX86 kernel
 
* Semthex's OSX86 kernel
  
===Partitioning and formatting the USB disk===
+
==Partitioning and formatting the USB disk==
  
based on Turbo's excellent  
+
based on Turbo's excellent guide [http://0xfeedbeef.com/appletv/usbboot here].
  
 
* hook up the USB drive to your iMac, macbook or macbook pro
 
* hook up the USB drive to your iMac, macbook or macbook pro
Line 34: Line 34:
 
  10+0 records in
 
  10+0 records in
 
  10+0 records out
 
  10+0 records out
  10485760 bytes transferred in 0.654783 secs (1601410 bytes/sec)
+
  10485760 bytes transferred in 6.547830 secs (1601410 bytes/sec)
 
* create a new one:
 
* create a new one:
 
  hostname:~ root# gpt create /dev/diskX
 
  hostname:~ root# gpt create /dev/diskX
Line 46: Line 46:
 
   1022175      32        Sec GPT table
 
   1022175      32        Sec GPT table
 
   1022207        1        Sec GPT header
 
   1022207        1        Sec GPT header
* create a new HFS partition, according to the values given above:
+
* calculate (in any calculator) how many sectors (size above is not in MB, KB or Bytes) you need for the primary partition:
  hostname:~ root# gpt add -b <font color="red">34</font> -s <font color="red">1022141</font> -i 1 -t "48465300-0000-11AA-AA11-00306543ECAC" /dev/diskX
+
(<size from gpt>/<disk size>)*80 = <font color="green"><number of sectors needed to build root partition of 80MB></font>
 +
* create a new HFS partition, according to the start value given above:
 +
  hostname:~ root# gpt add -b <font color="red">34</font> -s <font color="green">163840</font> -i 1 -t "48465300-0000-11AA-AA11-00306543ECAC" /dev/diskX
 +
* show the layout of the now half-filled table:
 +
Hostname:~ root# gpt show /dev/diskX
 +
    start    size  index  contents
 +
        0        1        PMBR
 +
        1        1        Pri GPT header
 +
        2      32        Pri GPT table
 +
        34  163840      1  GPT part - 5265636F-7665-11AA-AA11-00306543ECAC
 +
    <font color="red">163874  858301</font>       
 +
  1022175      32        Sec GPT table
 +
  1022207        1        Sec GPT header
 +
* create a secondary partition:
 +
hostname:~ root# gpt add -b <font color="red">163874</font> -s <font color="red">858301</font> -i 2 -t "48465300-0000-11AA-AA11-00306543ECAC" /dev/diskX
 
* Unplug and re-plug your USB disk. OSX will now give a dialog saying that the disk you inserted was not readable by this computer. Click on "Initialize..."
 
* Unplug and re-plug your USB disk. OSX will now give a dialog saying that the disk you inserted was not readable by this computer. Click on "Initialize..."
* Disk utility will open. Select the partition (''diskXsY'') on the left. Then, select the "Erase" tab. In the "Name" field, type "Patchstick". Click the "Erase" button, and confirm.
+
* Disk utility will open. Select the first partition (''diskXs1'') on the left. Then, select the "Erase" tab. In the "Name" field, type "Patchstick-root". Click the "Erase" button, and confirm.
 
+
* Do the same for diskXs2, but name it "Patchstick".
  
===Creating the patch-environment===
+
==Creating the patchstick boot-environment==
  
 
''this part is, for now, based on copying OSX binaries, and needs to be replaced ASAP''
 
''this part is, for now, based on copying OSX binaries, and needs to be replaced ASAP''
  
After performing the steps in the previous chapter, the USB drive's single partition should have mounted itself as /Volumes/Patchstick. If you named it differently, please substitute all occurences of /Volumes/Patchstick with the correct one.
+
After performing the steps in the previous chapter, the USB drive's primary partition should have mounted itself as /Volumes/Patchstick-root. If you named it differently, please substitute all occurences of /Volumes/Patchstick-root with the correct one.
  
* in a shell, as root, change the current directory to the patchstick:
+
* in a shell, as root, change the current directory to the patchstick root FS:
  hostname:~ root# cd /Volumes/Patchstick
+
  hostname:~ root# cd /Volumes/Patchstick-root
 
* create the directory structure:
 
* create the directory structure:
 
  hostname:~ root# mkdir -p sbin usr/lib/system System/Library/Extensions stuff etc dev OSBoot
 
  hostname:~ root# mkdir -p sbin usr/lib/system System/Library/Extensions stuff etc dev OSBoot
 
  hostname:~ root# ln -s sbin bin
 
  hostname:~ root# ln -s sbin bin
* copy semthex's kernel (named mach_kernel) to /Volumes/Patchstick/
+
* copy semthex's kernel (named mach_kernel) to /Volumes/Patchstick-root/
* create /Volumes/Patchstick/com.apple.Boot.plist with your favourite text editor (vi/pico/joe/...) and make it look like this:
+
* create /Volumes/Patchstick-root/com.apple.Boot.plist with your favourite text editor (vi/pico/joe/...) and make it look like this:
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 
  <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 81: Line 95:
 
  </dict>
 
  </dict>
 
  </plist>
 
  </plist>
* copy over the following files:
+
* copy over the following files: (EDIT: see Notes on the bottom about the required .kext stuff)
  hostname:~ root# cp -R /System/Library/Extensions/* /Volumes/Patchstick/System/Library/Extensions/
+
  hostname:~ root# cp -R /System/Library/Extensions/* /Volumes/Patchstick-root/System/Library/Extensions/
  hostname:~ root# cp /bin/bash /bin/cp /sbin/mount /sbin/mount_hfs /sbin/mount_devfs /bin/sleep /sbin/umount /Volumes/Patchstick/sbin/
+
  hostname:~ root# cp /bin/bash /bin/cp /sbin/mount /sbin/mount_hfs /sbin/mount_devfs /bin/sleep /sbin/umount /Volumes/Patchstick-root/sbin/
hostname:~ root# cp /usr/sbin/sshd /Volumes/Patchstick/stuff/
+
  hostname:~ root# cp /usr/lib/dyld /usr/lib/libSystem.B.dylib /usr/lib/libncurses.5.4.dylib /usr/lib/libgcc_s.1.dylib /Volumes/Patchstick-root/usr/lib/
  hostname:~ root# cp /usr/lib/dyld /usr/lib/libSystem.B.dylib /usr/lib/libncurses.5.4.dylib /usr/lib/libgcc_s.1.dylib /Volumes/Patchstick/usr/lib/
+
  hostname:~ root# cp /usr/lib/system/libmathCommon.A.dylib /Volumes/Patchstick-root/usr/lib/system/
  hostname:~ root# cp /usr/lib/system/libmathCommon.A.dylib /Volumes/Patchstick/usr/lib/system/
+
* Patch the AppleFileSystemDriver and add the following section to the file /Volumes/Patchstick-root/System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array:
* Patch the AppleFileSystemDriver and add the following section to the file /Volumes/Patchstick/System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array:
 
 
                         <key>media-match</key>
 
                         <key>media-match</key>
 
                         <dict>
 
                         <dict>
Line 111: Line 124:
 
                                         </dict>  
 
                                         </dict>  
  
* create /Volumes/Patchstick/stuff/ssh.plist, make it look like this:
+
 
 +
* now, create /Volumes/Patchstick-root/sbin/launchd with your favourite text editor (vi/pico/joe/...) and make it look like this:
 +
#!/sbin/bash
 +
 +
exec 2>/dev/console
 +
exec 1>/dev/console
 +
 +
echo
 +
echo " --- AppleTV Patchstick ---"
 +
echo
 +
 +
# echo "* remounting / r/w"
 +
# /sbin/mount -uw /
 +
 +
echo "* mounting OSBoot partition r/o"
 +
/sbin/mount -t hfs -r /dev/disk0s3 /OSBoot
 +
 +
echo "* re-mounting OSBoot partition r/w"
 +
/sbin/mount -uw /OSBoot
 +
 +
echo "* mounting stuff partition r/o"
 +
/sbin/mount -t hfs -r /dev/disk1s2 /stuff
 +
 +
if [ -d /OSBoot/dev/ ]; then
 +
 +
  for i in /stuff/installer.d/*; do
 +
    echo "--- ${i} ---"
 +
    /sbin/bash "${i}"
 +
  done
 +
 +
  /sbin/sync &>/dev/null
 +
  /sbin/umount /OSBoot
 +
  echo "all done!"
 +
 +
else
 +
  echo "! OSBoot not mounted, not installing or modifying anything"
 +
fi
 +
 +
 +
echo
 +
echo "Now, you can reboot your AppleTV by unplugging/replugging the power supply."
 +
/sbin/sleep 100000
 +
* make our launchd replacement executable:
 +
hostname:/Volumes/Patchstick-root root# chmod 755 /Volumes/Patchstick-root/sbin/launchd
 +
* add AppleTV's own boot.efi to the root of the patch stick.
 +
 
 +
== The aftermath ==
 +
* unmount the partition:
 +
hostname:~ root# hdiutil unmount /dev/diskXs1
 +
"diskXs1" unmounted successfully
 +
* remove the HFS partition...
 +
hostname:~ root# gpt remove -i 1 /dev/diskX
 +
gpt remove: /dev/diskX: 1 partition(s) removed
 +
* ...and add a hidden one in it's place
 +
gpt add -b <font color="red">34</font> -s <font olor="red">163840</font> -i 1 -t "5265636F-7665-11AA-AA11-00306543ECAC" /dev/diskX
 +
 
 +
== Adding patches ==
 +
Patching just got a bit more modular. First, we have to create the scripts dir:
 +
mkdir /Volumes/Patchstick/installer.d/
 +
 
 +
===SSHD===
 +
To add SSH, do the following:
 +
* make the SSH directory:
 +
mkdir /Volumes/Patchstick/ssh
 +
* create /Volumes/Patchstick/ssh/ssh.plist, make it look like this:
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 
  <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 151: Line 228:
 
  </dict>
 
  </dict>
 
  </plist>
 
  </plist>
* now, create /Volumes/Patchstick/sbin/launchd with your favourite text editor (vi/pico/joe/...) and make it look like this:
+
* copy the sshd binary to the patchstick:
  #!/bin/bash
+
  cp /usr/sbin/sshd /Volumes/Patchstick/ssh/sshd
+
* add an installer script:
exec 2>/dev/console
+
  #!/sbin/bash
exec 1>/dev/console
 
 
echo
 
echo " --- AppleTV Patchstick ---"
 
echo
 
 
# echo "* remounting / r/w"
 
# /sbin/mount -uw /
 
 
echo "* mounting OSBoot partition r/o"
 
/sbin/mount -t hfs -r /dev/disk0s3 /OSBoot
 
 
echo "* re-mounting OSBoot partition r/w"
 
/sbin/mount -uw /OSBoot
 
 
if [ -d /OSBoot/dev/ ]; then
 
 
  # install ssh
 
  [ -f /stuff/sshd ] && [ -f /stuff/ssh.plist ] && (
 
    echo -n "* installing SSH daemon... "
 
    cp /stuff/sshd /OSBoot/usr/sbin/sshd
 
    cp /stuff/ssh.plist /OSBoot/System/Library/LaunchDaemons/ssh.plist
 
    echo "done."
 
  )
 
 
  # install Perian
 
  [ -d /stuff/Perian.component/ ] && (
 
    echo -n "* installing Perian Quicktime codec set... "
 
    cp -R /stuff/Perian.component /OSBoot/Library/Quicktime/
 
    echo "done."
 
  )
 
   
 
  # install ATVFiles
 
  [ -d /stuff/ATVFiles.frappliance/ ] && (
 
    echo -n "* installing ATVFiles... "
 
    cp -R /stuff/ATVFiles.frappliance /OSBoot/System/Library/CoreServices/Finder.app/Contents/PlugIns/
 
    echo "done."
 
  )
 
 
  ### Additional install stuff should go here
 
 
   
 
   
 +
# install ssh
 +
# (c) 2007 macTijn at awkwardtv dot org
 
   
 
   
  /sbin/sync &>/dev/null
+
if [ -f /stuff/ssh/sshd ] && [ -f /stuff/ssh/ssh.plist ]; then
   /sbin/umount /OSBoot
+
  echo -n "* installing SSH daemon... "
   echo "all done!"
+
   cp /stuff/ssh/sshd /OSBoot/usr/sbin/sshd
+
  cp /stuff/ssh/ssh.plist /OSBoot/System/Library/LaunchDaemons/ssh.plist
 +
   echo "done."
 
  else
 
  else
   echo "! OSBoot not mounted, not modifying anything"
+
   echo "SSH files not found, not installing"
 
  fi
 
  fi
+
 
 
echo
 
echo "Now, you can reboot your AppleTV by unplugging/replugging the power supply."
 
/sbin/sleep 100000
 
* make our launchd replacement executable:
 
hostname:~ root# chmod 755 /Volumes/Patchstick/sbin/launchd
 
* add AppleTV's own boot.efi to the root of the patch stick.
 
=== The aftermath ===
 
* unmount the partition:
 
hostname:~ root# hdiutil unmount /dev/diskXs1
 
"diskXs1" unmounted successfully
 
* remove the HFS partition...
 
hostname:~ root# gpt remove -i 1 /dev/diskX
 
gpt remove: /dev/diskX: 1 partition(s) removed
 
* ...and add a hidden one in it's place
 
gpt add -b <font color="red">34</font> -s <font olor="red">1022141</font> -i 1 -t "5265636F-7665-11AA-AA11-00306543ECAC" /dev/diskX
 
* A popup saying the disk is unreadable will immediately show. press "Ignore".
 
  
 
All done! your patchstick should be completely done by now.
 
All done! your patchstick should be completely done by now.

Revision as of 13:27, 9 April 2007

This page describes how to make a Patch stick using OSX/Intel binaries, and therefor is not legally distributable. Therefor, no support whatsoever is given to anyone.

However, I think this process is important enough to document, so we can see what steps are needed to build an open, free and 100% legal version of Patchstick. - Mactijn 23:56, 8 April 2007 (CEST)

Pre-requisites

  • USB flashdrive or disk (USB mass storage compatible)
  • an Intel machine running MacOSX 10.4.x (I used my macbook) (might also work on non-intel machines)
  • boot.efi from your ATV (yes I know, chicken/egg. Work is being done to remove this requirement)
  • Semthex's OSX86 kernel

Partitioning and formatting the USB disk

based on Turbo's excellent guide here.

  • hook up the USB drive to your iMac, macbook or macbook pro
  • check what disk it is:
hostname:~ user$ df -h
/dev/disk0s2               74G    72G   1.9G    97%    /
devfs                     100K   100K     0B   100%    /dev
fdesc                     1.0K   1.0K     0B   100%    /dev
<volfs>                   512K   512K     0B   100%    /.vol
automount -nsl [205]        0B     0B     0B   100%    /Network
automount -fstab [219]      0B     0B     0B   100%    /automount/Servers
automount -static [219]     0B     0B     0B   100%    /automount/static
/dev/diskX                499M    40K   499M     0%    /Volumes/NO NAME

note: sometimes, the disk can show up as diskXsY in stead of just diskX. You will only need the sY part for unmounting. After that, just use diskX

  • become root, and unmount the disk
hostname:~ user$ sudo -s
Password:
hostname:~ root# hdiutil unmount /dev/diskX
"diskX" unmounted successfully.
  • destroy the current partition table:
hostname:~ root# dd if=/dev/zero of=/dev/diskX bs=1m count=10
10+0 records in
10+0 records out
10485760 bytes transferred in 6.547830 secs (1601410 bytes/sec)
  • create a new one:
hostname:~ root# gpt create /dev/diskX
  • show the layout of the empty table:
hostname:~ root# gpt show /dev/diskX
    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34  1022141         
  1022175       32         Sec GPT table
  1022207        1         Sec GPT header
  • calculate (in any calculator) how many sectors (size above is not in MB, KB or Bytes) you need for the primary partition:
(<size from gpt>/<disk size>)*80 = <number of sectors needed to build root partition of 80MB>
  • create a new HFS partition, according to the start value given above:
hostname:~ root# gpt add -b 34 -s 163840 -i 1 -t "48465300-0000-11AA-AA11-00306543ECAC" /dev/diskX
  • show the layout of the now half-filled table:
Hostname:~ root# gpt show /dev/diskX
    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34   163840      1  GPT part - 5265636F-7665-11AA-AA11-00306543ECAC
   163874   858301        
  1022175       32         Sec GPT table
  1022207        1         Sec GPT header
  • create a secondary partition:
hostname:~ root# gpt add -b 163874 -s 858301 -i 2 -t "48465300-0000-11AA-AA11-00306543ECAC" /dev/diskX
  • Unplug and re-plug your USB disk. OSX will now give a dialog saying that the disk you inserted was not readable by this computer. Click on "Initialize..."
  • Disk utility will open. Select the first partition (diskXs1) on the left. Then, select the "Erase" tab. In the "Name" field, type "Patchstick-root". Click the "Erase" button, and confirm.
  • Do the same for diskXs2, but name it "Patchstick".

Creating the patchstick boot-environment

this part is, for now, based on copying OSX binaries, and needs to be replaced ASAP

After performing the steps in the previous chapter, the USB drive's primary partition should have mounted itself as /Volumes/Patchstick-root. If you named it differently, please substitute all occurences of /Volumes/Patchstick-root with the correct one.

  • in a shell, as root, change the current directory to the patchstick root FS:
hostname:~ root# cd /Volumes/Patchstick-root
  • create the directory structure:
hostname:~ root# mkdir -p sbin usr/lib/system System/Library/Extensions stuff etc dev OSBoot
hostname:~ root# ln -s sbin bin
  • copy semthex's kernel (named mach_kernel) to /Volumes/Patchstick-root/
  • create /Volumes/Patchstick-root/com.apple.Boot.plist with your favourite text editor (vi/pico/joe/...) and make it look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Background Color</key>
        <integer>0</integer>
        <key>Boot Fail Logo</key>
        <string></string>
        <key>Boot Logo</key>
        <string>BootLogo.png</string>
        <key>Kernel</key>
        <string>mach_kernel</string>
        <key>Kernel Flags</key>
        <string>-v</string>
</dict>
</plist>
  • copy over the following files: (EDIT: see Notes on the bottom about the required .kext stuff)
hostname:~ root# cp -R /System/Library/Extensions/* /Volumes/Patchstick-root/System/Library/Extensions/
hostname:~ root# cp /bin/bash /bin/cp /sbin/mount /sbin/mount_hfs /sbin/mount_devfs /bin/sleep /sbin/umount /Volumes/Patchstick-root/sbin/
hostname:~ root# cp /usr/lib/dyld /usr/lib/libSystem.B.dylib /usr/lib/libncurses.5.4.dylib /usr/lib/libgcc_s.1.dylib /Volumes/Patchstick-root/usr/lib/
hostname:~ root# cp /usr/lib/system/libmathCommon.A.dylib /Volumes/Patchstick-root/usr/lib/system/
  • Patch the AppleFileSystemDriver and add the following section to the file /Volumes/Patchstick-root/System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array:
                        <key>media-match</key>
                        <dict>
                                <key>IOPropertyMatch</key>
                                <array>
                                        <dict>
                                                <key>Content Hint</key>
                                                <string>5265636F-7665-11AA-AA11-00306543ECAC</string>
                                                <key>Leaf</key>
                                                <true/>
                                        </dict>
                                        <dict>
                                                <key>Content Hint</key>
                                                <string>Apple_Recovery</string>
                                                <key>Leaf</key>
                                                <true/>
                                        </dict>
                                        <dict>
                                                <key>Content Hint</key>
                                                <string>48465300-0000-11AA-AA11-00306543ECAC</string>
                                                <key>Leaf</key>
                                                <true/>
                                        </dict> 


  • now, create /Volumes/Patchstick-root/sbin/launchd with your favourite text editor (vi/pico/joe/...) and make it look like this:
#!/sbin/bash

exec 2>/dev/console
exec 1>/dev/console

echo
echo " --- AppleTV Patchstick ---"
echo

# echo "* remounting / r/w"
# /sbin/mount -uw /

echo "* mounting OSBoot partition r/o"
/sbin/mount -t hfs -r /dev/disk0s3 /OSBoot

echo "* re-mounting OSBoot partition r/w"
/sbin/mount -uw /OSBoot

echo "* mounting stuff partition r/o"
/sbin/mount -t hfs -r /dev/disk1s2 /stuff

if [ -d /OSBoot/dev/ ]; then

  for i in /stuff/installer.d/*; do
    echo "--- ${i} ---"
    /sbin/bash "${i}"
  done

  /sbin/sync &>/dev/null
  /sbin/umount /OSBoot
  echo "all done!"

else
  echo "! OSBoot not mounted, not installing or modifying anything"
fi


echo
echo "Now, you can reboot your AppleTV by unplugging/replugging the power supply."
/sbin/sleep 100000
  • make our launchd replacement executable:
hostname:/Volumes/Patchstick-root root# chmod 755 /Volumes/Patchstick-root/sbin/launchd
  • add AppleTV's own boot.efi to the root of the patch stick.

The aftermath

  • unmount the partition:
hostname:~ root# hdiutil unmount /dev/diskXs1
"diskXs1" unmounted successfully
  • remove the HFS partition...
hostname:~ root# gpt remove -i 1 /dev/diskX
gpt remove: /dev/diskX: 1 partition(s) removed
  • ...and add a hidden one in it's place
gpt add -b 34 -s 163840 -i 1 -t "5265636F-7665-11AA-AA11-00306543ECAC" /dev/diskX

Adding patches

Patching just got a bit more modular. First, we have to create the scripts dir:

mkdir /Volumes/Patchstick/installer.d/

SSHD

To add SSH, do the following:

  • make the SSH directory:
mkdir /Volumes/Patchstick/ssh
  • create /Volumes/Patchstick/ssh/ssh.plist, make it look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <false/>
        <key>Label</key>
        <string>com.openssh.sshd</string>
        <key>Program</key>
        <string>/usr/libexec/sshd-keygen-wrapper</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/sshd</string>
                <string>-i</string>
        </array>
        <key>SessionCreate</key>
        <true/>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <dict>
                        <key>Bonjour</key>
                        <array>
                                <string>ssh</string>
                                <string>sftp-ssh</string>
                        </array>
                        <key>SockServiceName</key>
                        <string>ssh</string>
                </dict>
        </dict>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <false/>
        </dict>
</dict>
</plist>
  • copy the sshd binary to the patchstick:
cp /usr/sbin/sshd /Volumes/Patchstick/ssh/sshd
  • add an installer script:
#!/sbin/bash

# install ssh
# (c) 2007 macTijn at awkwardtv dot org

if [ -f /stuff/ssh/sshd ] && [ -f /stuff/ssh/ssh.plist ]; then
  echo -n "* installing SSH daemon... "
  cp /stuff/ssh/sshd /OSBoot/usr/sbin/sshd
  cp /stuff/ssh/ssh.plist /OSBoot/System/Library/LaunchDaemons/ssh.plist
  echo "done."
else
  echo "SSH files not found, not installing"
fi


All done! your patchstick should be completely done by now.

Extra's

Above installs SSHD for you on your AppleTV. But the script also mentions Perian and ATVFiles. You can add them as a bonus:

  • Perian:
    • download and mount the current Perian .dmg
    • copy Perian.component to /Volumes/Patchstick/stuff/
  • ATVFiles:
    • download and unpack the ATVFiles tarball
    • copy ATVFiles.frappliance to /Volumes/Patchstick/stuff/

TODO

  • [page] credits!
  • [page] add links to various items (semthex's kernel, Perian, ATVFiles)
  • [procedure] kill off unneeded kext stuff, takes too much space like this
  • [script] add more optional hacks
  • [script] hide patch messages, instead make animated (a la factory restore animation)

NOTES

so far, this list of .kext stuff is distilled (based on Kextstat_output):

AppleACPIPlatform.kext
AppleAPIC.kext
AppleEFIRuntime.kext
AppleFileSystemDriver.kext
AppleFlashNVRAM.kext
AppleHDA.kext
AppleHPET.kext
AppleIRController.kext
AppleRTC.kext
AppleSMBIOS.kext
AppleSMC.kext
AudioIPCDriver.kext
BootCache.kext
GeForce.kext
IO80211Family.kext
IOACPIFamily.kext
IOATAFamily.kext
IOAudioFamily.kext
IOGraphicsFamily.kext
IOHIDFamily.kext
IONDRVSupport.kext
IONetworkingFamily.kext
IOPCIFamily.kext
IOPlatformPluginFamily.kext
IOSCSIArchitectureModelFamily.kext
IOStorageFamily.kext
IOUSBFamily.kext
IOUSBMassStorageClass.kext
NVDANV40Hal.kext
NVDAResman.kext
OSvKernDSPLib.kext
System.kext