diff mbox series

[bug#56729,RFC,v3,11/32] gnu: Add sympow.

Message ID 1ba8f917eb764c920eab9c766026dca251ec1f3c.1685391447.git.guix@ikherbers.com
State New
Headers show
Series None | expand

Commit Message

vicvbcun May 29, 2023, 8:38 p.m. UTC
* gnu/packages/patches/sympow-enable-cross-compilation.patch,
gnu/packages/patches/sympow-null-terminate-dupdir.patch: New files.
* gnu/local.mk (dist_patch_DATA): Register here.
* gnu/packages/algebra.scm (sympow): New variable.
---
 gnu/local.mk                                  |   2 +
 gnu/packages/algebra.scm                      |  52 ++++++++
 .../sympow-enable-cross-compilation.patch     | 124 ++++++++++++++++++
 .../sympow-null-terminate-dupdir.patch        |  15 +++
 4 files changed, 193 insertions(+)
 create mode 100644 gnu/packages/patches/sympow-enable-cross-compilation.patch
 create mode 100644 gnu/packages/patches/sympow-null-terminate-dupdir.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 18e8235140..683c36c383 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1933,6 +1933,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/symmetrica-int32.patch			\
   %D%/packages/patches/symmetrica-return_values.patch 		\
   %D%/packages/patches/symmetrica-sort_sum_rename.patch 	\
+  %D%/packages/patches/sympow-enable-cross-compilation.patch	\
+  %D%/packages/patches/sympow-null-terminate-dupdir.patch	\
   %D%/packages/patches/t1lib-CVE-2010-2642.patch		\
   %D%/packages/patches/t1lib-CVE-2011-0764.patch		\
   %D%/packages/patches/t1lib-CVE-2011-1552+.patch		\
diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm
index 92a9faa04f..ee08378058 100644
--- a/gnu/packages/algebra.scm
+++ b/gnu/packages/algebra.scm
@@ -34,6 +34,7 @@ 
 (define-module (gnu packages algebra)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
@@ -49,6 +50,7 @@  (define-module (gnu packages algebra)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages image)
   #:use-module (gnu packages java)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages multiprecision)
@@ -1655,6 +1657,56 @@  (define-public symmetrica
 polynomials, and the representation theory of Hecke algebras of type A_n.")
     (license license:public-domain)))
 
+(define-public sympow
+  (package
+    (name "sympow")
+    (version "2.023.6")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://gitlab.com/rezozer/forks/sympow")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0anvrb0pkchc1c6hs1nlx0vpahbsn02mbms2kldszsfiizwmv72f"))
+              (patches (search-patches "sympow-enable-cross-compilation.patch"
+                                       "sympow-null-terminate-dupdir.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f ; no tests
+           #:phases #~(modify-phases %standard-phases
+                        (replace 'configure
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            ;; sympow tries to write to /var/cache
+                            ;; silence warnings when running as non-root user
+                            (substitute* "sympow.h"
+                              (("VERBOSE_DEFAULT 1")
+                               "VERBOSE_DEFAULT 0"))
+                            (substitute* "Configure"
+                              (("RM=")
+                               (string-append "RM=" (search-input-file inputs "/bin/rm")))
+                              (("GREP=")
+                               (string-append "GREP=" (search-input-file inputs "/bin/grep")))
+                              (("GP=")
+                               (string-append "GP=" (search-input-file inputs "/bin/gp")))
+                              (("SED=")
+                               (string-append "SED=" (search-input-file inputs "/bin/sed")))
+                              (("SH=")
+                               (string-append "SH=" (search-input-file inputs "/bin/sh"))))
+                            (setenv "PREFIX" #$output)
+                            (setenv "CC" #$(cc-for-target))
+                            (invoke "./Configure"))))))
+    (inputs (list bash-minimal coreutils grep pari-gp sed))
+    (native-inputs (list grep help2man pari-gp sed which))
+    (home-page "https://gitlab.com/rezozer/forks/sympow")
+    (synopsis "Package to compute elliptic curve L-functions")
+    (description
+     "SYMPOW is a package to compute special values of symmetric power
+elliptic curve L-functions.  It can compute up to about 64 digits of
+precision.")
+    (license (license:non-copyleft "file:///COPYING"))))
+
 (define-public m4rie
   (package
     (name "m4rie")
diff --git a/gnu/packages/patches/sympow-enable-cross-compilation.patch b/gnu/packages/patches/sympow-enable-cross-compilation.patch
new file mode 100644
index 0000000000..0ffc63c788
--- /dev/null
+++ b/gnu/packages/patches/sympow-enable-cross-compilation.patch
@@ -0,0 +1,124 @@ 
+Separate build-time from run-time binaries
+
+diff --git a/Configure b/Configure
+index 1ef9756..0b42b6b 100755
+--- a/Configure
++++ b/Configure
+@@ -12,36 +12,20 @@ VARPREFIX=${VARPREFIX:-"/var"}
+ 
+ FILE="Makefile.new"
+ CONFIG="config.h"
+-RM=`which \rm`
+-if [ -z "$RM" ];
+-then
+-echo "**ERROR**: Could not find rm"; exit;
+-fi
+-$RM -f $FILE
+-$RM -f $CONFIG
++RM=
++rm -f $FILE
++rm -f $CONFIG
+ VERSION=2.023.6
+ echo "#define PREFIX \"$PREFIX\"" >> $CONFIG
+ echo "#define VARPREFIX \"$VARPREFIX\"" >> $CONFIG
+ echo "#define VERSION \"$VERSION\"" >> $CONFIG
+ echo "VERSION = $VERSION" >> $FILE
+ 
+-GREP=`which \grep`
+-if [ -z "$GREP" ];
+-then
+-echo "*WARNING*: Could not find grep --- will not be able to build new_data"
+-fi
++GREP=
+ 
+-GP=`which \gp`
+-if [ -z "$GP" ];
+-then
+-echo "*WARNING*: Could not find gp --- will not be able to build new_data"
+-fi
++GP=
+ 
+-SED=`which \sed` && echo "SED = $SED" >> $FILE
+-if [ -z "$SED" ];
+-then
+-echo "*WARNING*: Could not find sed --- will not be able to build new_data"
+-fi
++SED=
+ 
+ if [ "x$ADDBINPATH" = "xyes" ]; then
+ echo "#define RM \"$RM\"" >> $CONFIG
+@@ -58,9 +42,8 @@ fi
+ [ -n "$GREP" ] && [ -n "$GP" ] && [ -n "$SED" ]\
+  && echo "#define NEW_DATA" >> $CONFIG
+ 
+-SH=/bin/sh
++SH=
+ echo "#define SH \"$SH\"" >> $CONFIG
+-echo "SH = $SH" >> $FILE
+ 
+ CC=${CC:-gcc} && echo "CC = $CC" >> $FILE
+ ##if [ -z "$CC" ];
+@@ -283,22 +266,6 @@ echo "TILDES = *~ datafiles/*~" >> $FILE
+ df="datafiles"
+ echo "DATAFILES = $df/*M.txt $df/*S.txt $df/param_data" >> $FILE
+ 
+-echo "RM = $RM" >> $FILE
+-CP=`which \cp` && echo "CP = $CP" >> $FILE
+-if [ -z "$CP" ];
+-then
+-echo "**ERROR**: Could not find cp"; exit;
+-fi
+-MKDIR=`which \mkdir` && echo "MKDIR = $MKDIR" >> $FILE
+-if [ -z "$MKDIR" ];
+-then
+-echo "**ERROR**: Could not find mkdir"; exit;
+-fi
+-TOUCH=`which \touch` && echo "TOUCH = $TOUCH" >> $FILE
+-if [ -z "$TOUCH" ];
+-then
+-echo "**ERROR**: Could not find touch"; exit;
+-fi
+ ####TAR=`which \tar` && echo "TAR = $TAR" >> $FILE
+ ####if [ -z "$TAR" ];
+ ####then
+@@ -319,19 +286,19 @@ echo "	\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(OPT) -o \$@ \$(DEFS) \$(OBJS) \$(LDFLAG
+ echo "%.o : %.c \$(HEADERS) Makefile" >> $FILE
+ echo "	\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(OPT) \$(DEFS) -c -o \$@ \$<" >> $FILE
+ echo "datafiles/param_data: \$(OTHERb)" >> $FILE
+-echo "	\$(MKDIR) -p datafiles" >> $FILE
+-echo "	\$(TOUCH) datafiles/param_data" >> $FILE
+-echo "	\$(SH) armd.sh" >> $FILE
+-echo "	\$(SED) -i -e '/logfile =/d' datafiles/*.txt" >> $FILE
++echo "	mkdir -p datafiles" >> $FILE
++echo "	touch datafiles/param_data" >> $FILE
++echo "	sh armd.sh" >> $FILE
++echo "	sed -i -e '/logfile =/d' datafiles/*.txt" >> $FILE
+ echo "sympow.1: sympow" >> $FILE
+ echo "	\$(HELP2MAN) \$(H2MFLAGS) -s 1 -n \"SYMPOW program\" -I sympow.h2m -o \$@ ./\$<" >> $FILE
+ echo "clean:" >> $FILE
+ ##echo "	\$(RM) -f \$(OBJSf) sympow \$(TILDES) \$(TARS)" >> $FILE
+-echo "	\$(RM) -f \$(OBJS) sympow sympow.1 \$(TILDES)" >> $FILE
+-echo "	\$(RM) -rf datafiles" >> $FILE
++echo "	rm -f \$(OBJS) sympow sympow.1 \$(TILDES)" >> $FILE
++echo "	rm -rf datafiles" >> $FILE
+ echo "distclean: clean" >> $FILE
+-echo "	\$(RM) -f \$(CONFEXE)" >> $FILE
+-echo "	\$(RM) -f config.h Makefile" >> $FILE
++echo "	rm -f \$(CONFEXE)" >> $FILE
++echo "	rm -f config.h Makefile" >> $FILE
+ echo "install-arch: build-arch" >> $FILE
+ echo "	install -d \$(DESTDIR)$PREFIX/bin" >> $FILE
+ echo "	install -d \$(DESTDIR)$PREFIX/share/man/man1" >> $FILE
+@@ -361,9 +328,9 @@ echo "install: install-arch install-indep" >> $FILE
+ ####echo "	\$(RM) -rf \$(WDIR)" >> $FILE
+ ####fi
+ 
+-$RM -f Makefile
+-$CP -f Makefile.new Makefile
+-$RM -f Makefile.new
++rm -f Makefile
++cp -f Makefile.new Makefile
++rm -f Makefile.new
+ 
+ echo "Makefile has been re-made. Use make if you wish to build SYMPOW"
+ echo ""
diff --git a/gnu/packages/patches/sympow-null-terminate-dupdir.patch b/gnu/packages/patches/sympow-null-terminate-dupdir.patch
new file mode 100644
index 0000000000..2640175b80
--- /dev/null
+++ b/gnu/packages/patches/sympow-null-terminate-dupdir.patch
@@ -0,0 +1,15 @@ 
+https://gitlab.com/rezozer/forks/sympow/-/merge_requests/5
+
+diff --git a/main.c b/main.c
+index 1d018dfc76888790212c7a203154c45b88acb383..0ab1386b5f3a62a79cc08adceb2e3e9553e08a4d 100644
+--- a/main.c
++++ b/main.c
+@@ -97,7 +97,7 @@ char * dupdirname(const char *name) {
+   if (eofn!=name) {
+    const size_t ublofn=eofn-name;
+    size_t cdx=0; const char * dim=NULL; char * dam=NULL; int flag=0;
+-   foldername=(char *)(malloc(ublofn)); memset(foldername,'\0',ublofn);
++   foldername=(char *)(malloc(ublofn+1)); memset(foldername,'\0',ublofn+1);
+    for(cdx=0,dim=name,dam=foldername;cdx<ublofn;++dim,++cdx) {
+     if (*dim == '/') flag=1;
+     else {if (flag) {*dam='/'; ++dam; flag=0;} *dam=*dim; ++dam;}}