# Install a udev rule on Netwinder machines to make sure the network
# interfaces receive the same names as used by the firmware.

if [ "$(archdetect)" == "arm/netwinder" ]; then
	cat > /etc/udev/rules.d/71-netwinder_net.rules <<EOF
# Make sure Linux uses the same names for network interfaces as the
# Netwinder firmware.  This rules file was created by the Debian
# installer.

SUBSYSTEM=="net", DRIVERS=="ne2k-pci", NAME="eth0"
SUBSYSTEM=="net", DRIVERS=="tulip", NAME="eth1"
EOF

	# Create a base-installer.d script to copy this rules file to the target
	mkdir -p /usr/lib/base-installer.d
	cat > /usr/lib/base-installer.d/06udev-netwinder-net << EOF
#!/bin/sh -e

RULESDIR=etc/udev/rules.d

mkdir -p /target/\$RULESDIR
cp /\$RULESDIR/71-netwinder_net.rules /target/\$RULESDIR 2>/dev/null || true
EOF

	chmod +x /usr/lib/base-installer.d/06udev-netwinder-net
fi

