1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#!/bin/sh
pkg=Matrix
if [ ! -f DESCRIPTION -o -z "$(grep "^Package: ${pkg}$" DESCRIPTION)" ]; then
echo "script must be run in package [${pkg}] root directory"
exit 1
fi
ssdir=SuiteSparse
ssver=7.6.0
sspfx=${ssdir}-${ssver}
sstgz=${sspfx}.tar.gz
ssurl=https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v${ssver}.tar.gz
if [ -f ${sstgz} ]; then
echo "Using existing ${sstgz}"
else
echo "Downloading ${sstgz} from GitHub ..."
wget ${ssurl} -O ${sstgz} || exit 1
echo "done"
fi
echo "Extracting files under inst/doc and src ..."
for d in inst/doc/${ssdir} src/${ssdir}; do
if [ -d ${d} ]; then
echo "Moving existing ${d} to ${d}.bak ..."
rm -rf ${d}.bak
mv ${d} ${d}.bak
echo "done"
fi
done
## {root}
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/README.md \
${sspfx}/ChangeLog \
${sspfx}/LICENSE.txt
## SuiteSparse_config
sslib=SuiteSparse_config
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/SuiteSparse_config.c \
${sspfx}/${sslib}/SuiteSparse_config.h
## CXsparse
sslib=CXSparse
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Source/*.[ch]
## AMD
sslib=AMD
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Source/*.[ch]
## COLAMD
sslib=COLAMD
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Source/*.[ch]
## CAMD
sslib=CAMD
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Source/*.[ch]
## CCOLAMD
sslib=CCOLAMD
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Source/*.[ch]
## CHOLMOD
sslib=CHOLMOD
tar -zxvf ${sstgz} -C inst/doc \
${sspfx}/${sslib}/README.txt \
${sspfx}/${sslib}/Doc/ChangeLog \
${sspfx}/${sslib}/Doc/License.txt \
${sspfx}/${sslib}/SuiteSparse_metis/Changelog \
${sspfx}/${sslib}/SuiteSparse_metis/LICENSE.txt \
${sspfx}/${sslib}/SuiteSparse_metis/README.txt
tar -zxvf ${sstgz} -C src \
${sspfx}/${sslib}/Include/*.h \
${sspfx}/${sslib}/Check/*.[ch] \
${sspfx}/${sslib}/Cholesky/*.[ch] \
${sspfx}/${sslib}/Utility/*.[ch] \
${sspfx}/${sslib}/MatrixOps/*.[ch] \
${sspfx}/${sslib}/Modify/*.[ch] \
${sspfx}/${sslib}/Partition/*.[ch] \
${sspfx}/${sslib}/Supernodal/*.[ch] \
${sspfx}/${sslib}/SuiteSparse_metis/include/*.h \
${sspfx}/${sslib}/SuiteSparse_metis/GKlib/*.[ch] \
${sspfx}/${sslib}/SuiteSparse_metis/libmetis/*.[ch]
echo "done"
echo "Changing prefix ${sspfx} to ${ssdir} ..."
mv inst/doc/${sspfx} inst/doc/${ssdir}
mv src/${sspfx} src/${ssdir}
echo "done"
inc=inst/include/Matrix
h=cholmod.h
echo "Copying ${h} into ${inc} ..."
if [ -f ${inc}/${h} ]; then
echo "Moving existing ${inc}/${h} to ${inc}/${h}.bak ..."
mv ${inc}/${h} ${inc}/${h}.bak
echo "done"
fi
cp src/${ssdir}/CHOLMOD/Include/${h} ${inc}
echo "done"
echo "Applying our patches ..."
patch -p0 < inst/scripts/${ssdir}.patch
patch -p0 < inst/scripts/${h}.patch
echo "done"
metis=src/${ssdir}/CHOLMOD/SuiteSparse_metis
echo "Adding disclaimer to comply with Apache-2.0 ..."
for f in $(find ${metis} \( ! -path "${metis}/*/*" -o -prune \) -type f); do
mv ${f} ${f}.bak
cat inst/scripts/disclaimer.txt ${f}.bak > ${f}
rm ${f}.bak
done
echo "done"
|