Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 472616 - sci-calculators/dozenal-20130216 - A complete suite of dozenal (base 12) programs
Summary: sci-calculators/dozenal-20130216 - A complete suite of dozenal (base 12) prog...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Default Assignee for New Packages
URL: http://dozenal.sourceforge.net
Whiteboard:
Keywords: EBUILD
Depends on:
Blocks:
 
Reported: 2013-06-07 20:34 UTC by Jeremy Johnson
Modified: 2013-06-10 16:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
dozenal-20130216.ebuild (dozenal-20130216.ebuild,1.73 KB, text/plain)
2013-06-07 20:34 UTC, Jeremy Johnson
Details
dozenal-20130218.ebuild (dozenal-20130218.ebuild,1.52 KB, text/plain)
2013-06-10 16:32 UTC, Jeremy Johnson
Details
metadata.xml (metadata.xml,1.46 KB, text/xml)
2013-06-10 16:33 UTC, Jeremy Johnson
Details
patch of dozpret/Makefile (dozenal-20130218.patch,497 bytes, patch)
2013-06-10 16:34 UTC, Jeremy Johnson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Johnson 2013-06-07 20:34:27 UTC
Created attachment 350356 [details]
dozenal-20130216.ebuild

Hi,

please find attached a draft ebuild for the dozenal package on sourceforge,
which is described as:

"A complete suite of dozenal (base 12) programs. Includes converters
for decimal to dozenal and vice-versa, a complete RPN dozenal calculator, and a
converter for working with metric, customary, imperial, and TGM dozenal
measurements"

To comply with Gentoo package naming conventions, I have converted the dozenal
version into the decimal version string, e.g. vE1190216 becomes 20130216.


A couple issues:

1) need to specify a source URL from sourceforge mirror to download file.
   For now, I've manually downloaded the file.

2) In order to compile, the Makefile in the dozpret subdirectory needs to be patched to remove
   the conv.h from the 2 compile lines for the Makefile rules for dozpret and conv, e.g.:

   "gcc -c dozpret.c conv.h conv.c" should be "gcc -c dozpret.c conv.c"
   and "gcc -c conv.c conv.h"       should be "gcc -c conv.c"

   Any instructions on how to create a patch file to work with epatch?

3) I can't figure out how to get the ebuild to install the binaries and man documentation.

So, for now I've just manually copied the binaries to verify that they work, e.g.:
cp /var/tmp/portage/app-misc/dozenal-20130216/work/dozenal/doz/doz /usr/local/bin/
cp /var/tmp/portage/app-misc/dozenal-20130216/work/dozenal/dec/dec /usr/local/bin/
etc.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2013-06-08 15:01:05 UTC
Comment on attachment 350356 [details]
dozenal-20130216.ebuild

># Copyright 1999-2010 Gentoo Foundation

It's 2013 now! :)

># Distributed under the terms of the GNU General Public License v2
># $Header: $

EAPI=5

>inherit base
>
>DESCRIPTION="A complete suite of dozenal (base 12) programs. Includes converters
>for decimal to dozenal and vice-versa, a complete RPN dozenal calculator, and a
>converter for working with metric, customary, imperial, and TGM dozenal
>measurements"

Description is too long. Use the <longdescription /> tag in metadata.xml instead.

>HOMEPAGE="http://dozenal.sourceforge.net"
>
># Version is date in dozenal, e.g. 2013/02/16 = 11E90216

Can we calculate that or just use the upstream version encoding in the ebuild name instead of hard-coding it here?

>MY_PN="dozenal"

MY_PN == PN so you don't need to do this.

>MY_PV="11E90216"
>MY_P="${MY_PN}_v${MY_PV}"
># SRC_URI="mirror://sourceforge.net/projects/dozenal/files/latest/download"

This can go right out.

>SRC_URI="mirror://downloads.sourceforge.net/projects/"${MY_PN}"/"${MY_P}"_src.tar.gz"

I don't think this is how we use mirror://

>LICENSE="GPL-3"
>SLOT="0"
>KEYWORDS="~amd64 ~x86"
>IUSE="doz dec dozword dozdc tgmconv dozpret dozdate dozstring doc"
>
>DEPEND=""
>RDEPEND="${DEPEND}"

Both are empty, so you don't need to set them at all.

>declare -a PROGS=( 'doz' 'dec' 'dozword' 'dozdc' 'tgmconv' 'dozpret' 'dozdate' 'dozstring')

PROGS=( .. ) implies an array, so you don't need to explicitly do "declare -a".

>S="/var/tmp/portage/app-misc/${P}/work/dozenal"

You cannot know what people use for PORTAGE_TMPDIR, so this might fail.
Use this instead:

S=${WORKDIR}/${PN}

>src_prepare() {
>	epatch "${FILESDIR}/dozpret.patch" || die "patch failed"
>}

epatch die()s on its own, so drop the "|| die*".

>#src_configure() { }

Remove that too.

>src_compile() { 
>    for f in ${PROGS[@]}; do
>		if ! use $f ; then
>			echo -e "\nCompiling $f"

If you MUST do this, then use einfo, not echo.

>			cd "${S}/$f"; 

pushd, not cd

>			make; 
>			if [ "${f}" = "dozdc" ]; then
>				make gdozdc
>			fi
>			if ! use $f; then make doc ; fi

What does this actually do? Can't we put that in a single make call?
Also, use emake, not make.

>			cd ..

popd, not cd
 
>		fi
>	done
>}
>
>#prefix = /usr/local
>bindir="/usr/local/bin"
>mandir="/usr/local/share/man/man1"

