mirror of
https://github.com/krislamo/kernmod.git
synced 2024-11-10 00:30:36 +00:00
Compare commits
3 Commits
e48f1aaf3c
...
42c46c0556
Author | SHA1 | Date | |
---|---|---|---|
42c46c0556 | |||
2523cb117b | |||
3dde1c3235 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1 @@
|
||||
*.cmd
|
||||
*.ko
|
||||
*.mod*
|
||||
*.o
|
||||
.helloworld.o.d
|
||||
.vagrant
|
||||
Module.symvers
|
||||
modules.order
|
||||
|
78
build.sh
78
build.sh
@ -1,29 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initial variables
|
||||
PACKAGE="helloworld"
|
||||
VERSION="0.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
|
||||
mkdir -p "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||
mkdir -p "$BUILDDIR/etc"
|
||||
mkdir -p "$BUILDDIR/DEBIAN"
|
||||
cp -r /vagrant/src/usr/src/* "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||
cp -r /vagrant/src/etc/* "$BUILDDIR/etc"
|
||||
cp -r /vagrant/src/DEBIAN/* "$BUILDDIR/DEBIAN"
|
||||
cd "$BUILDDIR/.."
|
||||
dpkg-deb --build "${PACKAGE}_$VERSION-$REVISION"
|
||||
# Build debian package
|
||||
function build_deb {
|
||||
[ $INSTALL -eq 1 ] && install_headers
|
||||
mkdir -p "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||
mkdir -p "$BUILDDIR/etc"
|
||||
mkdir -p "$BUILDDIR/DEBIAN"
|
||||
cp -r $SRCDIR/usr/src/* "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
|
||||
cp -r $SRCDIR/etc/* "$BUILDDIR/etc"
|
||||
cp -r $SRCDIR/DEBIAN/* "$BUILDDIR/DEBIAN"
|
||||
cd "$TEMPDIR"
|
||||
dpkg-deb --build "${PACKAGE}_$VERSION-$REVISION"
|
||||
}
|
||||
|
||||
# Install package
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y linux-headers-$(uname -r)
|
||||
apt-get install -y "./${PACKAGE}_$VERSION-$REVISION.deb"
|
||||
# Display details on module
|
||||
function info_mod {
|
||||
modinfo "$PACKAGE"
|
||||
cat /proc/modules | grep "$PACKAGE"
|
||||
rmmod "$PACKAGE"
|
||||
modprobe "$PACKAGE"
|
||||
cat /var/log/messages | grep "$PACKAGE"
|
||||
}
|
||||
|
||||
# Load module and show details about it
|
||||
modinfo helloworld
|
||||
cat /proc/modules | grep helloworld
|
||||
rmmod helloworld
|
||||
modprobe helloworld
|
||||
cat /var/log/messages | grep helloworld
|
||||
# Install Linux headers for current kernel
|
||||
function install_headers {
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y linux-headers-$(uname -r)
|
||||
}
|
||||
|
||||
# Build and install helloworld module or module(s) in $SCRATCH
|
||||
set -x
|
||||
if [ ! -z "$(ls -Al $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
|
||||
|
2
scratch/.gitignore
vendored
Normal file
2
scratch/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Loading…
Reference in New Issue
Block a user