On Sunday January 31 2016 18:53:32 Rainer Müller wrote:
> Personally, if a upstream checksum is available, I insert it into the
> Portfile while updating the version number. Then I can generate the
> others using 'sudo port -v checksum' and insert them into the Portfile.
That's comparable to what I used to do, with a foreach loop over all subports
doing port -v checksum in the shell, redirected to a file. That leads to a lot
of copy/pasting though, and I've been known to make errors in the process.
The other thing that has bitten me quite a few times is that using the port
command for this can wipe your build directory (which may not yet be desirable
when you're just updating the checksums), and more or less obliges you to add
the variants you're going to use later on.
I've just rolled a little script that works fine, redirecting its output to
${filespath}/checksums.table :
{{{
#!/bin/sh
if [ "${prefix}" = "" ] ;then
prefix=/opt/local
fi
version=5.17.0
branch=${version%.0}
METAPORT="K5Frameworks"
PORTFILE=`port file ${METAPORT}`
FRAMEWORKS="`grep '^subport ' ${PORTFILE} | sed -e 's|subport \(.*\) {|\1|g'`"
MASTERSITE="http://download.kde.org/stable/frameworks/${branch}"
echo "# checksums for KF5 Frameworks ${version}"
echo "\narray set checksumtable {"
DISTDIR="${prefix}/var/macports/distfiles/${METAPORT}"
mkdir -p "${DISTDIR}"
for F in ${FRAMEWORKS} ;do
# remove the "kf5-" prefix
FW="${F#kf5-}"
DISTFILE="${DISTDIR}/${FW}-${version}.tar.xz"
if [ ! -e "${DISTFILE}" ] ;then
wget -P "${DISTDIR}" "${MASTERSITE}/${FW}-${version}.tar.xz"
fi
if [ -r "${DISTFILE}" ] ;then
echo "\t${F} {"
echo "\t\t`openssl rmd160 ${DISTFILE} | sed -e 's|.*= ||g'`"
echo "\t\t`openssl sha256 ${DISTFILE} | sed -e 's|.*= ||g'`"
echo "\t}"
fi
done
echo "}"
}}}
and added this to the Portfile:
{{{
# read the checksums from a file
if {[file exists ${filespath}/checksums.table]} {
source ${filespath}/checksums.table
}
proc kf5.set_checksums {} {
global checksumtable
global subport
if {[info exists checksumtable]} {
checksums rmd160 [lindex $checksumtable(${subport}) 0] \
sha256 [lindex $checksumtable(${subport}) 1]
}
}
}}}
Now I have 60-something subports below those few lines that each say
"kf5.set_checksums", and when it's time to upgrade I bump the version number in
the script, and redirect its output to where it should go. Also saves me some
time when I start the actual work around upgrading because the distfiles are
all there already.
No errors are generated during normal un/install or de/activate operations. I
haven't checked what happens when the file is removed, but I presume that the
checksums data are only used when verifying the distfiles.
R
_______________________________________________
macports-dev mailing list
[email protected]
https://lists.macosforge.org/mailman/listinfo/macports-dev