mirror of
https://github.com/krislamo/kernmod.git
synced 2024-12-16 03:40:35 +00:00
Organize and add flexibility
This commit is contained in:
parent
e48f1aaf3c
commit
3dde1c3235
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@
|
|||||||
.vagrant
|
.vagrant
|
||||||
Module.symvers
|
Module.symvers
|
||||||
modules.order
|
modules.order
|
||||||
|
scratch
|
||||||
|
78
build.sh
78
build.sh
@ -1,29 +1,65 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Initial variables
|
||||||
PACKAGE="helloworld"
|
PACKAGE="helloworld"
|
||||||
VERSION="0.1"
|
VERSION="0.1"
|
||||||
REVISION="1"
|
REVISION="1"
|
||||||
BUILDDIR="$(mktemp -d)/${PACKAGE}_$VERSION-$REVISION"
|
SRCDIR="/vagrant/src"
|
||||||
|
SCRATCH="/vagrant/scratch"
|
||||||
|
OUTDIR="$SCRATCH"
|
||||||
|
TEMPDIR="$(mktemp -d)"
|
||||||
|
INSTALL=0
|
||||||
|
BUILDDIR="$TEMPDIR/${PACKAGE}_$VERSION-$REVISION"
|
||||||
|
|
||||||
# Place sources and build package
|
# Build debian package
|
||||||
mkdir -p "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
function build_deb {
|
||||||
mkdir -p "$BUILDDIR/etc"
|
[ $INSTALL -eq 1 ] && install_headers
|
||||||
mkdir -p "$BUILDDIR/DEBIAN"
|
mkdir -p "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||||
cp -r /vagrant/src/usr/src/* "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
mkdir -p "$BUILDDIR/etc"
|
||||||
cp -r /vagrant/src/etc/* "$BUILDDIR/etc"
|
mkdir -p "$BUILDDIR/DEBIAN"
|
||||||
cp -r /vagrant/src/DEBIAN/* "$BUILDDIR/DEBIAN"
|
cp -r $SRCDIR/usr/src/* "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||||
cd "$BUILDDIR/.."
|
cp -r $SRCDIR/etc/* "$BUILDDIR/etc"
|
||||||
dpkg-deb --build "${PACKAGE}_$VERSION-$REVISION"
|
cp -r $SRCDIR/DEBIAN/* "$BUILDDIR/DEBIAN"
|
||||||
|
cd "$TEMPDIR"
|
||||||
|
dpkg-deb --build "${PACKAGE}_$VERSION-$REVISION"
|
||||||
|
}
|
||||||
|
|
||||||
# Install package
|
# Display details on module
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
function info_mod {
|
||||||
apt-get update
|
modinfo "$PACKAGE"
|
||||||
apt-get install -y linux-headers-$(uname -r)
|
cat /proc/modules | grep "$PACKAGE"
|
||||||
apt-get install -y "./${PACKAGE}_$VERSION-$REVISION.deb"
|
rmmod "$PACKAGE"
|
||||||
|
modprobe "$PACKAGE"
|
||||||
|
cat /var/log/messages | grep "$PACKAGE"
|
||||||
|
}
|
||||||
|
|
||||||
# Load module and show details about it
|
# Install Linux headers for current kernel
|
||||||
modinfo helloworld
|
function install_headers {
|
||||||
cat /proc/modules | grep helloworld
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
rmmod helloworld
|
apt-get update
|
||||||
modprobe helloworld
|
apt-get install -y linux-headers-$(uname -r)
|
||||||
cat /var/log/messages | grep helloworld
|
}
|
||||||
|
|
||||||
|
# Build and install helloworld module or module(s) in $SCRATCH
|
||||||
|
set -x
|
||||||
|
if [ ! -z "$(ls -Al /vagrant/scratch/ | grep -e ^d)" ]; then
|
||||||
|
cd "$SCRATCH"
|
||||||
|
for d in */ ; do
|
||||||
|
if [ -f "$(basename $d)/override.sh" ]; then
|
||||||
|
SRCDIR="$(pwd)/$(basename $d)"
|
||||||
|
. "$(basename $d)/override.sh"
|
||||||
|
build_deb
|
||||||
|
if [ $INSTALL -eq 1 ]; then
|
||||||
|
apt-get install -y "./${PACKAGE}_$VERSION-$REVISION.deb"
|
||||||
|
info_mod
|
||||||
|
fi
|
||||||
|
cp "./${PACKAGE}_$VERSION-$REVISION.deb" \
|
||||||
|
"$OUTDIR/${PACKAGE}_$VERSION-$REVISION-$(date +%s).deb"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
INSTALL=1
|
||||||
|
build_deb
|
||||||
|
apt-get install -y "./${PACKAGE}_$VERSION-$REVISION.deb"
|
||||||
|
info_mod
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user