You are not logged in.

#1 2006-04-06 20:15:18

test1000
Member
Registered: 2005-04-03
Posts: 834

autoPKGBUILD

This script tries to take the tediousness (and sometimes difficulty for noobs) away out of making PKGBUILDS.

It automatically scours various venues of the internet and firefox cache for information about an archive you have downloaded and tries to autoinput all the entries in an PKGBUILD to it's best possibility. (note, the firefox cache code may not work all the time, i wrote it a long time ago when i barely knew what i was doing).
NOTE: Firefox is not an requirement, I use opera and it still finds almost all entries to autoinput.

You run the script like this:
autoPKGBUILD archivename.*

Download it now and try it out when your too tired to install that game not in AUR yet smile edit: scroll down to see the script.


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#2 2006-04-06 21:31:08

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: autoPKGBUILD

i should say that the script as default puts the downloaded package into /var/abs/local, change it you like..


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#3 2006-05-21 14:40:51

skruw
Member
Registered: 2003-12-06
Posts: 23

Re: autoPKGBUILD

i wonder why the heck i dident think about that.
well i will fix that in the next version, problem is i dont know when it will be out since i dont have a computor(?!?!?!?!?!) atm, but i will fix this as soon as.
thank you very much for your input.

Offline

#4 2006-05-21 15:54:36

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: autoPKGBUILD

?? wrong thread?
edit: oh sorry. You were offering your help. cool  big_smile

edit: I have actually done some work on this today. Which is a miracle almost considering it's me big_smile Will try to upload as fast as I think it's not total ugly anymore.


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#5 2006-08-10 14:47:28

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: autoPKGBUILD

Ok, there's a new version out. I have rewritten a lot of it, but some of it is barely functional code; i barely knew what i was doing back then roll
About the MIME stuff that i mention in the initial post, i just gave up on that one. now you run the script by just typing pkgbuilder name-of-archive.*

much nicer for me atleast, MIME i feel is a nightmare to 'get' completely with all the different implementations blablabla i don't even know what i'm talking about, that's how complicated it was.

The script doesn't support python yet, nor perl, but maybe i'll add those later today -- you see i have somewhat of a motivation problem big_smile

It won't always create the correct entries, and sometimes(though not so often) it might not find much info to autoinput into your PKGBUILD, but atleast in those cases your spared maunally writing the PKGBUILD from scratch  wink

So this isn't the mythical "do-it-all-for-you" plug & play PKGBUILD maker but it'll help you save a considerate amount of time. If i implement the stuff i'm thinking about it might atleast come closer to that(save for stuff that quite simply won't compile), but then it's this motivation thing again stopping me wink

I also renamed it to autoPKGBUILD because thats closer to the truth than 'pkgbuilder'; which it's not, and cleared up the initial post so as to not cause so much confusion.

Enough talk! Enjoy!

#!/bin/sh
# 
# version 1.1
# support rake. support java:http://sillysoft.net/download/American_History_Lux_Demo.jar support python.
# støtte www.happypenguin.org

# Important VARS. Change these to suit you better.
_BUILDDIR=/var/abs/local
_TERMINAL="xterm +tb -bg black -fg gray -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1"
_EDITOR=vim
_VIEWER=less

if [ -e "$1" ];
then
    what=$1
fi
if [ -e "$what" ];
then
    mv "$what" $_BUILDDIR
    cd $_BUILDDIR
else
    wget "$what"
    mv `basename "$what"` $_BUILDDIR
    cd $_BUILDDIR
