[ltp] more /dev/thinkpad

linux-thinkpad@linux-thinkpad.org linux-thinkpad@linux-thinkpad.org
Sun, 17 Jul 2005 16:58:55 +0100 (BST)


On Sun, 17 Jul 2005, Tom Adelstein wrote:

> On 7/17/05, honey@gneek.com <honey@gneek.com> wrote:
>>
>> I'd imagine the Extras repositories has plans for a
>> kernel-modules-thinkpad package (which includes /dev/thinkpad), as
>> they already have tpctl and configure-thinkpad in there for Fedora
>> Core 4 - I haven't checked the bugzilla yet.  If it has any
>> proprietary parts to it, the Livna repository will have plans -
>> either way it will install simply with yum.  I guess it's on the TODO
>> list - I can ask around.
>>
>> In the meantime, I'm just playing with the spec file to build an RPM
>> for it from Dag Wieers' RPM, which is quite outdated and for kernel
>> 2.4. It looks like I have it at least building now, but it needs a
>> little tweaking.  If anyone's interested, I'll send back my spec file
>> to Dag, and I guess he'll include an updated RPM soon.  Or if you're
>> ok for building your own RPM from a spec file (it'll need rebuilding
>> for each new kernel) I could send it to anyone, if wanted.
>>
>> It's a bit hacky just now, so I'll try and clean it up.  And make
>> sure it actually works :)  But /dev/thinkpad for FC4 doesn't look
>> hard to do.
>> --
>
> That would be a great service. I would be very grateful. Also, I'm
> guessing but the Thinkpad seems to be a very popular choice.
>

OK, quick rush at a spec file below.  Just to emphasis, this
is only for FC4 - it relies on the new kernel-devel package.
It could be much improved and generalised for all Red Hat-based
distributions, which I'm sure is Dag's and RPMForge's aim.
I'll copy this also to Dag, in case my hack is useful (Dag,
I broke your define kernel line, as it's a rushed job :) ).
I imagine this list doesn't accept attachments, so you'll need to
download the thinkpad tarball yourself.  Save the spec file below as
"kernel-module-thinkpad-5.8.4-dag-gnk-fc4.spec" - be careful about
linebreaks.  Note you'll need the rpm-build RPM installed to build.
Then quick instructions:

First patch thinkpad to 5.8.4: go to
ftp://ftp.debian.org/debian/pool/main/t/thinkpad/ and download
thinkpad_5.8.orig.tar.gz and thinkpad_5.8-4.diff.gz
% tar xfz thinkpad_5.8.orig.tar.gz
% gunzip thinkpad_5.8-4.diff.gz
% cd thinkpad-5.8.orig
% patch -p1 < ../thinkpad_5.8-4.diff
% cd ..
% mv thinkpad-5.8.orig thinkpad-5.8.4
% tar cfz thinkpad_5.8.4.tar.gz thinkpad-5.8.4

Then copy to the build area and build the RPM, install it:
% cp thinkpad_5.8.4.tar.gz /usr/src/redhat/SOURCES/
% rpmbuild -ba --target=i686 kernel-module-thinkpad-5.8.4-dag-gnk-fc4.spec
# rpm -ivh <the rpm file specified above>
# depmod -ae
# modprobe thinkpad

Once you've done this, provided your repositories are set up ok, you
should be able to simply:
# yum install tpctl configure-thinkpad

I think I have that right - apologies for typos.  Seems to works for
me, as far as these utils are useful for ACPI users.  Note that I
can't actually fix thinkpad itself for you if something doesn't work
in FC4(!), and if you don't understand the above you should probably just
wait for one of the repositories to ship kernel-module-thinkpad :)
Or file a bugzilla, if there isn't one filed.  Note also that Dag did most
of the work, not me!  My hacks marked "#GNK".

Spec file:

---


# $Id: kernel-module-thinkpad.spec 2005-07-17 gnk $
# Authority: gnk
# Upstream Dag Wieers <dag@wieers.com>
# UpUpstream: Thomas Hood <jdthood@yahoo.co.uk>

# Archs: i686 i586 i386 athlon
# Distcc: 0
# Soapbox: 0
# BuildAsRoot: 1

%define _libmoddir /lib/modules

%define real_name thinkpad

#GNK broken external kernel --defines - hack for now
#%{!?kernel:%define kernel %(rpm -q kernel-devel --qf '%{RPMTAG_VERSION}-%{RPMTAG_RELEASE}' | tail -1)}
%define kernel %(uname -r)

%define kversion %(echo "%{kernel}" | sed -e 's|-.*||')
%define krelease %(echo "%{kernel}" | sed -e 's|.*-||')

%define moduledir /kernel/drivers/thinkpad
#GNK
%define modules rtcmosram.ko smapi.ko superio.ko thinkpad.ko thinkpadpm.ko

