LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-16-2016, 04:17 PM   #1
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Where might I find the kernel-source SlackBuild ?


All --

I've been keeping up with the 4.4.x Kernel in Slackware64-14.2 by installing and / or updating the Kernel Packages from Slackware64-current in my Slackware64-14.2 + Multilib + Nvidia Blob Laptop.

Last Month, volkerdi seemed surprised that the Nvidia Blob was working for me because the Kernel Packages were compiled with a different version of gcc on current vs my 14.2 System ...

So far everything has worked great, but sooner or later I imagine I'll run into the trouble that Pat anticipated so I would like to start building my own set of 'tagged' 4.4.x Kernel Packages.

I've located all Pat's SlackBuild scripts except a kernel-source.SlackBuild ...

Are there any special tricks to creating a kernel-source Package ?

Is there a kernel-source.SlackBuild out there somewhere that I've not managed to find ?

Thanks !

-- kjh
Code:
# pwd -P ; find . -type f -iname "kernel*SlackBuild"

/home/dld/slackware/slackware-current-64

./source/a/kernel-firmware/kernel-firmware.SlackBuild
./source/k/packaging-x86_64/kernel-huge/kernel-huge.SlackBuild
./source/k/packaging-x86_64/kernel-generic/kernel-generic.SlackBuild
./source/k/packaging-x86_64/kernel-modules/kernel-modules.SlackBuild
./source/k/packaging-x86/kernel-huge/kernel-huge.SlackBuild
./source/k/packaging-x86/kernel-modules-smp/kernel-modules-smp.SlackBuild
./source/k/packaging-x86/kernel-generic/kernel-generic.SlackBuild
./source/k/packaging-x86/kernel-huge-smp/kernel-huge-smp.SlackBuild
./source/k/packaging-x86/kernel-generic-smp/kernel-generic-smp.SlackBuild
./source/k/packaging-x86/kernel-modules/kernel-modules.SlackBuild
 
Old 10-16-2016, 04:26 PM   #2
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
As far as I know, the kernel source would be the source for a kernel. You get that from kernel.org. Slackware doesn't alter the kernel source in any way, so what you get from kernel.org is what you get from Slackware's kernel sources.

Making that into a Slackware package is probably superfluous, but you could, if you wanted, place it in a dir structure that mimics your target, and then use makepkg to make it into a formal package.
 
1 members found this post helpful.
Old 10-16-2016, 04:32 PM   #3
zk1234
4MLinux Maintainer
 
Registered: Oct 2010
Location: Poland
Distribution: 4MLinux, Slackware
Posts: 1,254

Rep: Reputation: 220Reputation: 220Reputation: 220
Basically, no special requirements (because Slackware uses an unmodified source code).
You'll have to create links (to the source code) in the modules directory, but it's rather general (and not Slackware specific) requirement.

.
 
1 members found this post helpful.
Old 10-16-2016, 04:39 PM   #4
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Original Poster
Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Thanks notKlaatu and zk1234.

I am simply wrapping /usr/src/linux-4.4.x/ in a kernel-source-4.4.x-noarch-1kjh.txz Package after doing a `make mrproper` so I guess I am good to go.

-- kjh
 
Old 10-17-2016, 04:46 AM   #5
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,445
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Where might I find the kernel-source SlackBuild ?

Why bother? It's all in that directory.
I've never bothered packaging kernels, their modules or their source code.
 
1 members found this post helpful.
Old 10-17-2016, 05:56 AM   #6
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
As an alternative, you might also consider setting up /usr/src/linux as a git clone which is what I do. git takes up extra diskspace and the initial clone can be quite a big download, but from then on in, its just a matter of 'git pull' to update it, which is really convenient.

Unlike rkelsen I do prefer to package up my kernels+modules. We all have our own individual approaches.
 
1 members found this post helpful.
Old 10-17-2016, 06:14 AM   #7
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Original Poster
Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Thanks rkelsen & GazL --

Hmmm ... Let me think about simply building the Kernels and Modules in /usr/src/linux-4.4.x/ without bothering to build Unofficial Slackware Packages ...

I am a firm believer in Slackware Packages and the installpkg / upgradepkg / removepkg tools.

For kernels, `removepkg` is especially convenient for removing old kernels from the system.

But I suppose there's not a lot to remove with the kernel Packages, is there ?

Thanks again !

-- kjh
 
Old 10-17-2016, 07:11 AM   #8
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by kjhambrick View Post
But I suppose there's not a lot to remove with the kernel Packages, is there ?
I've always done my kernels manually. If I build a custom kernel (whether based on a test config from Pat or different customizations), I just build it in /usr/src/, copy the vmlinuz image over to boot, run make modules_install, then rebuild an initrd based on the new kernel. If I decide to remove old kernels, I find it is plenty easy to just remove the kernel, initrd, kernel source, and modules manually. To me, it's much easier than the extra effort involved in trying to create or manage a SlackBuild for them. Plus, if you generate an initrd, it wouldn't be included with the kernel package (unless you manually include it), so you'll still either be left with files on your drive or have to manually remove it.

