Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Octave Forge framework - chance for discard g-octave
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Hack_leberry Finn
n00b
n00b


Joined: 26 Nov 2012
Posts: 2

PostPosted: Mon Nov 26, 2012 3:30 pm    Post subject: Octave Forge framework - chance for discard g-octave Reply with quote

Hi all.
Last week I was informed that I have to use Octave in my work. Since last year I was not using it, and I remember that g-octave was terrible painful experience. Using recipes form g-octave developer wiki I could update octave forge packages that I needed. Now even this page gone (not mention maintenance of package). That's why I have written two short scripts in bash (KISS rule), for automation ebuilds templates prepare. In my concept Octave Forge packages ebuilds should be located in sci-misc directory with names octave-<package name> ie. sci-misc/octave-image/octave-image-2.0.0.ebuild. This way, it will be much comfortable for all Octave and Octave Forge Gentoo Users, and Developers.
Here are some portions of code:
First main.script.sh:
Code:

#!/bin/sh
# This is main bash script for automation of Octave Forge packages
# ebulids writing
# (c) by Hack_leberry Finn 2012 on GPLv3 license
# Require wget, sed, grep, chmod, ls, echo, rm

# Downloading Octave Forge latest packages listing page
wget http://octave.sourceforge.net/packages.php

# Generate script for Octave Forge packages tree
echo \#\!"/bin/sh" > script1.sh
grep "class=\"package\" " packages.php | sed -e \
's/<div class\=\"package\" id=\"/mkdir octave-forge-/g' -e 's/\">//g' \
>> script1.sh
chmod u+x script1.sh
./script1.sh

# Generating script for download latest packages sources
ls -d octave-forge-* |sed -e 's/^/cd /g' > helper1
grep download packages.php | sed -e \
's/<a class\=\"package_link\" href\=\"/wget \"/g' \
-e 's/\?download\">download<\/a><\/td>/\" cd ..\//g' \
> helper2
echo \#\!"/bin/sh" > script2.sh
paste -d "\n" helper1 helper2 |sed 's/ cd /\ncd /g' >> script2.sh
chmod u+x script2.sh
./script2.sh

# Create portage dir
mkdir -p portage/sci-misc

# Create portage Octave Forge tree
# Create dirs
echo \#\!"/bin/sh" > script3.sh
sed 's/octave-forge/portage\/sci-misc\/octave/g' script1.sh >> script3.sh
chmod u+x script3.sh
./script3.sh
ls octave-forge-* | sed -e 's/octave.*:$//g' -e 's/tar\.gz/ebuild/g' | \
grep -v ^$ |sed -e 's/^/octave-/g' > helper3
sed -e 's/-[[:digit:]].*$//g' -e 's/^/touch portage\/sci-misc\//g' helper3 \
> helper4

# Create ebuild files
echo \#\!"/bin/sh" > script4.sh
paste -d "/" helper4 helper3 >> script4.sh
chmod u+x script4.sh
./script4.sh

# Unpack sources to get acces to Description files
grep download packages.php | sed -e \
's/<a class\=\"package_link\" href\=\"http\:\/\/downloads\.sourceforge\.net\/octave\//tar -xzf /g' \
-e 's/\?download\">download<\/a><\/td>/ cd \.\.\//g' > helper5
echo \#\!"/bin/sh" > script5.sh
paste -d "\n" helper1 helper5 |sed 's/ cd /\ncd /g' >> script5.sh
chmod u+x script5.sh
./script5.sh

