Normalise line endings in Git repository without external tools

As it happens, I recently »inherited« a Git repository. It turned out that all files had been submitted with Windows line endings, also known as CRLF. Since the core.autocrlf wasn't set, they were stored as such in the repository.

Since it was a private repository that wasn't published anywhere (that I knew of or cared about), I decided to rewrite its history as a first step. I wanted to use Git's own conversion rather than relying on external tools such as fromdos, so I activated it using

$ git config core.autocrlf input
Then I wrote a small shell script called readd.sh that re-adds the current commit and triggers Git's line-ending conversion:
#!/bin/sh

git rm --cached -r .
git add -f .
The -f option to add ensures that even files that are in .gitignore are re-added. Yes, they even managed to submit ignored files into their repository...

As a last step, I used filter-branch to process every commit and apply my script.

$ git filter-branch --tree-filter "$HOME/readd.sh" -- --all

Since it was a very small repository, the entire process took only a matter of seconds, and I was left with a clean state with normalised line endings.

If I ruled the world...

To whom it may concern, particularly any political party that would like my vote:

  • Religious taxation and religious education at public schools is abolished to be replaced by philosophy. The subject currently called »maths« is renamed »arithmetic«.
  • Recreational drugs are legalised. The gained enforcement capacity is used to police speeding and parking offences and any other traffic violation that compromises the safety of others. Every incident is fined at a flat rate of €200.
  • The proceeds of traffic fines are used to actually make roads cycling friendly.
  • Tax relief and subsidies for commuting is scrapped. The funds are used to make public transport free for everyone to use.
  • Privately-owned compulsory health insurance is abolished. Doctors and hospitals are made free for everyone to use (administrative fees of €5-€10 per use apply), the health system is financed through income tax. Whether the income was gained through employment, capital gains or otherwise makes no difference and there are no upper or lower limits to each individual's contributions. Tax relief and subsidies for private health insurance is scrapped.
  • Tax relief and subsidies for private pension plans are scrapped. The public pension system based on annual turnover is adjusted such that 40 years' worth of contributions yield an equivalent pension income. Pension contributions are subsumed by income tax irrespective of whether the income was gained through employment, capital gains or otherwise.
  • Unemployment insurance and incapacity benefits are subsumed by income tax irrespective of whether the income was gained through employment, capital gains or otherwise.
  • Tax relief and subsidies for real estate are abolished, personal use excepted. Income from rent is treated like any other income.

As you have probably guessed I'm not an economist. But I figure that just the simplifications from these changes would make for a much more pleasant life...

Yosemite with audio on DH87RL with Realtek ALC892

The following is now obsolete thanks to AppleALC which only requires the kernel parameter :Boot:Arguments alcid=1.


In order to get audio functionality in Yosemite on my DH87RL motherboard, I follow toleda's method using Clover. The exact method is encoded as a shell script with the required files in a couple of repositories.

The first task is to find out the current layout-id using the command

$ ioreg -nHDEF -r -w0
There should be a section called "HDEF@1B" with a key "layout-id" showing a value.

In my case, the value was 0 which is not a good sign. Thankfully, Clover can patch it by adding the string value :Devices:Audio:Inject with the desired value "1".

After rebooting, the command

$ ioreg -rxnIOHDACodecDevice
identifies my audio chip as vendor and device 0x10ec0892 (Realtek ALC892) and revision 0x100302 (current).

Now I downloaded and unpacked config-audio_cloverALC.plist.zip and copied the two relevant entries from :KernelAndKextPatches:KextsToPatch to my config.plist: Item 0 with comment »10.9-10.10-AppleHDA/Resources/xml>zml« (the purpose of which will become clear in a little while) and Item 4, »10.9-10.10-AppleHDA/Realtek ALC892«.

Then I downloaded and unpacked realtekALC.kext and installed it into my EFI/CLOVER/OEM/DH87RL/kexts/10.10 folder. Finally, I renamed the files Platforms.xml.zlib and layout[123].xml.zlib from 892.zip to *.zml.zlib, installed them in my /System/Library/Extensions/AppleHDA.kext/Contents/Resources folder and made them owned by root:wheel.

Next, I ensured that the :SystemParameters:InjectKexts was enabled in my config.plist ("Detect") and that :Boot:Arguments contained "kext-dev-mode=1" and rebooted with rebuilding kext cache.

An active remote client has recently sent requests to this machine

