[sympow] Make a functional sympow package.

pcpa pcpa at fedoraproject.org
Wed Jul 11 16:43:00 UTC 2012


commit 805c71263b9e93a54ef25e1de9126428ce6d9c47
Author: pcpa <paulo.cesar.pereira.de.andrade at gmail.com>
Date:   Wed Jul 11 13:41:21 2012 -0400

    Make a functional sympow package.
    
      Previously it would need to be run as root to not crash on simple usages.

 sympow-1.019-datafiles.patch |   76 ++++++++++++++++++++++++++++++++++++++++++
 sympow-launcher              |   27 ---------------
 sympow.spec                  |   58 ++++++++++++++++++++++----------
 3 files changed, 116 insertions(+), 45 deletions(-)
---
diff --git a/sympow-1.019-datafiles.patch b/sympow-1.019-datafiles.patch
new file mode 100644
index 0000000..e08f296
--- /dev/null
+++ b/sympow-1.019-datafiles.patch
@@ -0,0 +1,76 @@
+diff -p -up SYMPOW-1.019/disk.c.orig SYMPOW-1.019/disk.c
+--- SYMPOW-1.019/disk.c.orig	2009-09-03 18:20:37.000000000 -0300
++++ SYMPOW-1.019/disk.c	2009-09-03 18:22:08.000000000 -0300
+@@ -47,8 +47,8 @@ static int get_params(int which,int sp,i
+  while (1)
+  {if (!getline0(F,LINE,64))
+   {printf("**ERROR** %s not found in param_data file\n",S);
+-   if (!HECKE) printf("It can be added with './sympow -new_data %i",sp);
+-   else printf("It can be added with './sympow -new_data %i",ep);
++   if (!HECKE) printf("It can be added with 'sympow -new_data %i",sp);
++   else printf("It can be added with 'sympow -new_data %i",ep);
+    if ((sp&1) || HECKE) printf("d%i",dv); if ((HECKE) && (sp>1)) printf("h");
+    if ((CM_CASE) && ((sp&3)==0)) printf("c"); printf("'\n"); exit(-1);}
+   if ((S[0]==LINE[0]) && (S[1]==LINE[1]) && (S[2]==LINE[2]) && (S[3]==LINE[3])
+diff -p -up SYMPOW-1.019/generate.c.orig SYMPOW-1.019/generate.c
+--- SYMPOW-1.019/generate.c.orig	2009-09-03 18:20:49.000000000 -0300
++++ SYMPOW-1.019/generate.c	2009-09-03 18:22:23.000000000 -0300
+@@ -101,9 +101,11 @@ int assure_line(char *STR)
+ 
+ void new_sympow_s1(char *A)
+ {procit(A);
+- printf("echo 'Removing any old data files'\n"); printf("cd datafiles\n");
+- printf("%s -f %s %s %s\n",RM,Mtxt1,Stxt1,Mbin1);
+- if (HILO) printf("%s -f %s %s %s\n",RM,Mtxt2,Stxt2,Mbin2); printf("cd ..\n");}
++ printf("if [ -d datafiles ]; then\n");
++ printf("    echo 'Removing any old data files'\n"); printf("    pushd datafiles\n    touch param_data\n");
++ printf("    %s -f %s %s %s\n",RM,Mtxt1,Stxt1,Mbin1);
++ if (HILO) printf("    %s -f %s %s %s\n",RM,Mtxt2,Stxt2,Mbin2); printf("    popd\n");
++ printf("else\n    mkdir datafiles\n    touch datafiles/param_data\nfi\n");}
+ 
+ void new_sympow_pari(char *A)
+ {int i; procit(A); pari_params();
+@@ -142,10 +144,10 @@ void new_sympow_s2(char *A)
+  trimit(Mtxt1); trimit(Stxt1); if (HILO) {trimit(Mtxt2); trimit(Stxt2);}
+  printf("echo 'Turning the meshes into binaries'\n");
+  printf("NUM=`%s -c AT %s`\n",GREP,Mtxt1);
+- printf("../sympow -txt2bin $NUM %s < %s\n",Mbin1,Mtxt1);
++ printf("sympow -txt2bin $NUM %s < %s\n",Mbin1,Mtxt1);
+  if (HILO)
+  {printf("NUM=`%s -c AT %s`\n",GREP,Mtxt2);
+-  printf("../sympow -txt2bin $NUM %s < %s\n",Mbin2,Mtxt2);}
++  printf("sympow -txt2bin $NUM %s < %s\n",Mbin2,Mtxt2);}
+  printf("cd ..\n");}
+ 
+ void rewarp_params()
+diff -p -up SYMPOW-1.019/new_data.orig SYMPOW-1.019/new_data
+--- SYMPOW-1.019/new_data.orig	2009-09-03 18:20:25.000000000 -0300
++++ SYMPOW-1.019/new_data	2009-09-03 18:21:31.000000000 -0300
+@@ -1,7 +1,7 @@
+ #! /bin/sh
+ #
+ # This script should not need to be run directly,
+-# but will be automatically executed via "./sympow -new_data []"
++# but will be automatically executed via "sympow -new_data []"
+ #
+ # example direct usages
+ # sh new_data /bin/sh /usr/bin/gp '-sp 3 -dv 2'
+@@ -18,11 +18,11 @@ echo "Running the new_data script for $3
+ 
+ SH=$1 && GP=$2
+ echo "Making the datafiles for $3" && echo "" &&
+-./sympow -rewarp && ./sympow -shell1 "$3" &&
+-./sympow -shell1 "$3" | $SH &&
++sympow -rewarp && sympow -shell1 "$3" &&
++sympow -shell1 "$3" | $SH &&
+ echo 'Running the gp script' && echo "" &&
+-./sympow -pari "$3" &&
+-./sympow -pari "$3" | $GP -q > /dev/null && echo "" &&
+-./sympow -shell2 "$3" &&
+-./sympow -shell2 "$3" | $SH &&
+-./sympow -rewarp && echo "Finished with $3"
++sympow -pari "$3" &&
++sympow -pari "$3" | $GP -q > /dev/null && echo "" &&
++sympow -shell2 "$3" &&
++sympow -shell2 "$3" | $SH &&
++sympow -rewarp && echo "Finished with $3"
diff --git a/sympow.spec b/sympow.spec
index 7db59f1..e1ddf34 100644
--- a/sympow.spec
+++ b/sympow.spec
@@ -1,15 +1,15 @@
+%global         sympowdir                %{_libdir}/%{name}
+
 Name:           sympow
 Version:        1.019
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Special Values of Symmetric Power Elliptic Curve L-Functions
 Group:          Applications/Engineering
 License:        BSD
 URL:            http://www.maths.bris.ac.uk/~mamjw/
 Source0:        http://www.maths.bris.ac.uk/~mamjw/sympow.tar.bz2
 Source1:        sympow-README.Fedora
-Source2:        sympow-launcher
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
+Patch0:         sympow-1.019-datafiles.patch
 BuildRequires:  pari-gp
 
 
@@ -21,8 +21,12 @@ elliptic curve L-functions.
 %prep
 %setup -q -n SYMPOW-%{version}
 cp %{SOURCE1} README.Fedora
-cp %{SOURCE2} sympow-launcher
+%patch0 -p1
 
+sed \
+    -e 's|"new_data"|"%{sympowdir}/new_data"|' \
+    -e 's|\(standard.\.gp\)|%{sympowdir}/\1|g' \
+    -i generate.c
 
 %build
 export CFLAGS="%{optflags}"
@@ -31,33 +35,51 @@ make %{?_smp_mflags}
 
 
 %install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}/datafiles