Normally, I'm all for Slackware packages and if there isn't a SlackBuild available, I'll create one myself, but the kernel puts files in only a few known places, and it's very easy to manually remove them. I suppose if you were to create a SlackBuild that also builds the kernel, installs the modules, copies the kernel over, generates an initrd (if needed), and packages all of that into a nifty little Slackware package, it could be nice, but that's far too much work for me to spend on this when it is super easy to just manually remove them (compared to many packages who have their files scattered across the filesystem in many different folders).
 
3 members found this post helpful.
Old 10-17-2016, 05:33 PM   #9
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,445
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by bassmadrigal View Post
I've always done my kernels manually. If I build a custom kernel (whether based on a test config from Pat or different customizations), I just build it in /usr/src/, copy the vmlinuz image over to boot, run make modules_install, then rebuild an initrd based on the new kernel. If I decide to remove old kernels, I find it is plenty easy to just remove the kernel, initrd, kernel source, and modules manually.
This is exactly the way I do it.
Quote:
Originally Posted by bassmadrigal View Post
I suppose if you were to create a SlackBuild that also builds the kernel, installs the modules, copies the kernel over, generates an initrd (if needed), and packages all of that into a nifty little Slackware package, it could be nice, but that's far too much work for me to spend on this when it is super easy to just manually remove them (compared to many packages who have their files scattered across the filesystem in many different folders).
Yep, creating a package every time would be more trouble than it's worth.
 
Old 10-18-2016, 06:16 AM   #10
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
you can use this script below, put it in the source directory and rename it kernel-source.SlackBuild (I used it myself)

