LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-13-2011, 11:44 PM   #1
TheCrow33
Member
 
Registered: Aug 2009
Posts: 81

Rep: Reputation: 8
Can we make slackbuilds easier?


After many hours of fiddling with a 'project' computer (which is really just a better way of saying spare parts that were laying around the house and turned into a working machine), I installed way too many slackbuild packages which became very time consuming. Mythtv can be named the main culprit behind this, because it has a lot of packages that it depends on (and those packages depend on a lot of packages and so on). So I began to ask myself this question of 'Can I make slackbuilds easier?' and in the spirit of B0b the Builder I answered 'Yes we can!'.

So I give to you, my fellow slackers, a small script that takes a file (for some reason too many cmd line arguments won't register) of package names and slackbuild names and then does the rest of the work for you. This will work for most all packages that follow the usual layout: pkgName-0.1.2.extension or even pkg-Name-0.1.2.extension or even pkg-Name-0.1.2rc3.extension. Note it will break if the package is a snapshot that includes the date in the version number or other weird formats. Also note that it will not pass arguments to the slackbuilds for you (though I'd imagine you can just set them before you run the script and all will turn out ok). Anyway feel free to do anything you like with these scripts (use it, modify it, post it on the web, print it out and set it on fire) so long as you don't claim credit for the work you didn't do.

Code:
root@multimedia:/make# cat /usr/sbin/installsbo
#!/bin/bash
#
# Takes <file>
# Creates and installs the slackbuild and then cleans up