fi
echo Moving file to ${_BUILDDIR}...
_new=`basename "$what"`
sleep 1
# the only named packaged i know it doesn't take care of properly is starship_troopers.zip for example
_PKGNAME=`echo "${_new}"|sed -e 's/([_|-]|[.]){1}.*//' -e 's/[[:alnum:]]?.?[[:alpha:]]?.?[[:alnum:]]?.?[[:alpha:]]?.?[[:alnum:]]?.?[[:alpha:]]?.?[[:alnum:]]?(.tar.gz|.tar.bz2|.zip|.tar|.tgz)//'|tr -t '[:upper:]' '[:lower:]'`
case "${_new##*.}" in
        gz)
        _PDIR=`tar tf $_new|head -1|sed 's|/.*||g'`
    mkdir $_PDIR
    cd $_PDIR
        ;;
        tgz)
        _PDIR=`tar tf $_new|head -1|sed 's|/.*||g'`
    mkdir $_PDIR
    cd $_PDIR
        ;;
        zip)
    _PDIR=`unzip -qql "$_new"|sed '2!d'|cut -c 29-`
    if [ `dirname "$_PDIR"` = "." ]
    then
        _PDIR="$_PKGNAME"
        mkdir "$_PDIR"
        cd "$_PDIR"
        _UNZIP="1"
    else
        _PDIR=`dirname "$_PDIR"`
        mkdir "$_PDIR"
        cd "$_PDIR"
    fi
        ;;
        bz2)
    _PDIR=`tar tf $_new|head -1|sed 's|/.*||g'`
        mkdir $_PDIR
        cd $_PDIR
        ;;
        *)
        echo unknown archive file.
        sleep 1
    exit 1
esac
mv ../$_new .
echo Analysing and Creating PKGBUILD entries
echo $_PKGNAME
echo pkgname=$_PKGNAME >> PKGBUILD
_PKGVER=`echo ${_new}|sed -e 's/[[:alnum:]]{2}[[:alpha:]]*[_|-]?//' -e "s/.tar.gz//" -e "s/.tar.bz2//" -e "s/.tar//" -e "s/.zip//" -e "s/.tgz//"`
echo pkgver=$_PKGVER >> PKGBUILD
echo pkgrel=1 >> PKGBUILD

echo pkgdesc="`lynx -dump "http://freshmeat.net/projects/${_PKGNAME}"|grep -A 2 "About:"|grep -v "About:"|xargs echo`" >> PKGBUILD

