This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/4] stap-prep: add support for deb based systems


---
 stap-prep |   75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/stap-prep b/stap-prep
index 24d7131..4a4c87c 100755
--- a/stap-prep
+++ b/stap-prep
@@ -46,11 +46,86 @@ if [ "$NEEDED" != "" ]; then
 fi
 }
 
+prep_deb_based() {
+if [ $# -ne 0 ]; then
+    echo "Specifying kernel version is not yet support on deb based systems." 1>&2
+    exit 1
+fi
+
+# 2.6.32-5-amd64
+# 2.6.32-37-generic
+ABINAME="$(cut -d " " -f 3 /proc/version)"
+
+# 2.6.32
+BASEVERSION="$(echo "$ABINAME" | cut -d "-" -f 1)"
+
+case "$DISTRO" in 
+    Debian) # 2.6.32-39
+	if uname -v | grep -q Debian; then
+	    VERSION="$(uname -v | cut -d " " -f 4)"
+	else
+	    VERSION="$(cut -d " " -f 5 /proc/version | cut -d ")" -f 1)"
+	fi
+	;;
+    Ubuntu)
+	# 2.6.32-37.81
+	VERSION="$(cut -d " " -f 2 /proc/version_signature | cut -d "-" -f 1-2)"
+	;;
+esac
+
+(
+    echo "make >= 0"
+    echo "linux-image-$ABINAME = $VERSION"
+    echo "linux-headers-$ABINAME = $VERSION"
+    echo "linux-kbuild-$BASEVERSION >= 0"
+    case "$DISTRO" in
+	Debian)
+	    echo "linux-image-$ABINAME-dbg = $VERSION"
+	    ;;
+	Ubuntu)
+	    echo "linux-image-$ABINAME-dbgsym = $VERSION"
+	    ;;
+    esac
+) | while read package relation requiredversion; do
+    installedversion="$(dpkg-query -W "$package" 2> /dev/null | cut -f 2)"
+    if [ "$installedversion" = "" ]; then
+	availableversion="$(apt-cache show $package 2> /dev/null | grep ^Version: | cut -d " " -f 2)"
+	if [ "$availableversion" = "" ]; then
+	    echo "You need package $package but it does not seem to be available"
+	    if [ "$DISTRO" = "Ubuntu" -a "$(echo $package | grep dbgsym$)" ]; then
+		echo " Ubuntu -dbgsym packages are typically in a separate repository"
+		echo " Follow https://wiki.ubuntu.com/DebuggingProgramCrash to add this repository"
+	    elif [ "$DISTRO" = "Debian" -a "$(echo $package | grep dbg$)" ]; then
+		echo " Debian does not have -dbg packages for all kernels. Consider switching to a kernel that has one."
+	    fi
+	else
+	    echo "Please install $package"
+	fi
+    elif ! dpkg --compare-versions $installedversion $relation $requiredversion; then
+	echo "Package $package version $installedversion does not match version of currently running kernel: $requiredversion"
+	echo " Consider apt-get upgrade && reboot"
+    fi
+done
+
+user="$(id --user --name)"
+if [ "$user" != "root" ]; then
+    groups="$(id --groups --name)"
+    for i in stapusr stapdev; do
+	if [ "$(echo $groups | grep $i)" = "" ]; then
+	    echo "Be root or adduser $user $i"
+	fi
+    done
+fi
+}
+
 DISTRO="$(lsb_release --id --short 2> /dev/null)"
 if [ $? -ne 0 ]; then
     DISTRO="unknown"
 fi
 case "$DISTRO" in
+Debian|Ubuntu)
+	prep_deb_based "$@"
+	;;
 *)
 	prep_rpm_based "$@"
 	;;
-- 
1.7.2.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]