if [[ $# < 1 ]]; then
	echo "Usage: $0 </path/to/listOfPackages>"
	exit
fi

list=`cat $1`
isSB=0

for x in $list; do
	if [[ $isSB == 0 ]]; then
		package=$x

		if [[ -n `echo $package | grep ".tar.bz2" ` ]]; then
			pkgflags="-xjf"
			pkgreplace=".tar.bz2"
		elif [[ -n `echo $package | grep ".tar.gz" ` ]]; then
			pkgflags="-xf"
			pkgreplace=".tar.gz"
		elif [[ -n `echo $package | grep ".tgz" ` ]]; then
			pkgflags="-xf"
			pkgreplace=".tgz"
		else
			echo "unanticipated package extension: $package"
			exit
		fi

		isSB=1
	else
		SB=$x

		if [[ -n `echo $SB | grep ".tar.bz2" ` ]]; then
			sbflags="-xjf"
			sbreplace=".tar.bz2"
		elif [[ -n `echo $SB | grep ".tar.gz" ` ]]; then
			sbflags="-xf"
			sbreplace=".tar.gz"
		elif [[ -n `echo $SB | grep ".tgz" ` ]]; then
			sbflags="-xf"
			sbreplace=".tgz"
		else
			echo "unanticipated slackbuild extension: $SB"
			exit
		fi

		buildDir=`echo $SB | sed s/$sbreplace// `
		packageName=`echo $package | sed -r 's/(.*)[-_]([0-9a-zA-Z].*)/\1/' `

		regex="s/(.*)[-_]([0-9a-zA-Z].*)$pkgreplace/\2/"
		packageVers=`echo $package | sed -r $regex `

		echo "unpackaging slackbuild ..."
		tar $sbflags $SB

		echo "moving package ..."
		mv $package $buildDir/

		echo "moving to $buildDir ..."
		pushd $buildDir

		regex="s/VERSION=(.*)/VERSION=$packageVers/"
		sed -rs $regex $buildDir.SlackBuild > a
		mv a $buildDir.SlackBuild
		chmod +x $buildDir.SlackBuild

		if [[ -n `cat $buildDir.SlackBuild | grep "PKGNAME"` ]]; then
			varName="\$PKGNAME"
		elif [[ -n `cat $buildDir.SlackBuild | grep "PRGNAM"` ]]; then
			varName="\$PRGNAM"
		fi

		addtoscript="/sbin/installpkg \"\$OUTPUT/$varName-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz}\"\n
		checkpkg \"\$OUTPUT/$varName-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz}\"\n
		exit \$?"
		echo "adding to script ..."
		echo -e $addtoscript >> ./$buildDir.SlackBuild

		echo "running slackbuild ..."
		./$buildDir.SlackBuild

		if [[ $? != 1 ]]; then
			echo "Failed to install: $package";
			exit
		fi

		isSB=0

		popd
		rm -R $buildDir $SB
	fi
done
root@multimedia:/make# cat /usr/sbin/checkpkg
#!/bin/bash
#
# Checks if a slackbuild was made into a package
# We can assume if this returns 1 then it was also installed

echo "Checking: $1 ..."
if [[ `ls $1` == $1 ]]; then
	exit 1
else
	exit 0
fi
So an example file would look like either of the following:
Code:
example-1.2.3.tar.bz2 example.tar.gz helloWorld.4.5.6.tar.bz2 helloWorld.tar.gz
or
Code:
example-1.2.3.tar.bz2 example.tar.gz
helloWorld.4.5.6.tar.bz2 helloWorld.tar.gz
Note: yeah I know this could use some cleaning up, but it's been a long day and I coded this this morning give me a break haha.

Last edited by TheCrow33; 01-13-2011 at 11:46 PM.
 
Old 01-14-2011, 12:37 AM   #2
TL_CLD
Member
 
Registered: Sep 2006
Posts: 366

Rep: Reputation: 45
I can kinda see where you're going with this, but why not just go with the excellent sbopkg and use its queue facility?

http://www.sbopkg.org/
 
Old 01-14-2011, 12:40 AM   #3
TheCrow33
Member
 
Registered: Aug 2009
Posts: 81

Original Poster
Rep: Reputation: 8
Quote:
Originally Posted by TL_CLD View Post
I can kinda see where you're going with this, but why not just go with the excellent sbopkg and use its queue facility?

http://www.sbopkg.org/
Doh! It's been a long couple of days and I guess I just wanted to make it longer by failing to google for an existing solutions first haha. Eh, oh well, I enjoyed programming it anyway.
 
Old 01-14-2011, 01:47 AM   #4
TL_CLD
Member
 
Registered: Sep 2006
Posts: 366

Rep: Reputation: 45
Quote:
Originally Posted by TheCrow33 View Post
...I enjoyed programming it anyway.
Hehe, I can relate to that. I've written _a lot_ of code simply for the sake of writing it. It relaxes the mind.
 
Old 01-14-2011, 03:42 AM   #5
tallship
Member
 
Registered: Jul 2003
Location: On the Beaches of Super Sunny Southern San Clemente, California USA
Distribution: Slackware - duh!
Posts: 534
Blog Entries: 3

Rep: Reputation: 118Reputation: 118
Thumbs up

That's actually pretty neat

could be used for some other, more specific packaging routines, tested, and incorporated as a sort of favpack install.

Nice work!
 
Old 01-14-2011, 09:35 AM   #6
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
Mmmm I did that for converting my CDs to mp3/flac... then I realized there was abcde which did everything I wanted except place the final files in separate directories.

It was really annoying to try and find software that named the files -exactly- how I wanted them.


But in regards to the topic; I personally don't like using SBo for too many things. I like creating my own build queues for things like inkscape that doesn't have a lot of shared dependencies with other packages that I install.

Last edited by lumak; 01-14-2011 at 09:39 AM.
 
  


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
Make linuxquestions.org easier to use Dwight Randall LQ Suggestions & Feedback 8 12-19-2009 08:58 AM
LXer: To Those Who Make My Job Easier LXer Syndicated Linux News 0 06-19-2008 06:40 AM
How to make my life easier with embedded Linux?????????? raedbenz Linux - Embedded & Single-board computer 7 06-11-2008 11:48 AM
What Will Make Linux Easier To Use: Research Questionnaire Murdock1979 Linux - General 3 12-29-2005 06:25 AM
Make linux easier? bolinux General 43 10-20-2003 10:22 PM

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

All times are GMT -5. The time now is 05:53 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