tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Random string generation during *-install



Le 25/05/2015 13:46, Taylor R Campbell a écrit :>     Date: Mon, 25 May
2015 13:34:29 +0200
From: Jean-Yves Migeon <jeanyves.migeon%free.fr@localhost>

Date: Mon, 25 May 2015 13:34:29 +0200 From: Jean-Yves Migeon
<jeanyves.migeon%free.fr@localhost>

Le 25/05/2015 13:15, Taylor R Campbell a écrit :
(tr -cd '[:graph:]' | head -c 20) < /dev/urandom

There's a slim chance that on some exotic Unixoid platform pkgsrc
supports, you can't assume there will be a /dev/urandom.  But I
wouldn't worry about it until someone actually trips over it.

One bit to highlight in this is to write </dev/urandom outside the
pipeline, not in one of the subcommands, so that the whole pipeline
will exit with failure in the slim chance it doesn't exist, in order
to make sure that someone actually trips over it instead of quietly
getting nothing in that case.

Ack, good point.

That's almost what I did, the only difference being that I
"LC_ALL=C" right before calling tr. On some platform it tries to
parse
/dev/urandom
bytes as UTF-8 encoded strings (as per locale) and tr(1) chokes when
encoding is invalid.

Hm.  I don't observe this on NetBSD with LANG=en_us.UTF-8.  Curious.

Darwin.
I suspect this will happen on FreeBSD and GNU systems.


Don't use pre-install and do-install for this -- use the INSTALL
script alongside the Makefile.  The pre-install and do-install
make targets are always (unless you explicitly set USE_DESTDIR=no,
which is
ill-advised) run at build-time when installing into a destdir
before creating a package, not at install-time when you actually
install the
package.

This is what the pkgsrc's guide says, but alas it does not say
what I am
supposed to do to patch in some code in INSTALL. So what would be
the recommended way to alter a pkginstall INSTALL script when
generated by the templates? Does that mean someone(tm) has to
"manually" patch WRKSRC/.pkginstall/INSTALL?

It's a file you write alongside the package's Makefile.  See, e.g.,
mail/mutt-devel/INSTALL.  I believe this should be included in the
binary package's +INSTALL script even if you cause auto-generated
installation actions, e.g. by requiring user/group creation.

Thanks!

--
Jean-Yves Migeon


Home | Main Index | Thread Index | Old Index