Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Feb 2005 10:49:44 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        Florent Thoumie <flz@xbsd.org>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Questions about creating a port
Message-ID:  <20050217084944.GB1161@straylight.m.ringlet.net>
In-Reply-To: <4213B71B.4070601@xbsd.org>
References:  <20050116175951.20a95dfe@ale.varnet.bsd> <4213B71B.4070601@xbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--xXmbgvnjoT4axfJE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 16, 2005 at 10:11:55PM +0100, Florent Thoumie wrote:
> Alejandro Pulver wrote:
> >Hello,
> >
> >I want to create a port of the modified version of 'generator' called=20
> >'generator-cbiere'.
> >
> >I partially made the port: it compiles and runs, but I have some questio=
ns=20
> >about the distribution, installation, patching, compiler warnings and ty=
pe=20
> >decalrations.
> >
> >Distribution:
> >
> >The program is distributed by the author as a (complete) compressed=20
> >(tar/bz2) source called 'generator-0.35-cbiere.tar.bz2', or as a=20
> >compressed (bz2) patch called 'generator-0.35-cbiere.udiff.bz2' (that mu=
st=20
> >be applied to the original version of 'generator').
> >
> >Both are called in a non-standard format=20
> >("${PORTNAME}${PORTVERSION}-cbiere"), I think it should be=20
> >'generator-cbiere-0.35'. So (for using the complete source) I have to=20
> >change ${DISTFILES} (or ${DISTNAME} and ${EXTRACT_SUFX}) and ${WORKSRC},=
=20
> >or upload that file to my server with the correct name.
> >
> >Which one is the best method to distribute the port (full source or=20
> >patch)? Can I include the patch (96386 bytes) directly in the 'files/'=
=20
> >directory of the port?
>=20
> 	I'll use full source, and modify DISTFILES, try to use upstream=20
> 	sites.

I personally would also go for full sources, yes.

As to the distfile name, a better solution would be to modify just
DISTNAME and then define USE_BZIP2 - see section 5.4.3, "EXTRACT_SUFX",
in the Porter's Handbook.  The Good Thing(tm) about USE_BZIP2 is that it
pulls archivers/bzip2 as a dependency if bzip2 is not part of the base
system.  While bzip2 is indeed part of the base system on recent
versions of FreeBSD, this is still the right way to do it for various
reasons related to portability.

> >Installation:
> >
> >The program is installed as 'bin/generator-gtk', like 'generator' (the=
=20
> >original version), so they will conflict. How can I avoid this (I mean h=
ow=20
> >to rename the binary 'generator-gtk' to 'generator-cbiere-gtk')?
>=20
> 	You can either set CONFLICTS or use in-line editing (USE_REINPLACE=20
> 	and
> 	REINPLACE_CMD) to modify the Makefile so that it installs generator
> 	binary under a different name.

If there is a case when both the 'generator' and 'generator-cbiere' MAY
be installed simultaneously, then either REINPLACE_CMD or passing a
--program-prefix or --program-suffix to a GNU configure-style script
would be best.  If nobody would ever really need to install both at the
same time, CONFLICTS is better.

> >Compiler warnings:
> >
> >There are (a lot of) compiler warnings about unused variables. The=20
> >original port ('generator') does not show them, so I suppose the=20
> >responsible is who did the patch. Should I fix them?
>=20
> 	You can try to fix them removing unused variables and sending patches
> 	upstream (to the developers). I guess you could use :
> 	CFLAGS +=3D -Wno-unused too.

The point about sending the patches to the original authors cannot be
stressed too much.  If you *do* make a patch to a port, then there are
two cases:
- the patch applies to all systems, not just FreeBSD: in that case you
  really ought to send it to the program developers, since it would
  probably be useful to people using the program on other systems,
  too;
- the patch only applies to FreeBSD: make it so it detects whether it's
  running on FreeBSD if possible (with C, that would usually be a matter
  of an #ifdef __FreeBSD__; for Perl, if ($^O eq 'freebsd'); for shell
  scripts, if [ "`uname -s`" =3D "FreeBSD" ], and so on).  If you can do
  that, see the first case about sending it to the developers - it might
  turn out to be useful for other systems, too.

In this particular case, CFLAGS +=3D -Wno-unused looks like a good
workaround, although it might fail if the port is compiled with a
compiler other than GCC.  If you can take the time to actually fix the
unused variable definitions, it would indeed be best to do so and send
the patch to the authors.

> >Type decalrations:
> >
> >The modified version (generator-cbiere) did not compile because there wa=
s=20
> >an invalid type declaration "u_int64_t", that I changed into "uint64_t".=
=20
> >Then I noticed declarations saying "uint8", and I think the standard=20
> >defines it as "uint8_t". Should I change them?
>=20
> 	Just do a patch, or use REINPLACE_CMD.

Careful there - if you use REINPLACE_CMD, you have to be *certain* that
you will only replace the literal string 'uint8' when it is NOT part of
a correct 'uint8_t' declaration :)

> >Patching:
> >
> >In almost all the cases I will end with more than one patch, so: should =
I=20
> >use different patches or merge them in one?
>=20
> 	Try to create a patch for each file modified and name it like these :
> 	x patch-src::Makefile.in if the patch modifies
> 	${WRKDIR}/src/Makefile.in.
> 	x patch-foo.c if the patch modifies ${WRKDIR}/foo.c.
>=20
> 	Put these patches in ${FILESDIR} (files/).

This is generally regarded as the correct way to do things - usually.
However, if there are dozens (or in some cases even hundreds) of files
to be patched for a single purpose (e.g. changing #include <malloc.h> to
#include <stdlib.h>, or adding an #include <sys/types.h> to many files
as needed, or something), then it might be a better idea to combine
*those fixes* in a single patchfile.  However, in that case, try to
avoid patching the same source file in two different patchfiles, as
explained in the Porter's Handbook.  For any 'should I...' or 'how do
I...' questions related to ports, please try the Porter's Handbook first
:)

G'luck,
Peter

--=20
Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
If the meanings of 'true' and 'false' were switched, then this sentence wou=
ldn't be false.

--xXmbgvnjoT4axfJE
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iD8DBQFCFFqo7Ri2jRYZRVMRAggjAJ9g24uJqjry2ZzDoBN9Mmb9cR3DbgCgwd6U
XWXwl7o4IpST+ue5VlBJHSE=
=6YHM
-----END PGP SIGNATURE-----

--xXmbgvnjoT4axfJE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050217084944.GB1161>