We don't install in /usr/local through ebuilds.

>src_install() { 
>    for f in ${PROGS[@]}; do
>		if ! use $f ; then
>			echo "cp ${S}/$f/$f /usr/local/bin/"

First you set up bindir (incorrectly) and then you don't use it.
Also, dobin is your friend.

>			cp ${S}/$f/$f "${bindir}/"
>			#insinto "${bindir}"; doins "${S}/$f/$f" || die "Install $f failed!"
>			if ! use doc ; then  
>				#insinto "${mandir}"; doins "${S}/$f/$f/$f.1" || die "Install $f failed!"

doins fails on its own, too. But you commented it out, so it should just go away.

>				cp ${S}/$f/$f.1 "${mandir}/"

doman is your friend here.

>			fi
>		fi
>	done
>}
>
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2013-06-08 15:13:15 UTC
(In reply to Jeroen Roovers from comment #1)
> >src_prepare() {
> >	epatch "${FILESDIR}/dozpret.patch" || die "patch failed"
> >}

Also, where is the patch?
Comment 3 Jeremy Johnson 2013-06-08 18:47:18 UTC
OK, I'm working on your corrections:

1) Update copyright notice to 1999-2010 to 1999-2013 (11X7-11E9)

2) Shortened description to just first sentence:
   "A complete set of dozenal (base 12) programs." Also added metadata.xml file

3) The dozenal source is available by git and as a versioned tarball.
   I tried to use the dozenal version "11E90216" in my ebuild name, but
   Gentoo's ebuild command complained that it violated the syntax for the
   version string (a sequence of 'digits' followed by maybe a,b followed by
   maybe a revision -r<digit>
   
   I suppose I could write a bash function
   doz2dec(){
      str=$1; len=${#str}
      sum=0; pv=1; 
      for((n=3; n>=0; n--)) do
         digit=${i:n:1}
         if   [ digit = "X" ] ; then digit=10
         elif [ digit = "E" ] ; then digit=11
         fi
         sum=$((sum+digit+pv)); pv=$((pv*12))
      done
   }

4) Removing superfluos MY_PN and DEPEND and RDEPEND variables
5) Made change S=${WORKDIR}/${PN}

6) To generate the patch file, should I make a copy of the WORKDIR 
   modify the Makefile in the copy
   then do a "diff -Naur ORIGINAL FIXED > my.patch" ?


7) The install script provided by the dozenal package is a simple bash script:

cd doz;
make;
make doc;
make install;

cd ../dec;
make;
make doc;
make install;

cd ../dozdc;
make;
make gdozdc;
make doc;
make install;

cd ../tgmconv;
make;
make doc;
make install;

cd ../dozword;
make;
make doc;
make install;

cd ../dozpret;
make;
make doc;
make install;

cd ../dozdate;
make;
make doc;
make install;

cd ../dozstring;
make;
make doc;
make install;



The individual program subdirectories, each in turn, have simple Makefiles
like this one for the decimal-to-dozenal converter (doz):

doz : main.o conv.h conv.o doz.o
        gcc -g -lm -o doz main.o conv.o doz.o dec.o

main.o : conv.h main.c conv.o doz.o dec.o
        gcc -g -lm -c main.c

conv.o : conv.c conv.h
        gcc -g -lm -c conv.c

doz.o : conv.o conv.h doz.c
        gcc -g -std=c99 -lm -c doz.c

dec.o : dec.c conv.h conv.c
        gcc -g -c dec.c

doc : doz.1
        rman -fHTML doz.1 > doz_man.html

prefix = /usr/local
bindir = /usr/local/bin
mandir = /usr/local/share/man/man1

install : doz doz.1
        cp ./doz $(bindir)
        cp ./doz.1 $(mandir)

uninstall :
        rm $(bindir)/doz
        rm $(mandir)/doz.1


The dozdc Makefile has an extra target "gdozdc"
I'll look into the Gentoo functions popd, pushd, emake, dobin, doman


I am not at all familiar with Gentoo's portage manual.
My current method is to use grep -r to look for easy/simple ebuilds
that I can use as a starting point.
Comment 4 Jeremy Johnson 2013-06-10 16:32:54 UTC
Created attachment 350652 [details]
dozenal-20130218.ebuild

Revised ebuild for dozenal.
Comment 5 Jeremy Johnson 2013-06-10 16:33:34 UTC
Created attachment 350654 [details]
metadata.xml
Comment 6 Jeremy Johnson 2013-06-10 16:34:12 UTC
Created attachment 350656 [details, diff]
patch of dozpret/Makefile
Comment 7 Jeremy Johnson 2013-06-10 16:37:32 UTC
dozenal-20130218.ebuild now tested with fetch, unpack, prepare and compile


after emerge'ing, the following files are installed:

# equery files dozenal
 * Searching for dozenal ...
 * Contents of app-misc/dozenal-20130218:
/usr
/usr/bin
/usr/bin/dec
/usr/bin/doz
/usr/bin/dozdate
/usr/bin/dozdc
/usr/bin/dozpret
/usr/bin/dozstring
/usr/bin/dozword
/usr/bin/gdozdc
/usr/bin/tgmconv
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/dec.1.bz2
/usr/share/man/man1/doz.1.bz2
/usr/share/man/man1/dozdate.1.bz2
/usr/share/man/man1/dozdc.1.bz2
/usr/share/man/man1/dozpret.1.bz2
/usr/share/man/man1/dozstring.1.bz2
/usr/share/man/man1/dozword.1.bz2
/usr/share/man/man1/gdozdc.1.bz2
/usr/share/man/man1/tgmconv.1.bz2