[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] maintaining perl modules with arch?
From: |
Jeremy Shaw |
Subject: |
Re: [Gnu-arch-users] maintaining perl modules with arch? |
Date: |
Fri, 03 Sep 2004 16:55:47 -0700 |
User-agent: |
Wanderlust/2.11.30 (Wonderwall) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) |
>
> However, I am not personally comfortable with precommit hooks patching
> the sources, they are potentially dangerous and unexpected.
>
> I prefer to keep a single package version and increment it manually on
> every "make dist".
I hacked up this little ditty in haskell one day (someday I should
modify it to not use a temp file, or atleast clean-up the temp file
afterward):
-->
module Version where
import Language.Haskell.THSyntax
import System.Cmd
import System.IO
import System.Posix.Temp
version :: ExpQ
version = do (tempfile, h) <- qIO (mkstemp "/tmp/cmc.XXXXXX")
qIO (system ("tla logs -srf | head -n1 > " ++ tempfile))
ver <- qIO (hGetLine h)
qIO (hClose h)
lift ver
<--
Then in my source code, I can do,
ver = $( Version.version )
which will cause the compiler to run the 'version' function at
*compile* time. Then later I can do:
putStrLn (progName ++ " version: " ++ ver)
This, of course, ties my version number to a specific revision in tla,
and needs to be extended to handle nested trees.
It's interesting in the sense that no source files are modified in the
process, it is still fully automatic, it does not required a tla hook,
and it is a horrific abuse of template haskell.
Of course, this *trick* won't work for things like perl or python that
are interpreted. But similar tricks are probably doable.
Jeremy Shaw.
--
This message contains information which may be confidential and privileged.
Unless you are the
addressee (or authorized to receive for the addressee), you may not use, copy
or disclose to anyone
the message or any information contained in the message. If you have received
the message in error,
please advise the sender and delete the message. Thank you.