Trying to get Windows 7 to sleep is notoriously difficult. Like many, I was in the situation that I got the following message:

C:\Windows\system32>powercfg /requests
DISPLAY:
None.

SYSTEM:
[DRIVER] \FileSystem\srvnet
An active remote client has recently sent requests to this machine.

AWAYMODE:
None.

Needless to say, the Management Console's fsmgmt.msc was silent about any active sessions, so the message seems to be a lie.

In order to make the message disappear, I ended up creating a homegroup, activating media streaming and waiting for the whole process to finish (there is a message in the control panel while it is still busy »sharing«). Afterwards, I simlpy »left« the homegroup again, and voilá, the srvnet request disappeared.

There is also a setting in the advanced power options about letting the computer sleep while sharing media, but that seems to have no effect either way.

Running Yosemite on UEFI hardware

I use the Clover boot loader in a UEFI-only installation on the ESP with the »BootCamp« theme. The only UEFI driver I need is OsxAptioFix2Drv-64 -- without it I get ???.

The best source for up-to-date kexts I've found is to download the current MultiBeast installer. The »Contents/Resources« folder of »MultiBeast.app« contains packages which can be expanded using

$ pkgutil --expand FakeSMC-v6.14.1364.pkg p
$ pax -rzf p/Payload

For my Intel DH87RL, I drop FakeSMC.kext and AppleIntelE1000e.kext into the corresponding folder OEM/DH87RL/kexts/10.10 on the ESP.

After installing new kexts, a reboot »without caches« must be performed by selecting the boot entry with space bar in Clover and selecting the corresponding entry.

My configuration file OEM/DH87RL/config.plist contains

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>ACPI</key>
 <dict>
  <key>SSDT</key>
  <dict>
   <key>EnableC6</key>
   <true/>
   <key>Generate</key>
   <dict>
    <key>CStates</key>
    <true/>
    <key>PStates</key>
    <true/>
   </dict>
  </dict>
 </dict>
 <key>Boot</key>
 <dict>
  <key>DefaultVolume</key>
  <string>LastBootedVolume</string>
  <key>Timeout</key>
  <integer>5</integer>
  <key>Log</key>
  <false/>
 </dict>
 <key>GUI</key>
 <dict>
  <key>Scan</key>
  <true/>
  <key>Custom</key>
  <dict>
   <key>Legacy</key>
   <array>
    <dict>
     <key>Type</key>
     <string>Windows</string>
     <key>Hidden</key>
     <true/>
    </dict>
   </array>
  </dict>
 </dict>
 <key>KernelAndKextPatches</key>
 <dict>
  <key>Debug</key>
  <false/>
  <key>KernelPm</key>
  <true/>
 </dict>
 <key>RtVariables</key>
 <dict>
  <key>MountEFI</key>
  <false/>
 </dict>
 <key>SystemParameters</key>
 <dict>
  <key>InjectKexts</key>
  <string>Detect</string>
 </dict>
</dict>
</plist>

Deploy Windows RE on system partition

I have been fighting with REAgentC to allow me to install the WinRE image to the system partition (8).

I have gone through numerous errors like »the product has been uninstalled«, »there is insufficient space on the device«, »the operation cannot be completed due to a file system limitation« and the pair of »cannot find the file/path specified« or »file cannot be created because it exists«.

I think the »cannot be created« error was the result of copying an existing boot.sdi ramdisk along with the winre.wim. This is wrong, REAgentC creates the ramdisk.

One thing I've noticed is that at least on an MBR disk, an NTFS partition is required in order to successfully enable WinRE on the system partition. If it's FAT32, I got misleading errors about »insufficient space« until I enlarged it, which then told me it could not complete the operation due to »file system limitations.«

If REAgentC is confused by the current contents of %systemroot%\System32\Recovery\ReAgent.xml, replace by a blank file:

<?xml version='1.0' encoding='utf-8'?>
<WindowsRE version="1.0">
    <WinreBCD id=""/>
    <WinreLocation path="" id="0" offset="0"/>
    <ImageLocation path="" id="0" offset="0"/>
    <OsInstallLocation path="" id="0" offset="0"/>
    <InstallState state="0"/>
    <OsInstallAvailable state="0"/>
    <WinREStaged state="0"/>
    <OperationParam path=""/>
    <OsBuildVersion path=""/>
    <OemTool state="0"/>
    <BootKey state="0"/>
    <IsServer state="0"/>
    <ScheduledOperation state="4"/>