+mkdir -p $RPM_BUILD_ROOT%{sympowdir}/datafiles
 # executables
-install -m 755 %{name} $RPM_BUILD_ROOT%{_libdir}/%{name}/
-install -m 755 new_data $RPM_BUILD_ROOT%{_libdir}/%{name}/
+install -m 755 %{name} $RPM_BUILD_ROOT%{sympowdir}/
+install -m 755 new_data $RPM_BUILD_ROOT%{sympowdir}/
 # datafiles
-install -m 644 datafiles/* $RPM_BUILD_ROOT%{_libdir}/%{name}/datafiles/
+install -m 644 datafiles/* $RPM_BUILD_ROOT%{sympowdir}/datafiles/
 # more datafiles
-install -m 644 *.gp $RPM_BUILD_ROOT%{_libdir}/%{name}/
+install -m 644 *.gp $RPM_BUILD_ROOT%{sympowdir}/
 
 # launcher script
 mkdir -p $RPM_BUILD_ROOT%{_bindir}
-install -m 755 sympow-launcher $RPM_BUILD_ROOT%{_bindir}/%{name}
-
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
+cat > $RPM_BUILD_ROOT%{_bindir}/%{name} << EOF
+#!/bin/sh
+
+SYMPOW_DATA=%{sympowdir}/datafiles
+if test -n "\$SYMPOW_DIR"; then
+    if [ ! -d \$SYMPOW_DIR/datafiles ]; then
+	mkdir -p \$SYMPOW_DIR/datafiles
+	cp -far \$SYMPOW_DATA/*.txt \$SYMPOW_DATA/param_data \$SYMPOW_DIR/datafiles
+    fi
+    cd \$SYMPOW_DIR
+else
+    cd %{sympowdir}
+fi
+
+exec %{sympowdir}/%{name} "\$@"
+EOF
+chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
 
 %files
-%defattr(-,root,root,-)
 %doc README COPYING README.Fedora
 %{_bindir}/%{name}
 %{_libdir}/%{name}
 
 
 %changelog
+* Wed Jul 11 2012 pcpa <paulo.cesar.pereira.de.andrade at gmail.com> - 1.019-6
+- Remove BuildRoot, %%clean and %%defattr.
+- Add my Mandriva patch to create .bin files otherwise sympow will
+  just crash on actual usage.
+- Remove sympow-launcher and create it dynamically in spec.
+- The new sympow launcher also checks for the SYMPOW_DATA environment
+  variable and copies data there if empty. This is required because
+  data files may be changed or new ones created by users.
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.019-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list