OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /v/openpkg/cvs                   Email:  r...@openpkg.org
  Module: openpkg-src                      Date:   19-Jul-2009 14:30:47
  Branch: HEAD                             Handle: 2009071913304600

  Added files:
    openpkg-src/scala       scala.c
  Modified files:
    openpkg-src/scala       scala.spec

  Log:
    replace scala(1) with a C program to be able to use it directly in a
    shebang line

  Summary:
    Revision    Changes     Path
    1.1         +30 -0      openpkg-src/scala/scala.c
    1.8         +7  -1      openpkg-src/scala/scala.spec
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/scala/scala.c
  ============================================================================
  $ cvs diff -u -r0 -r1.1 scala.c
  --- /dev/null 2009-07-19 14:30:46 +0200
  +++ scala.c   2009-07-19 14:30:47 +0200
  @@ -0,0 +1,30 @@
  +
  +#include <stdio.h>
  +#include <stdlib.h>
  +#include <string.h>
  +#include <unistd.h>
  +
  +#define SCALA_BIN "@l_prefix@/bin"
  +#define SCALA_SH  "@l_prefix@/lib/scala/bin/scala"
  +
  +int main(int argn, char **argv)
  +{
  +    char *path_old;
  +    char *path_new;
  +
  +    /*  add Scala binary directory to PATH  */
  +    if ((path_old = getenv("PATH")) == NULL)
  +        path_old = "/bin:/usr/bin:/sbin:/usr/sbin";
  +    if ((path_new = (char *)malloc(strlen(SCALA_BIN) + 1 + strlen(path_old) 
+ 1)) == NULL)
  +        abort();
  +    sprintf(path_new, "%s:%s", SCALA_BIN, path_old);
  +    setenv("PATH", path_new, 1);
  +
  +    /*  execute Scala wrapper script  */
  +    argv[0] = SCALA_SH;
  +    if (execv(argv[0], argv) == -1)
  +        abort();
  +
  +    return 0;
  +}
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/scala/scala.spec
  ============================================================================
  $ cvs diff -u -r1.7 -r1.8 scala.spec
  --- openpkg-src/scala/scala.spec      19 Jul 2009 12:11:45 -0000      1.7
  +++ openpkg-src/scala/scala.spec      19 Jul 2009 12:30:46 -0000      1.8
  @@ -36,6 +36,7 @@
   
   #   list of sources
   Source0:      
http://www.scala-lang.org/downloads/distrib/files/scala-%{version}.final.tgz
  +Source1:      scala.c
   Patch0:       scala.patch
   
   #   build information
  @@ -66,6 +67,9 @@
   
   %build
       rm -f bin/*.bat
  +    cp %{SOURCE scala.c} .
  +    %{l_shtool} subst %{l_value -s -a} scala.c
  +    %{l_cc} %{l_cflags} %{l_ldflags} -o scala scala.c
   
   %install
       rm -rf $RPM_BUILD_ROOT
  @@ -73,13 +77,15 @@
           $RPM_BUILD_ROOT%{l_prefix}/bin \
           $RPM_BUILD_ROOT%{l_prefix}/lib/scala \
           $RPM_BUILD_ROOT%{l_prefix}/man/man1
  -    for prog in `find bin -type f -print | sed -e 's;^bin/;;'`; do
  +    for prog in `find bin -type f -print | sed -e 's;^bin/;;' | grep -v 
'^scala$'`; do
           ( echo "#!/bin/sh"
             echo "PATH=\"%{l_prefix}/bin:\$PATH\"; export PATH"
             echo "exec %{l_prefix}/lib/scala/bin/$prog \${1+\"\...@\"}"
           ) >$RPM_BUILD_ROOT%{l_prefix}/bin/$prog
           chmod a+x $RPM_BUILD_ROOT%{l_prefix}/bin/$prog
       done
  +    %{l_shtool} install -c -s -m 755 \
  +        scala $RPM_BUILD_ROOT%{l_prefix}/bin/
       %{l_shtool} install -c -m 644 \
           man/man1/* $RPM_BUILD_ROOT%{l_prefix}/man/man1/
       cp -rp bin lib meta \
  @@ .
______________________________________________________________________
OpenPKG                                             http://openpkg.org
CVS Repository Commit List                     openpkg-cvs@openpkg.org

Reply via email to