From 173a4fab89b786e9f6cc2474860592336cae5d71 Mon Sep 17 00:00:00 2001 From: smckown Date: Thu, 28 Aug 2008 19:53:29 +0000 Subject: [PATCH] This project's new upper-level Makefile will build a debian source package that can be used to build a debian package that installs and uninstalls correctly. --- Makefile | 78 ++++++++++++++++++++++++++++++ debian.in/changelog | 5 ++ debian.in/control | 17 +++++++ debian.in/copyright | 13 +++++ debian.in/postinst | 8 ++++ debian.in/postrm | 7 +++ debian.in/rules | 112 ++++++++++++++++++++++++++++++++++++++++++++ src/installmod | 2 +- 8 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 debian.in/changelog create mode 100644 debian.in/control create mode 100644 debian.in/copyright create mode 100755 debian.in/postinst create mode 100755 debian.in/postrm create mode 100755 debian.in/rules diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d4418cd --- /dev/null +++ b/Makefile @@ -0,0 +1,78 @@ +# Makefile for newer cp2101 driver, we call cp210x +# Essentially, it makes a debian source package which +# then can be built by pbuilder, etc. + +DEBDIST = hardy +BUILD = build +KVER := $(shell uname -r) +KSRCVER := $(shell echo $(KVER) | sed -e 's/-[0-9][^-]*-[a-zA-Z][^-]*$$//') +PKGVER = 0.11 +SVNRELEASE := $(shell svn info | grep "Revision: " | sed -e s'/^[^0-9]*\([0-9]*\).*$$/\1/') +DEBRELEASE := 0rsm$(SVNRELEASE) +DEBVER := $(PKGVER)-$(DEBRELEASE) +RFC822DATE := $(shell date --rfc-822) +ROOTNAME := cp210x +PACKAGE := $(ROOTNAME)-module-$(KVER) +TARFILE := $(PACKAGE)_$(DEBVER).orig.tar.gz +DEBSRC := $(PACKAGE)-$(PKGVER) +ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEBFILE := $(BUILD)/$(PACKAGE)_$(DEBVER)_$(ARCH).deb +DEBSRCFILE := $(BUILD)/$(PACKAGE)_$(DEBVER).dsc + + +source: $(DEBSRCFILE) +$(DEBSRCFILE): $(BUILD)/debian-stamp + cd $(BUILD) && dpkg-source -b $(DEBSRC) + touch $@ + + +binary: $(DEBFILE) +$(DEBFILE): $(BUILD)/debian-stamp + cd $(BUILD)/$(DEBSRC) && dpkg-buildpackage -sa -us -uc + + +$(BUILD)/src-stamp: $(wildcard src/*) + mkdir -p $(BUILD) + rm -rf $(BUILD)/$(DEBSRC) + cp -a src $(BUILD)/$(DEBSRC) + find $(BUILD)/$(DEBSRC) -name .svn -type d -exec rm -rf "{}" ";" 2>/dev/null || exit 0 + tar -C $(BUILD) -czf $(BUILD)/$(TARFILE) $(DEBSRC) + touch $@ + + +configure: $(BUILD)/debian-stamp +$(BUILD)/debian-stamp: $(BUILD)/src-stamp $(wildcard debian.in/*) + mkdir -p $(BUILD)/$(DEBSRC)/debian + rsync --quiet -avz --exclude=.svn/ debian.in/ $(BUILD)/$(DEBSRC)/debian/ + perl -i -pe 's/xxPACKAGExx/$(PACKAGE)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxROOTNAMExx/$(ROOTNAME)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxPKGVERxx/$(PKGVER)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxKVERxx/$(KVER)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxKSRCVERxx/$(KSRCVER)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxDEBVERxx/$(DEBVER)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxDEBDISTxx/$(DEBDIST)/g' $(BUILD)/$(DEBSRC)/debian/* + perl -i -pe 's/xxRFC822DATExx/$(RFC822DATE)/g' $(BUILD)/$(DEBSRC)/debian/* + touch $@ + + +clean: + rm -rf $(BUILD) + + +debug: + @echo "BUILD = $(BUILD)" + @echo "KVER = $(KVER)" + @echo "PKGVER = $(PKGVER)" + @echo "SVNRELEASE = |$(SVNRELEASE)|" + @echo "DEBRELEASE = $(DEBRELEASE)" + @echo "DEBVER = $(DEBVER)" + @echo "RFC822DATE = $(RFC822DATE)" + @echo "PACKAGE = $(PACKAGE)" + @echo "TARFILE = $(TARFILE)" + @echo "DEBSRC = $(DEBSRC)" + @echo "ARCH = $(ARCH)" + @echo "DEBFILE = $(BUILD)/$(PACKAGE)_$(DEBVER)_$(ARCH).deb" + @echo "DEBSRCFILE = $(BUILD)/$(PACKAGE)_$(DEBVER).dsc" + + +.PHONY: clean binary source configure diff --git a/debian.in/changelog b/debian.in/changelog new file mode 100644 index 0000000..6b0b8bc --- /dev/null +++ b/debian.in/changelog @@ -0,0 +1,5 @@ +xxPACKAGExx (xxDEBVERxx) xxDEBDISTxx; urgency=low + + * Auto packaged + + -- R. Steve McKown xxRFC822DATExx diff --git a/debian.in/control b/debian.in/control new file mode 100644 index 0000000..7546215 --- /dev/null +++ b/debian.in/control @@ -0,0 +1,17 @@ +Source: xxPACKAGExx +Section: devel +Priority: optional +Maintainer: R. Steve McKown +Standards-Version: 3.7.2.0 +Build-Depends: dpkg-dev (>= 1.13.9), binutils (>= 2.9.5.0.12), gcc (>= 4:4.2.2), dpatch, file, bzip2, lsb-release, linux-headers-xxKVERxx, linux-source-xxKSRCVERxx + +Package: xxPACKAGExx +Architecture: any +Depends: linux-image-xxKVERxx +Priority: extra +Description: Enhanced USB/serial kernel module for xxROOTNAMExx based devices. + This module blacklists the standard cp2101 module installed in the kernel, + effectively taking its place. This package will be obsolete once the ioctl + calls supporting the advanced features of the xxROOTNAMExx appear in the mainline + kernel source. This code is an enhanced version of Silicon Lab's xxPKGVERxx + driver. diff --git a/debian.in/copyright b/debian.in/copyright new file mode 100644 index 0000000..e2fb7d2 --- /dev/null +++ b/debian.in/copyright @@ -0,0 +1,13 @@ +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/debian.in/postinst b/debian.in/postinst new file mode 100755 index 0000000..77a08e6 --- /dev/null +++ b/debian.in/postinst @@ -0,0 +1,8 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + depmod -q xxKVERxx || true + modprobe -rq cp2101 || true +fi diff --git a/debian.in/postrm b/debian.in/postrm new file mode 100755 index 0000000..fdd7b35 --- /dev/null +++ b/debian.in/postrm @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + depmod -a +fi diff --git a/debian.in/rules b/debian.in/rules new file mode 100755 index 0000000..3eac6fc --- /dev/null +++ b/debian.in/rules @@ -0,0 +1,112 @@ +#!/usr/bin/make -f +# debian/rules file - for xxROOTNAMExx-module +# Based on sample debian/rules file - for GNU Hello (1.3). +# Copyright 1994,1995 by Ian Jackson. +# Copyright 1998-2007 James Troup +# I hereby give you perpetual unlimited permission to copy, +# modify and relicense this file, provided that you do not remove +# my name from the file itself. (I assert my moral right of +# paternity under the Copyright, Designs and Patents Act 1988.) +# This file may have to be extensively modified + +package = xxPACKAGExx +inst_dir = debian/tmp/lib/modules/xxKVERxx/kernel/drivers/usb/serial + +STRIP = strip --strip-unneeded --remove-section=.comment --remove-section=.note + +install_dir = install -d -m 755 +install_file = install -m 644 +install_script = install -m 755 +install_binary = install -m 755 -s + +DISTRIBUTION := $(shell lsb_release -is) + + +# At the current time (20080828) this package has to build from the source +# directory. For now, the solution is quite hackish: copy the source +# directory to the build directory before running configure. +tempdir := $(shell tempfile $(package)) + +configure-stamp: + $(checkdir) + rm -rf configure-stamp builddir + rm -f $(tempdir) + cp -a . $(tempdir) + mv -f $(tempdir) builddir + cd builddir && ./configure -kver xxKVERxx + touch $@ + + +build: build-stamp +build-stamp: configure-stamp + $(checkdir) + $(MAKE) -C builddir -f Makefile.go + touch $@ + + +install: install-stamp +install-stamp: checkroot build-stamp + $(checkdir) + rm -rf debian/tmp + $(install_dir) $(inst_dir) + chmod a+x builddir/installmod + $(MAKE) -C builddir -f Makefile.go \ + INSTALL_PREFIX=$$(pwd)/debian/tmp install + mv $(inst_dir)/cp2101.ko $(inst_dir)/xxROOTNAMExx.ko + $(install_dir) debian/tmp/etc/modprobe.d + echo "blacklist cp2101" > debian/tmp/etc/modprobe.d/$(package) +ifeq ($(with_strip),yes) + find debian/tmp -type f | xargs file | grep "ELF.*executable" | \ + cut -f 1 -d : | xargs $(STRIP) +endif + touch $@ + + +binary-indep: checkroot build install + : # Nothing to do + + +binary-arch: checkroot build install + $(checkdir) + : # install maintainer scripts + $(install_dir) debian/tmp/DEBIAN + $(install_script) debian/postinst debian/tmp/DEBIAN/postinst + $(install_script) debian/postrm debian/tmp/DEBIAN/postrm + : # install docs + $(install_dir) debian/tmp/usr/share/doc/$(package)/ + $(install_file) debian/changelog \ + debian/tmp/usr/share/doc/$(package)/changelog.Debian + $(install_file) debian/copyright debian/tmp/usr/share/doc/$(package)/ + : # Compress stuff that needs it + find debian/tmp/usr/share/doc/$(package)/ -type f ! -name copyright | \ + xargs gzip -9 + : # Finish it all up + find debian/tmp -type f | xargs file | grep ELF | cut -d: -f 1 | \ + xargs dpkg-shlibdeps + dpkg-gencontrol -isp $(CONFLICTS) + chown -R root:root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + + +binary: binary-indep binary-arch + + +clean: + $(checkdir) + -rm -rf debian/tmp builddir + -rm -fr debian/patched debian/files* debian/substvars + -rm -f *-stamp + + +define checkdir + test -f Makefile.go -a -f debian/rules +endef + + +checkroot: + $(checkdir) + test root = "`whoami`" + + +.PHONY: binary clean checkroot diff --git a/src/installmod b/src/installmod index 2334445..dda85a5 100644 --- a/src/installmod +++ b/src/installmod @@ -21,7 +21,7 @@ if [ -f $1 ] ; then echo "Installed $1 in $installpath" fi - depmod + #depmod exit 0 else echo "ERR: Module \"$1\" not present" -- 2.39.2