Summary: IBM ThinkPad kernel modules
Name: kernel-module-thinkpad
Version: 5.8.4
Release: 0_%{kversion}_%{krelease}.gnk
License: GPL
Group: System Environment/Kernel
URL: http://tpctl.sf.net/

Packager:Gneeki <gneeki@gmail.com>
Vendor: Gneeki

Source0: http://dl.sf.net/tpctl/thinkpad_%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root


BuildRequires: kernel-devel
Requires: /boot/vmlinuz-%{kversion}-%{krelease}

Obsoletes: thinkpad, kernel-thinkpad
Provides: thinkpad, kernel-thinkpad
Provides: kernel-modules

%description
IBM ThinkPad kernel modules.

These drivers are built for kernel %{kversion}-%{krelease}.
They might work with newer/older kernels.

%prep
%setup -n %{real_name}-%{version}

### FIXME: Remove chown/chgrp from Makefile. (Please fix upstream)
%{__perl} -pi.orig -e '
 		s| -o 0 -g 0 | |;
 		s|^(DIR_MOD):=(.+)$|$1:=\$(RPM_BUILD_ROOT)$2|;
 		s|^(DIR_MOD_VER):=.*$|$1:=\$(DIR_MOD)/%{kversion}-%{krelease}/kernel/drivers|;
 		s|^(CFLAGS):=(.*)$|$1:=$2 \$(RPM_OPT_FLAGS)|;
 	' Makefile */*/Makefile

%{__cat} <<EOF >README.modules.conf
To enable the thinkpad kernel modules, place the following to your
/etc/modules.conf:

alias char-major-10-170 thinkpad
EOF

#GNK comment back in with 2.6 as per README - could generalise for
#GNK kernel version
%{__ln_s} -f 2.6/drivers/ .
%{__ln_s} -f 2.6/include/ .

%build
%{__rm} -rf %{buildroot}
echo -e "\nDriver version: %{version}\nKernel version: %{kversion}-%{krelease}\n"

### Prepare UP kernel.
#GNK - fixed path but actually not needed in FC4
#cd %{_usrsrc}/kernels/%{kversion}-%{krelease}-%{_target_cpu}
#%{__make} -s distclean &>/dev/null
#%{__cp} -f configs/kernel-%{kversion}-%{_target_cpu}.config .config
#%{__make} -s symlinks oldconfig dep EXTRAVERSION="-%{krelease}" &>/dev/null
#cd -

### Make UP module.
%{__make} %{?_smp_mflags} clean all \
 	KSRC="%{_libmoddir}/%{kversion}-%{krelease}/build"
#GNK
#cd 2.4/drivers/
cd drivers/
%{__install} -d -m0755 %{buildroot}%{_libmoddir}/%{kversion}-%{krelease}%{moduledir}
%{__install} -m0644 %{modules} %{buildroot}%{_libmoddir}/%{kversion}-%{krelease}%{moduledir}

%install
%{__install} -d -m0755 %{buildroot}/dev \
 			%{buildroot}%{_mandir}/man4
touch %{buildroot}/dev/thinkpad
%{__install} -m0644 man/*.4 %{buildroot}%{_mandir}/man4/

### FIXME: A manual page should not be part of a kernel module package, added to documentation.
%{__rm} -rf %{buildroot}%{_mandir}

%post
if [ "$1" -ne 0 ]; then
 	groupadd -r thinkpad
 	if [ ! -e /dev/thinkpad ]; then
 		mknod -m0664 /dev/thinkpad c 10 170
 	fi
 	chown root:thinkpad /dev/thinkpad
fi
/sbin/depmod -ae %{kversion}-%{krelease} || :

%postun
groupdel thinkpad
/sbin/depmod -ae %{kversion}-%{krelease} || :

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc AUTHORS ChangeLog COPYING README* SUPPORTED-MODELS TECHNOTES man/
#%doc %{_mandir}/man4/*
%{_libmoddir}/%{kversion}-%{krelease}%{moduledir}/
%ghost /dev/thinkpad

%changelog
* Sat Jul 17 2005 Gneeki <gneeki@gmail.com> - 5.8.4-0
- Updated for FC4/5.8.4.

* Sat Mar 06 2004 Dag Wieers <dag@wieers.com> - 5.0-0
- Updated to release 5.0.

* Thu Dec 04 2003 Dag Wieers <dag@wieers.com> - 4.8-0
- Updated to release 4.8.

* Fri Jul 18 2003 Dag Wieers <dag@wieers.com> - 4.3-3
- Moved manpage to documentation directory.

* Fri Apr 11 2003 Dag Wieers <dag@wieers.com> - 4.3-1
- Updated to release 4.3.

* Tue Mar 11 2003 Dag Wieers <dag@wieers.com> - 4.0-0
- Initial package. (using DAR)