# Prepare ebuild templates for manual correction
echo \#\!"/bin/sh" > script6.sh
ls octave-forge-*/*/ | grep octave-forge | sed -e 's/^/cd /g' \
-e 's/:$/\n\. \.\.\/\.\.\/script\.sh \ncd \.\.\/\.\.\//g' > script6.sh
chmod u+x script6.sh
./script6.sh

# Delete temporary files
rm -f helper[12345] script[123456].sh packages.php


and script.sh code (it is used by script6.sh):
Code:

#!/bin/sh
# This is bash script for automation of Octave Forge packages
# ebulids writing
# (c) by Hack_leberry Finn 2012 on GPLv3 license
# Require sed, grep, ls, echo, test (and "if loop"), cat

# Main part of ebuild auto writer
echo "$(cat ../../template1.ebuild && grep Title  DESCRIPTION \
| sed -e 's/Title:/DESCRIPTION=\"Octave Forge/g' -e 's/$/ package\"/g' \
&& cat ../../template2.ebuild && grep License: DESCRIPTION \
| sed -e 's/, / \|\| /g' -e 's/$/\"\n/g' -e 's/License: /LICENSE\=\"/g'\
&& cat ../../template3.ebuild && grep Depends: DESCRIPTION \
| sed  -e 's/$/\"\n/g' -e 's/, /\n\t/g' -e 's/[(>=)]//g' \
-e 's/Depends: /DEPEND\=\"\n\t/g' -e 's/  /-/g' \
-e 's/\t/\t>=sci-misc\/octave-/g' \
-e 's/misc\/octave-octave/mathematics\/octave/g' \
&& cat ../../template4.ebuild)" > \
$(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))

# Checking if octave dependency is placed in DEPEND variable
Testing=$(grep ">=" $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g')) \
| grep "mathematics/octave")

if [ -z "$Testing"  ]
then
Testing2=$(grep "^DEPEND" $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e 's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g')))
if [ -z "$Testing2"  ]
then
sed -i -e 's/RDEPEND/DEPEND=\"sci-mathematics\/octave\"\nRDEPEND/g' \
$(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))
else
sed -i -e 's/^DEPEND=\"/DEPEND=\"sci-mathematics\/octave/g' \
$(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e 's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))
fi
else
echo "$Testing" > /dev/null
fi

# Checking extra deps (for manual correction of ebuild)
grep SystemRequirements DESCRIPTION | sed 's/^/#/g' \
>>  $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))
grep Suggested DESCRIPTION | sed 's/^/#/g' \
>> $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))
grep BuildRequires DESCRIPTION | sed 's/^/#/g' \
>> $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))
grep Systemrequirements DESCRIPTION | sed 's/^/#/g' \
>> $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e 's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))

# Guys from Octave Forge give strange dirnames so checking this
pwd |sed -e 's/.*octave-forge-.*\//\nS=\$\{WORKDIR\}\//g' \
>> $(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))

# Avoid g-octave collision
sed -i -e 's/^RDEPEND=\"/RDEPEND=\"\!g-octave\/'\
$(ls ../*tar.gz | sed -e 's/\.\.\///g' -e 's/-[[:digit:]].*$//g')'\n\t/g' \
$(echo $(ls ../*tar.gz \
| sed -e 's/\.\.\//\.\.\/\.\.\/portage\/sci-misc\/octave-/g' \
-e's/-[[:digit:]].*gz$/\//g')\
$(ls ../*tar.gz | sed -e 's/\.\.\//octave-/g' -e 's/tar\.gz/ebuild/g'))

And templates used by this scripts:
template1.ebuild:
Code:
                                                         
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v3
# $Header: Hack_leberry Finns tricks for Octave Forge $

inherit eutils


template2.ebuild:
Code:

HOMEPAGE="http://octave.sourceforge.net/${PN}/index.html"
SRC_URI="http://downloads.sourceforge.net/octave/${P/octave-//}.tar.gz"

RESTRICT="mirror"


template3.ebuild:
Code:

SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE=""


template4.ebuild:
Code:


RDEPEND="${DEPEND}"



After execution main.script.sh You get tree builded that way:
Code:

./
 |-+ octave-forge-<packagename>
 | |- <package_source_tarball>tar.gz
 | |-+ <package_source_dir>
 |   |- some_sources
 ...
 |-+ portage             
   |-+ sci-misc
      |-+ octave-<package_name>
      | |- octave=<package_name>-<packave_version>.ebuild
      ...


I have placed bug in bugzilla, with tarball of this sources.
In this week I will try to prepare ebuild for packages that I need, and maybe some extra ones.
_________________
Sentence that You are reading now is false.
Back to top
View user's profile Send private message
Hack_leberry Finn
n00b
n00b


Joined: 26 Nov 2012
Posts: 2

PostPosted: Thu Nov 29, 2012 8:45 pm    Post subject: Reply with quote

Now those scripts are ready as tools for people who can develop ebuilds by themselves. Main script can work as part of cron calls and provide regular updated "workspace". There is extra script for system-wide searches for dependencies indicated by Octave Forge developers too.
Look on bugzilla thread, download latest version, tray, share opinions, suggestions, patches etc.
_________________
Sentence that You are reading now is false.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum