Skip to content

Commit

Permalink
Add Makefile and the autorun script to install this driver easily
Browse files Browse the repository at this point in the history
Signed-off-by: Deokgyu Yang <[email protected]>
  • Loading branch information
awesometic committed Jan 26, 2022
1 parent b4ed17a commit 6f69354
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2022 Deokgyu Yang <[email protected]>
#
# 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 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.

all: clean modules install install_rules

modules:
$(MAKE) -C src/ modules

clean:
$(MAKE) -C src/ clean

install: modules
$(MAKE) -C src/ install

install_rules:
$(MAKE) -C src/ install_rules
56 changes: 56 additions & 0 deletions autorun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default

TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net/usb -type d)
if [ "$TARGET_PATH" = "" ]; then
TARGET_PATH=/lib/modules/$(uname -r)/kernel/drivers/net
fi
echo
check=`lsmod | grep r8152`
if [ "$check" != "" ]; then
echo "rmmod r8152"
/sbin/rmmod r8152
fi

echo "Build the module and install"
echo "-------------------------------" >> log.txt
date 1>>log.txt
make $@ all 1>>log.txt || exit 1
module=`ls src/*.ko`
module=${module#src/}
module=${module%.ko}

echo "DEPMOD $(uname -r)"
depmod `uname -r`
echo "load module $module"
modprobe $module

is_update_initramfs=n
distrib_list="ubuntu debian"

if [ -r /etc/debian_version ]; then
is_update_initramfs=y
elif [ -r /etc/lsb-release ]; then
for distrib in $distrib_list
do
/bin/grep -i "$distrib" /etc/lsb-release 2>&1 /dev/null && \
is_update_initramfs=y && break
done
fi

if [ "$is_update_initramfs" = "y" ]; then
if which update-initramfs >/dev/null ; then
echo "Updating initramfs. Please wait."
update-initramfs -u -k $(uname -r)
else
echo "update-initramfs: command not found"
exit 1
fi
fi

echo "Completed."
exit 0

0 comments on commit 6f69354

Please sign in to comment.