Move more shared code into scripts/kernel-version

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4050 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2012-01-07 09:06:24 +00:00
parent 3f876d0ce6
commit f2127c015f
3 changed files with 139 additions and 193 deletions
+6 -61
View File
@@ -23,53 +23,12 @@
# Function definitions #
########################
source $(dirname $0)/kernel-version
function usage {
echo "Usage: $0 <kernel version>"
}
# First three components of the kernel version number.
function kernel_version {
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p'
}
# Last component of the kernel version, or the empty string if $1 has only
# three components.
function patchlevel {
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
}
# Download the file from URL $1 and save it in the current directory.
function download_file {
if [ ! -e "$(basename "$1")" ]; then
if [ "${quiet_download}" = "false" ]; then
echo "Downloading $1 ..."
fi
wget -q -nc "$1"
fi
}
# Make sure the kernel tarball and patch file are present in directory
# ${kernel_sources}. Download any missing files from ${kernel_mirror}.
function download_kernel {
local kver="$(kernel_version $1)"
local plevel="$(patchlevel $1)"
local series="$1"
if [ "${series:0:2}" = "3." ]; then
series="3.x"
else
series="${series:0:3}"
fi
mkdir -p "${kernel_sources}" || return $?
test -w "${kernel_sources}" || return $?
(
cd "${kernel_sources}" || return $?
download_file "${kernel_mirror}/v$series/linux-$1.tar.xz" \
|| download_file "${kernel_mirror}/v$series/longterm/v${kver}/linux-$1.tar.xz" \
|| return $?
)
}
#########################
# Argument verification #
@@ -87,10 +46,6 @@ fi
# Kernel tree generation #
##########################
kernel_mirror="ftp://ftp.kernel.org/pub/linux/kernel"
kernel_longterm="http://www.kernel.org/pub/linux/kernel"
kernel_sources="$HOME/software/downloads"
scriptname="$0"
if [ "${scriptname#/}" = "${scriptname}" ]; then
scriptname="$PWD/$scriptname"
@@ -99,24 +54,14 @@ target="linux-$1"
kernel_version="$(kernel_version "$1")"
patchlevel="$(patchlevel "$1")"
download_kernel "$1"
download_kernel "$1" || exit $?
extract_kernel_tree "$1" || exit $?
mkdir "${target}" || exit $?
cd "${target}" || exit $?
if [ -e "${kernel_sources}/linux-${kernel_version}.tar.xz" ]; then
tar --strip-components=1 -xaf "${kernel_sources}/linux-${kernel_version}.tar.xz"
else
tar --strip-components=1 -xaf "${kernel_sources}/linux-${kernel_version}.tar.bz2"
fi
if [ ! -z "$patchlevel" ]; then
echo "==== ${kernel_sources}/patch-$1.bz2"
bzip2 -cd < "${kernel_sources}/patch-$1.bz2" | patch -s -p1
fi
svn status -v "$(dirname "$(dirname "$scriptname")")" \
| grep -v '^Performing' \
| grep -vE '^\?|^Performing' \
| cut -c41- \
| grep -- "-${kernel_version}.*.patch$" \
| grep -v /in-tree/ \