Re: Re: Compiling kernel modules (was Re: 2 questions)

Charlie Brady <[email protected]>
Newsgroups gmane.network.e-smith.devel
Message-ID <[email protected]>
On Wed, 12 Nov 2003, Bruce Richardson wrote:

> Right.  I saw the note accompanying the freeswan modules, saying that
> there were problems with auto-selection.  Sounds as if it would be
> difficult to distribute a powerswitch rpm as anything other than a
> source rpm.

No, depends on your definition of difficult. It's difficult to build
correct binary RPMs until you work out how to trick the RedHat system.
Once you've done that, it's easy :-)

> > I've knocked up a spec file for building RPMs, but I notice that the
> > powerswitch source tarball does not come with any license.
...
> I talked about that to Joris and he said:
> 
> "I believe there is a line in the README file which states that it can
> be used and copied freely.

And modified even. Sorry, I missed that.

> The documentation with version 1.5 says "This program is freeware; you
> may use, modify and/or distribute it without restriction."  That's
> unambiguous enougn, I think.

> Ah, that would be good.  I'll look forward to inspecting the source rpm
> to see how I should have done it.

Spec file is attached. That should allow you to build your own binary 
RPMs. Use "rpmbuild -bb --target=xxx powerswitch.spec".

--
Charlie Brady                         [email protected]
Mitel Networks Corporation      http://www.mitel.com/
Phone: +1 (613) 592 5660 or 592 2122  Fax: +1 (613) 592 1175

A: Because we read from top to bottom, left to right.
Q: Why should i start my reply below the quoted text?

--
Please report bugs to [email protected]
Please mail [email protected] (only) to discuss security issues
Support for registered customers and partners to [email protected]
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Searchable archive at http://www.mail-archive.com/devinfo%40lists.e-smith.org
powerswitch.spec (text/plain, 2.5 KB)
# The version and release of the kernel is determined from
# the installed "kernel-source" rpm. You can specify difference
# values via "--define 'kversion xxx' --define 'krelease yyy'"
%{!?kversion: %{expand: %%define	kversion		%(rpm -q --qf="%{VERSION}" kernel-source)}}
%{!?krelease: %{expand: %%define	krelease		%(rpm -q --qf="%{RELEASE}" kernel-source)}}
Summary:  driver for ATX power switch
Name: powerswitch
Version: 1.5
Release: 1cb
License: freeware
Group: System Environment/Kernel
Vendor: Mitel Networks Corporation
Source0: http://workshy.org/download/powerswitch-1.5.tar.gz
Packager: Charlie Brady <[email protected]>
BuildRoot: %{_tmppath}/%{name}-root

%define modules /lib/modules/%{kversion}-%{krelease}

BuildRequires: kernel-source = %{kversion}-%{krelease}
Requires: kernel = %{kversion}-%{krelease}

%description
The powerswitch driver makes it possible to use the ATX power button
on your computer to shutdown Linux. You simply press the power button,
and the driver shuts down Linux and powers off the machine, just like
the shutdown command does.

%prep
if ! test -d /usr/src/linux-%{kversion}-%{krelease}/drivers/net; then
  echo "
  -----------------------------------------------------
  You don't seem to have a Linux %{kversion}-%{krelease} source tree installed!
  Please install the kernel-source-%{kversion}-%{krelease} RPM package."
  exit 1
fi
%setup -q -n %{name}

%build

CPU=%{_target_cpu}

for s in smp ""
do
    if [ "$s" = "smp" ]
    then
	SMP=1
    else
	SMP=0
    fi
    gcc -DMODULE -D__KERNEL__ \
     -D__BOOT_KERNEL_H_ \
     -D__MODULE_KERNEL_$CPU \
     -D__BOOT_KERNEL_SMP=$SMP \
     -DEXPORT_SYMTAB -DMODVERSIONS \
     -include \
     /usr/src/linux-%{kversion}-%{krelease}/include/linux/modversions.h \
     -Wall -Wstrict-prototypes -O6 -c \
     -Iinclude -I/usr/src/linux-%{kversion}-%{krelease}/include \
     -c powerswitch.c
    if [ "$s" = "smp" ]
    then
	mv powerswitch.o powerswitch.osmp
    fi
done

%install
for s in smp ""
do
    mkdir -p $RPM_BUILD_ROOT/%{modules}${s}/kernel/drivers/addon/powerswitch
    mv powerswitch.o${s} $RPM_BUILD_ROOT/%{modules}${s}/kernel/drivers/addon/powerswitch/powerswitch.o
done

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README
%{modules}/kernel/drivers/addon/powerswitch/powerswitch.o
%{modules}smp/kernel/drivers/addon/powerswitch/powerswitch.o

%changelog
* Tue Nov 11 2003 Charlie Brady <[email protected]>
- Initial
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.