if grep -m 1 $_PKGNAME $HOME/.mozilla/firefox/*.default/history.dat 2>&1 > /dev/null;
then
    echo url="`grep -m 1 $_PKGNAME $HOME/.mozilla/firefox/*.default/history.dat|sed 's|    =||'|sed 's|)(.*||'`" >> PKGBUILD
else
    echo url="`lynx -source http://freshmeat.net/projects/$_PKGNAME|grep -m 1 'url_homepage'|egrep -o 'http://.*|ftp://.*'|sed 's|</a><br>||'|tr -d 'r'`" >> PKGBUILD
fi
# bad license script..
echo license="`lynx -dump "http://freshmeat.net/projects/$_PKGNAME"|grep -m 1 License|sed 's/.*(//'|sed 's/)//'`" >> PKGBUILD
echo "Checking compression type"
sleep 1
# maybe not working for archives compressed weirdly
echo $_PDIR is "$_PDIR"
case "${_new##*.}" in
        gz)
    echo "Uses gzip compression. Uncompressing..."
        tar zxf "$_new"
        cd $_PDIR
    _COMPRTYPE=gz
        ;;
        tgz)
    echo "Uses gzip compression. Uncompressing..."
        tar zxf "$_new"
        cd $_PDIR
    _COMPRTYPE=gz
    ;;
        zip)
    echo "Uses zip compression. Uncompressing..."
        if [ "$_UNZIP" = "1" ]
    then
            mkdir "$_PDIR"
            cd "$_PDIR"
            unzip "$_new"
        _COMPRTYPE=zip
        else
                unzip "$_new"
            cd "$_PDIR"
        _COMPRTYPE=zip
    fi
    ;;
    bz2)
    echo "Uses bzip compression. Uncompressing..."
    tar jxf $_new
    cd $_PDIR
    _COMPRTYPE=bz2
    ;;
    *)
    echo unknown archive file. Exiting.
    sleep 1
    exit
        ;;
esac

# DEPENDS: grep from configure script? autopackage-tools? download .deb or .rpm and do ldd on it? grep from freshmeat/x-website?
echo Retrieving dependencies from software listings on the net and grepping for lib in dir. Then fixing them up.
_FMEAT_DEPS=`lynx -nolist -dump  "http://freshmeat.net/projects/${_PKGNAME}"|sed -n '/Dependencies:/,/[download links]/p'|sed -n '/Dependencies:/,/No dependencies filed/p'`
_FMEAT_REQ_DEPS=`echo "$_FMEAT_DEPS"|grep '(required)'|cut -d " " -f 4|tr [:upper:] [:lower:]`
_FMEAT_OPT_DEPS=`echo "$_FMEAT_DEPS"|grep '(optional)'|cut -d " " -f 4|tr [:upper:] [:lower:]`
#_HP_DEPS=`lynx -nolist -dump  'http://www.happypenguin.org/show?XShipWars'| sed -n '/Additional System Requirements:/,/Sound:/p'| sed '1s/Additional System Requirements://;$s/Sound://'|sed -e 's/^.**//' -e's/library.*//' |sed -n '/for (sound|graphics|joystick)/p' |sed -e "s/${_PKGNAME}.*the//" -e 's/(.*)//'|tr "," "n" |sed -e 's/^.................................*$//' -e 's/Binary.?//' -e 's/Source.?//'|tr -d " "|sed '/^$/d'`
#_SF_DEPS=
_FILE_DEPS=`find -regextype egrep -iregex '[[:print:]]*readme|readme[[:print:]]*|[[:print:]]*install|install[[:print:]]*'|xargs egrep -ihIo "[a-z]+lib|lib[a-z]+"`
_DEPENDS=`echo -e "${_FILE_DEPS}n${_FMEAT_REQ_DEPS}"|sed 's/libraries|library//'|sort|uniq|sed '/^$/d'`
echo depends=(`echo "$_DEPENDS" |sed "s|^|'|"|sed "s|$|'|"|xargs -d "n"`) >> ../PKGBUILD
# return to normal dir
cd ..
echo "#makedepends=('')" >> PKGBUILD
echo "#install=" >> PKGBUILD
# If user downloaded the file through firefox the source= entry will be correct, else try to get the entry with lynx through freshmeat...
if grep ".*URL.*".*/${_new}".*" $HOME/.mozilla/firefox/*.default/downloads.rdf 2>&1 >/dev/null;
then
# if its from sourceforge/x web site transform the url to acceptable sourceforge PKGBUILD url which it doesnt do just yet...
# grab the url from the rdf.
    _FILE=$(grep ".*URL.*".*/${_new}".*" $HOME/.mozilla/firefox/*.default/downloads.rdf|sed 's|.*</a> /dev/null|head -n 1`" ];then _AUTOTOOL="0";fi
if [ -n "`find . -maxdepth 3 -name autogen.sh 2> /dev/null|head -n -1`" ];then _AUTOTOOL="1";fi

if [ "$_AUTOTOOL" = "0" ];
then
    echo "./configure --prefix=/usr" >> ../PKGBUILD
elif [ "$_AUTOTOOL" = "1" ];
then
    echo "./autogen.sh --prefix=/usr" >> ../PKGBUILD
fi

if [ -n "$_AUTOTOOL" ];
then
    echo This program uses autotools.
fi

echo "make || return 1" >> ../PKGBUILD
# checking for DESTDIR
if grep -r DESTDIR * 2>&1 >/dev/null; then
    echo 'make DESTDIR=$startdir/pkg install' >> ../PKGBUILD
fi

if ! grep "make DESTDIR" ../PKGBUILD 2>&1 >/dev/null; then
    echo 'make prefix=$startdir/pkg/usr install' >> ../PKGBUILD
    # grab all make install prefix=/someplace exec_prefix=/someotherplace bindir=/foo sbindir=/bar .... from Makefile and insert it here
fi

_INSTALLFILEEXISTS="`find -regextype egrep -iregex '[[:print:]]*install|install[[:print:]]*'|head -n 1 2> /dev/null`"
if [ -n "$_INSTALLFILEEXISTS" ]
then
    # To be colored
    echo opening INSTALL file
    sleep 1
    $_VIEWER "$_INSTALLFILEEXISTS"
fi
_READMEEXIST="`find -regextype egrep -iregex '[[:print:]]*readme|readme[[:print:]]*'|head -n 1 2> /dev/null`"
if [ -n "$_READMEEXIST" ]
then
    # To be colored
    echo opening README file
    sleep 1
    $_VIEWER "$_READMEEXIST"
fi
# Check for more info? doc ?

# cd back to dir with PKGBUILD
cd ..
echo } >> PKGBUILD

echo Opening built PKGBUILD...
sleep 1
$_EDITOR PKGBUILD
echo "Do You want to run makepkg now? Yy[enter]/Nn"
read _answer
case $_answer in
    [yY])
    makepkg
    if [ "$?" = "0" ]; then
        echo 'Makepkg completed.'
    else
        echo "The build didn't complete correctly. Exiting script."
        sleep 1
        $_TERMINAL &
        exit 0
    fi
    ;;
    [nN])
    echo "Exiting script."
    sleep 1
    exit
    ;;
    *)
    if [ "$?" = "0" -a "$_answer" = "" ]; then
        makepkg
    else
        echo "Exiting script."
            sleep 1
        exit

    fi
    ;;
esac
echo 'Listing the output of $startdir/pkg'
ls -R pkg
echo 'Was the output ok? Do you want to goto package dir(this script will also close) Yy[enter]/Nn'
read _answer
case $_answer in
    [yY])
    $_TERMINAL &
    sleep 1
    exit 0
    ;;
    [nN])
      echo "Exiting script."
        sleep 1
        exit 1
        ;;
    *)
    if [ "$?" = "0" -a "$_answer" = "" ]; then
               $_TERMINAL &
           sleep 1
           exit 0
        else
        echo "Exiting script."
        sleep 1
        exit 1
        fi
    ;;
esac

KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#6 2006-08-19 10:07:40

pbw
Member
From: Barrie ON, Canada
Registered: 2005-06-01
Posts: 65

Re: autoPKGBUILD

Good idea test1000, decided to give it a try tonight to see how it handled a basic pkg.. seems there's small syntax error somewhere in your posted script.

/usr/bin/autoPKGBUILD: line 250: unexpected EOF while looking for matching `"'
/usr/bin/autoPKGBUILD: line 256: syntax error: unexpected end of file


I just went ahead and wrote the pkgbuild myself, i apologize for my extreme lazyness.

Offline

#7 2006-08-19 10:31:25

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: autoPKGBUILD

Does it work now? I've pasted the version i had on my HD which was apparently different from this one for some reason... if it didn't work now either please tell me which file you ran it on so i can fix the script.

It should work after all... why do you think there's been a sudden influx of packages by nut543 on the AUR big_smile


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#8 2006-08-19 11:14:40

pbw
Member
From: Barrie ON, Canada
Registered: 2005-06-01
Posts: 65

Re: autoPKGBUILD

Still recieved the same error, the pkg is wxdfast
It's a simple build, nothing fancy.

test1000 wrote:

It should work after all... why do you think there's been a sudden influx of packages by nut543 on the AUR

lol, nice.

btw, here's how far it gets if it helps any..

$ autoPKGBUILD wxdfast_0.5.1.tar.gz
Moving file to /var/abs/local...
Analysing and Creating PKGBUILD entries
wxdfast
Checking compression type
$_PDIR is wxdfast-0.5.1
Uses gzip compression. Uncompressing...
Retrieving dependencies from software listings on the net and grepping for lib in dir. Then fixing them up.
/usr/bin/autoPKGBUILD: line 250: unexpected EOF while looking for matching `"'
/usr/bin/autoPKGBUILD: line 256: syntax error: unexpected end of file

Offline

Board footer

Powered by FluxBB