PKGNAM=linux
VERSION=${VERSION:-$(echo /slacksrc/k/$PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
BUILD=${BUILD:-1}
CWD=$(pwd)
TMP=${TMP:-/tmp}
mkdir -pv $TMP/kernel-source/usr/src
PKG=$TMP/kernel-source
cd $PKG/usr/src
tar xf /slacksrc/k/$PKGNAM-$VERSION.tar.xz
cd $PKGNAM-$VERSION
mkdir -pv $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd /tmp/kernel-source
VERSION1=${VERSION1:-$(echo /slacksrc/k/$PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)_smp}
makepkg -l y -c n /tmp/kernel-source-$VERSION1-noarch-$BUILD.txz
rm -rf /tmp/kernel-source/

Last edited by nobodino; 10-18-2016 at 06:20 AM. Reason: error
 
1 members found this post helpful.
Old 10-18-2016, 06:28 AM   #11
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Original Poster
Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Thanks rkelsen, bassmadrigal

And thanks nobodino.

I'll review and try out your script ( placed in code-tags below ) !

-- kjh

Code:
#!/bin/sh
#
# package kernel-source for Slackware courtesy of LQ user nobodino
#
PKGNAM=linux
VERSION=${VERSION:-$(echo /slacksrc/k/$PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
BUILD=${BUILD:-1}

CWD=$(pwd)
TMP=${TMP:-/tmp}
mkdir -pv $TMP/kernel-source/usr/src
PKG=$TMP/kernel-source

cd $PKG/usr/src
tar xf /slacksrc/k/$PKGNAM-$VERSION.tar.xz

cd $PKGNAM-$VERSION
mkdir -pv $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd /tmp/kernel-source
VERSION1=${VERSION1:-$(echo /slacksrc/k/$PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)_smp}
makepkg -l y -c n /tmp/kernel-source-$VERSION1-noarch-$BUILD.txz
rm -rf /tmp/kernel-source/
 
Old 10-18-2016, 12:26 PM   #12
aaditya
Member
 
Registered: Oct 2013
Location: India
Distribution: Slackware
Posts: 272
Blog Entries: 2

Rep: Reputation: 85
(Just throwing it out in case its of any use)

I use the following script to fetch the kernel sources, build it, and install the built kernel and modules. Removing the kernel is easy too, just need to remove the copied files and installed modules.

https://github.com/aadityabagga/scri...lack_kernel.sh

Code:
#!/bin/sh
# Script to get, build and install kernels in Slackware Linux

# functions
check_version() {
	if [ -z "$VERSION" ]; then
		echo "No version specified."
		echo "Kernel version can be specified using the -k argument."
		exit 1
	fi
}

init() {
	check_version
	#ARCH=$(uname -a)
	NUMJOBS=3
	# Get base version of kernel, ie, for 3.10.17, base version is 3.10
	BASEVER=${VERSION%.*}
	# Get really base version, like for 3.10.17, it is 3
	BASEBASEVER=${VERSION%%.*}
	# Check for something like 4.0
	[ "$BASEVER" = "$BASEBASEVER" ] && BASEVER=${VERSION%.*.*}
}

change_dir() {
	check_version
	[ ! "$(basename $(pwd))" = "linux-$VERSION" ] && cd "linux-$VERSION"
}

get() {
	check_version
	# Download the base kernel
	wget -Nc "https://www.kernel.org/pub/linux/kernel/v${BASEBASEVER}.x/linux-$BASEVER.tar.xz"
	# Download patch
	if [ ! "$VERSION" = "$BASEVER" ]; then
		wget -Nc "https://www.kernel.org/pub/linux/kernel/v${BASEBASEVER}.x/patch-$VERSION.xz"
	fi
}

extract_release() {
	# Check if kernel directory is available
	if [ -d "linux-$VERSION" ]; then
		return 0
	fi
	if [ -d "linux-$BASEVER" ]; then
		return 0
	# Else extract the base version
	elif [ -f "linux-${BASEVER}.tar.xz" ]; then # || [ -f "linux-$BASEVER.tar.gz" ] || [ -f "linux-$BASEVER.tar.bz2" ]
		tar xvf "linux-${BASEVER}.tar.xz" || return 1
	else
		echo "Unable to extract linux-${BASEVER}.tar.xz"
		return 1
	fi
}

extract_patch() {
	# Need to check if patch for specified version is available
	if [ -e "patch-$VERSION.xz" ]; then
		# Extract the patch
		unxz "patch-$VERSION.xz"
	elif [ -f "patch-$VERSION.gz" ]; then
		"gunzip patch-$VERSION.gz"
	else
		return 1
	fi
}

apply_patch() {
	# Now check and apply patch
	if [ -e "patch-$VERSION" ]; then
		# Change into the src directory and apply the patch
		cd "linux-$BASEVER" && patch -p1 < ../"patch-$VERSION" || exit 1
		# Change name of src directory so state can be verified
		cd .. && mv -v "linux-$BASEVER" "linux-$VERSION"
	fi
}

extract(){
	check_version
	extract_release
	extract_patch
	apply_patch
}

config() {
	# change to proper directory
	change_dir
	# copy the config
	cp -i ../config-*"$BASEVER"* .config || exit 1
	# Config handling is manual
	make oldconfig
	# Custom config too
	make menuconfig
}

build() {
	# change to proper directory
	change_dir
	# Build the kernel
	make -j"$NUMJOBS" bzImage
	# Build the modules
	make -j"$NUMJOBS" modules
}

install() {
	check_version
	# change to proper directory
	change_dir
	echo "Installing kernel ${VERSION}"
	# Install the modules
	sudo make modules_install || exit 1
	# Copy the built kernel and configs
	sudo cp -v arch/x86/boot/bzImage "/boot/vmlinuz-custom-$VERSION" || exit 1
	sudo cp -v System.map "/boot/System.map-custom-$VERSION" || exit 1
	sudo cp -v .config "/boot/config-custom-$VERSION" || exit 1
}

remove() {
	check_version
	echo "Removing kernel ${VERSION}"
	sudo rm -rv "/lib/modules/$VERSION" || exit 1
	sudo rm -v "/boot/vmlinuz-custom-$VERSION" || exit 1
	sudo rm -v "/boot/System.map-custom-$VERSION" || exit 1
	sudo rm -v "/boot/config-custom-$VERSION" || exit 1
}

post_install() {
	# Update bootloader
	echo 'Updating grub configurartion'
	sudo update-grub
}

clean() {
	check_version
	# change to proper directory
	change_dir
	# Unpatch and move the directory to linux-basever
	patch -R -p1 < ../"patch-$VERSION" || exit 1
	cd .. && mv -v "linux-$VERSION" "linux-$BASEVER"
}

display_help() {
	cat << EOF
Usage: slack_kernel.sh -k <kernel> <option>
Options-
	[get,-g]	[clean,-c]	[extract,-e]
	[config,-m]	[build,-b]	[install,-i]
	[posinstall,-p]	[remove,-r]	[all(-gembip),-a]
	[help,-h]
EOF
}

# process cmd line args
while getopts "gcembiprahk:" opt; do
	case "$opt" in
	g) get;;
	c) clean;;
	e) extract;;
	m) config;;
	b) build;;
	i) install;;
	p) post_install;;
	r) remove;;
	a) get; extract; config; build; install; post_install;;
	h) display_help ;;
	k) VERSION=$OPTARG; init;;
	*) ;;
	esac
done

#echo "Done"
My usage for it is like:

Code:
# cd ~/build/kernel
# sh slack_kernel.sh -k 4.4.25 -a
The steps are somewhat based upon http://docs.slackware.com/howtos:sla...kernelbuilding
 
2 members found this post helpful.
Old 10-19-2016, 12:55 PM   #13
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Original Poster
Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
aaditya --

Sweet

I'll check out your script.

Thanks !!

-- kjh
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trying to rebuild extragear with slackbuild, tar can't find source? damgar Slackware 6 07-20-2012 07:57 PM
[SOLVED] Updated to kernel 3.0.4 but now source package can not find kernel headers. ReaperX7 Slackware 2 10-03-2011 06:48 PM
cannot find kernel-source petervdv Mandriva 7 12-12-2006 05:02 AM
How can I find the source for my Kernel? husten SUSE / openSUSE 5 04-17-2006 08:19 AM
trying to find/install kernel-source or kernel-headers timsch75 Slackware 3 10-22-2005 09:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration