Rebase COLAMD to 3.0.4

This commit replaces Source archive with a repackaged archive without
colamd/colamd.{c,h} files because of a bad license.
This commit supplies a new COLAMD 3.0.4 with a different and
acceptable license using a patch.

It is squashed into a single commit to prevent from leaking the bad
licensed COLAMD into the patch file.
f41
Petr Písař 2 years ago
parent 25a4c38a41
commit 32f2481e5a

1
.gitignore vendored

@ -1,2 +1,3 @@
lp_solve_5.5.2.0_source.tar.gz
/lp_solve_5.5.2.11_source.tar.gz
/lp_solve_5.5.2.11_source-repackaged.tar.gz

@ -0,0 +1,92 @@
From a826560622624aefbe1df965a4887c35051de9d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 27 Jun 2023 14:58:25 +0200
Subject: [PATCH 2/2] Port lp_MDO to colamd-3.0.4
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The port was done intentionally without modifying the COLAMD sources.
That should ease any future rebases, or building against
a system-provided COLAMD library.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
lp_MDO.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/lp_MDO.c b/lp_MDO.c
index 1217229..a617cf0 100644
--- a/lp_MDO.c
+++ b/lp_MDO.c
@@ -18,6 +18,7 @@
----------------------------------------------------------------------------------
*/
+#include <limits.h> /* for INT_MAX */
#include <string.h>
#include "commonlib.h"
#include "lp_lib.h"
@@ -28,6 +29,18 @@
# include "lp_fortify.h"
#endif
+/* COLAMD has explicit 32-bit and 64-bit interfaces. To keep polymorphic int
+ * type in this code, alias the functions here. */
+#if INT_MAX == (1<<31) - 1
+ /* Use default names. */
+#elif INT_MAX == (1<<63) - 1
+# define colamd colamd_l
+# define colamd_recommended colamd_l_recommended
+# define symamd symamd_l
+#else
+# error "Only 32-bit and 64-bit int types are supported"
+#endif
+
STATIC MYBOOL includeMDO(MYBOOL *usedpos, int item)
{
/* Legend: TRUE => A basic slack variable already in the basis
@@ -160,7 +173,8 @@ int __WINAPI getMDO(lprec *lp, MYBOOL *usedpos, int *colorder, int *size, MYBOOL
int nrows = lp->rows+1, ncols = colorder[0];
int i, j, kk, n;
int *col_end, *row_map = NULL;
- int Bnz, Blen, *Brows = NULL;
+ int Bnz, *Brows = NULL;
+ size_t Blen;
int stats[COLAMD_STATS];
double knobs[COLAMD_KNOBS];
@@ -187,7 +201,12 @@ int __WINAPI getMDO(lprec *lp, MYBOOL *usedpos, int *colorder, int *size, MYBOOL
/* Store row indeces of non-zero values in the basic columns */
Blen = colamd_recommended(Bnz, nrows, ncols);
- allocINT(lp, &Brows, Blen, FALSE);
+ if (Blen == 0 || Blen > INT_MAX) {
+ error = TRUE;
+ stats[COLAMD_STATUS] = COLAMD_ERROR_out_of_memory;
+ goto Transfer;
+ }
+ allocINT(lp, &Brows, (int)Blen, FALSE);
prepareMDO(lp, usedpos, colorder, Brows, row_map);
#ifdef Paranoia
verifyMDO(lp, col_end, Brows, nrows, ncols);
@@ -203,14 +222,14 @@ int __WINAPI getMDO(lprec *lp, MYBOOL *usedpos, int *colorder, int *size, MYBOOL
error = !symamd(nrows, colorder, col_end, Brows, knobs, stats, mdo_calloc, mdo_free);
}
else
- error = !colamd(nrows, ncols, Blen, Brows, col_end, knobs, stats);
+ error = !colamd(nrows, ncols, (int)Blen, Brows, col_end, knobs, stats);
#else
if(symmetric && (nrows == ncols)) {
MEMCOPY(colorder, Brows, ncols + 1);
error = !symamd(nrows, colorder, col_end, Brows, knobs, stats, mdo_calloc, mdo_free);
}
else
- error = !colamd(nrows, ncols, Blen, Brows, col_end, (double *) NULL, stats);
+ error = !colamd(nrows, ncols, (int)Blen, Brows, col_end, (double *) NULL, stats);
#endif
/* Transfer the estimated optimal ordering, adjusting for index offsets */
--
2.41.0

File diff suppressed because it is too large Load Diff

@ -1,14 +1,8 @@
Name: lpsolve
Version: 5.5.2.11
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Mixed Integer Linear Programming (MILP) solver
# bfp/bfp_LUSOL/lp_LUSOL.c: LGPL-2.1-or-later
# colamd/colamd.c: ??? (free with attribution in Matlab)
# Waiting on an identifier
# <https://gitlab.com/fedora/legal/fedora-license-data/-/issues/230>
# colamd/colamd.h: ??? (free with attribution in Matlab)
# Waiting on an identifier
# <https://gitlab.com/fedora/legal/fedora-license-data/-/issues/230>
# lp_crash.c: LGPL-2.1-or-later
# lp_lib.c: LGPL-2.1-or-later
# lp_lib.h: LGPL-2.1-or-later
@ -25,16 +19,24 @@ Summary: Mixed Integer Linear Programming (MILP) solver
# lp_SOS.c: LGPL-2.1-or-later
# lp_utils.c: LGPL-2.1-or-later
# README.txt: LGPL-2.1-or-later
# lp_solve-5.5.2.11-Rebase-COLAMD-to-3.0.4.patch: BSD-3-clause
## Unused and nonpackaged
# bfp/bfp_LUSOL/LUSOL/hbio.c: xlock-like
# configure: FSFUL
License: LGPL-2.1-or-later AND GPL-2.0-or-later WITH Bison-exception-2.2
License: LGPL-2.1-or-later AND GPL-2.0-or-later WITH Bison-exception-2.2 AND BSD-3-clause
# There is a mailing list at <https://groups.google.com/g/lp_solve>.
URL: https://sourceforge.net/projects/lpsolve
# A separate documention at
# <https://downloads.sourceforge.net/lpsolve/lp_solve_%%{version}_doc.tar.gz>
# contains proprietary JavaScript files and javascript trackers.
Source: https://downloads.sourceforge.net/lpsolve/lp_solve_%{version}_source.tar.gz
#
# This is a repackaged source tar ball from
# <https://downloads.sourceforge.net/lpsolve/lp_solve_%%{version}_source.tar.gz>.
# Original archive contained a nonfree COLAMD code (colamd/colamd.{c,h}),
# <https://gitlab.com/fedora/legal/fedora-license-data/-/issues/230>.
# A new upstream COLAMD code with an acceptable code is supplied in
# Rebase-COLAMD-to-3.0.4.patch.
Source: lp_solve_5.5.2.11_source-repackaged.tar.gz
# Use system-wide compiler, compiler and linker flags
Patch0: lp_solve-5.5.2.11-Respect-CC-CFLAGS-and-LDFLAGS.patch
# Port to C99, GCC 14 will remove support for previous standards, proposed to
@ -42,14 +44,18 @@ Patch0: lp_solve-5.5.2.11-Respect-CC-CFLAGS-and-LDFLAGS.patch
Patch1: lp_solve-5.5.2.11-Port-to-C99.patch
# Do not duplicate library code in the the tool
Patch2: lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch
# 1/2 Rebase bundled COLAMD to 3.0.4, proposed to the upstream.
Patch3: lp_solve-5.5.2.11-Rebase-COLAMD-to-3.0.4.patch
# 2/2 Rebase bundled COLAMD to 3.0.4, proposed to the upstream.
Patch4: lp_solve-5.5.2.11-Port-lp_MDO-to-colamd-3.0.4.patch
BuildRequires: bash
# binutils for ar and ranlib
BuildRequires: binutils
BuildRequires: coreutils
BuildRequires: gcc
BuildRequires: sed
# Tests:
BuildRequires: grep
Provides: bundled(colamd) = 3.0.4
%description
Mixed Integer Linear Programming (MILP) solver lpsolve solves pure linear,
@ -65,8 +71,7 @@ Header files for developing with lpsolve library.
%prep
%autosetup -p1 -n lp_solve_5.5
sed -n -e '/Authors:/,/http:\/\/www\.cise\.ufl/p' < colamd/colamd.c \
> colamd/colamd_license
mv colamd/License.txt colamd/colamd_license
chmod -x lp_lib.h
%build
@ -110,6 +115,9 @@ LD_LIBRARY_PATH="$LP_PATH" ./a.out </dev/null
%{_includedir}/lpsolve
%changelog
* Tue Aug 01 2023 Petr Pisar <ppisar@redhat.com> - 5.5.2.11-3
- Rebase COLAMD to 3.0.4
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.5.2.11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

@ -1 +1 @@
SHA512 (lp_solve_5.5.2.11_source.tar.gz) = 24f5a14d0c77a71e1ab3f46e08ea3f85f2f116ae2d3d2c54acddc5fb138251ba258240284060827e1b8b7ef15d580acecc242329ec775802fe5e8028407499bc
SHA512 (lp_solve_5.5.2.11_source-repackaged.tar.gz) = f026e32b15c1455508dc2f496496075cb0b345b1285fa5a8bdc9e83d29b9b8bdd018e19cd5f33f883dc75382599a2b76f0d3d90d1e6c548a71ac4cc01f781649

Loading…
Cancel
Save