1
0
mirror of https://github.com/krislamo/kernmod.git synced 2024-11-12 17:40:35 +00:00

Compare commits

..

3 Commits

3 changed files with 59 additions and 28 deletions

7
.gitignore vendored
View File

@ -1,8 +1 @@
*.cmd
*.ko
*.mod*
*.o
.helloworld.o.d
.vagrant .vagrant
Module.symvers
modules.order

View File

@ -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 $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
View File

@ -0,0 +1,2 @@
*
!.gitignore