#!/bin/sh
grep sv_SE.UTF-8 /etc/locale.gen >/dev/null||{
	echo "Please add sv_SE.UTF-8 to your /etc/locale.gen and run locale-gen"
}

cvs -d:pserver:anonymous@cvs.sf.net/cvsroot/rtl8180-sa2400 co rtl8180-sa2400-dev
version=`cat rtl8180-sa2400-dev/CHANGES|grep '^V '|head -1|sed 's/^..//'`
cvsdate=`LC_ALL=sv_SE.UTF-8 ls -lt rtl8180-sa2400-dev|egrep -v "CVS|total"|head -1|awk '{print $6}'|tr -d '-'`
mv rtl8180-sa2400-dev rtl8180-sa2400-dev-$version.cvs.$cvsdate
cd rtl8180-sa2400-dev-$version.cvs.$cvsdate
mkdir driver
mv *.c *.h Makefile* driver
echo 'all:
	make -C driver

install:
	make -C driver install' > Makefile
dh_make --kmod
cd debian
mv changelog changelog.dh_make
cat changelog.dh_make|sed 's/#nnnn.*/#314719/'>changelog

cp rules rules.dh_make
echo '--- rules.org	2005-10-27 12:33:11.453663381 +0200
+++ rules	2005-10-27 12:33:45.154694445 +0200
@@ -64,7 +64,7 @@
 # kdist* rules. It is responsible for cleaning up any changes that have
 # been made by the other kdist_commands (except for the .deb files created)
 kdist_clean: clean
-  	$(MAKE) $(MFLAGS) -f debian/rules clean
+	$(MAKE) $(MFLAGS) -f debian/rules clean
 #	rm -f driver/*.o driver/*.ko
 #
 ### end  KERNEL SETUP
@@ -144,9 +144,10 @@
 
 	# Create the directories to install the source into
 	dh_installdirs -p$(psource)  usr/src/modules/$(sname)/debian
+	dh_installdirs -p$(psource)  usr/src/modules/$(package)/debian
 
 	# Copy only the driver source to the proper location
-	cp -s driver/*  debian/$(psource)/usr/src/modules/$(package)
+	cp driver/*  debian/$(psource)/usr/src/modules/$(package)
 	# Copy the needed debian/ pieces to the proper location
 	cp debian/*modules.in* \
 		debian/$(psource)/usr/src/modules/$(package)/debian'|patch -p0

cd ..
echo '--- driver/Makefile.org	2005-10-27 12:39:34.800017413 +0200
+++ driver/Makefile	2005-10-27 12:39:47.514011066 +0200
@@ -6,7 +6,7 @@
 KVER := $(shell uname -r)
 KSRC := /lib/modules/$(KVER)/build
 include $(KSRC)/.config
-INSTALL_PREFIX :=
+INSTALL_PREFIX := $(DESTDIR)
 EXTRA_CFLAGS += -std=gnu89
 EXTRA_CFLAGS += -O2
 EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y'|patch -p0
dpkg-buildpackage -rfakeroot