</WindowsRE>

With the recovery partition on R:, the commands

md r:\Recovery\WindowsRE
xcopy /h %systemroot%\System32\Recovery\winre.wim r:\Recovery\WindowsRE
reagentc /setreimage /path R:\Recovery\WindowsRE /target %systemroot%
reagentc /enable
succeed and eventually produced this file:

<?xml version='1.0' encoding='utf-8'?>
<WindowsRE version="1.0">
    <WinreBCD id="{30f4463f-add1-11e4-97b2-e8db73286102}"/>
    <WinreLocation path="\Recovery\WindowsRE" id="196858822" offset="1048576" guid="{00000000-0000-0000-0000-000000000000}"/>
    <ImageLocation path="\Recovery\WindowsRE" id="196858822" offset="1048576" guid="{00000000-0000-0000-0000-000000000000}"/>
    <OsInstallLocation path="" id="0" offset="0" guid="{00000000-0000-0000-0000-000000000000}"/>
    <InstallState state="1"/>
    <OsInstallAvailable state="0"/>
    <WinREStaged state="0"/>
    <OperationParam path=""/>
    <OsBuildVersion path="7601.18700.amd64fre.win7sp1_gdr.141211-1742"/>
    <OemTool state="0"/>
    <BootKey state="0"/>
    <IsServer state="0"/>
    <ScheduledOperation state="4"/>
</WindowsRE>

Note that it's apparently impossible to issue the »/enable« command from Recovery Environment because it doesn't support the »/target« switch.

And here are the relevant boot loader entries created by REAgentC for this case:

Windows-Start-Manager
---------------------
Bezeichner              {bootmgr}
device                  partition=\Device\HarddiskVolume1
description             Windows Boot Manager
locale                  de-de
inherit                 {globalsettings}
default                 {current}
resumeobject            {30f44639-add1-11e4-97b2-e8db73286102}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows-Startladeprogramm
-------------------------
Bezeichner              {current}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Windows 7
locale                  de-de
inherit                 {bootloadersettings}
recoverysequence        {30f4463f-add1-11e4-97b2-e8db73286102}
recoveryenabled         Yes
osdevice                partition=C:
systemroot              \Windows
resumeobject            {30f44639-add1-11e4-97b2-e8db73286102}
nx                      OptIn
detecthal               Yes

Windows-Startladeprogramm
-------------------------
Bezeichner              {30f4463f-add1-11e4-97b2-e8db73286102}
device                  ramdisk=[\Device\HarddiskVolume1]\Recovery\WindowsRE\Winre.wim,{30f44640-add1-11e4-97b2-e8db73286102}
path                    \windows\system32\winload.exe
description             Windows Recovery Environment
inherit                 {bootloadersettings}
osdevice                ramdisk=[\Device\HarddiskVolume1]\Recovery\WindowsRE\Winre.wim,{30f44640-add1-11e4-97b2-e8db73286102}
systemroot              \windows
nx                      OptIn
winpe                   Yes

Geräteoptionen
--------------
Bezeichner              {30f44640-add1-11e4-97b2-e8db73286102}
description             Ramdisk Options
ramdisksdidevice        partition=\Device\HarddiskVolume1
ramdisksdipath          \Recovery\WindowsRE\boot.sdi

For the tools to work, the system and recovery partition must be type id 0x27 on an MBR disk. The MBR and GPT partition types are:

Recovery300MBNTFS0x27de94bba4-06d1-4d40-a16a-bfd50179d6ac
ESP100MBFAT320x27c12a7328-f81f-11d2-ba4b-00a0c93ec93b
MSR128MBNTFS0x7e3c9e316-0b5c-4db8-817d-f92df00215ae
OSNTFS0x7ebd0a0a2-b9e5-4433-87c0-68b6b72699c7

Other tools

Helpful tools I've used (apart from REAgentC and bcdedit, obviously) include bcdboot %systemroot% /l en-us /s s: to copy the required files to the boot partition and set the desired locale and the Recovery Environment commands bootsect /nt60 %systemroot%, bootrec /fixboot and bootrec /fixmbr (the latter apparently Windows XP relics) to restore a partition's boot loader.

Did you know

…you can start WordPad using "write" from the cmd line? Very useful when editing LF-only files as administrator…