void-packages/xbps-src/shutils/fetch_funcs.sh
Juan RP 1ebe5e6b5e Mega-commit removing deps in xbps-base-chroot.
xbps-src:
  * ALWAYS use the static bins, to avoid breakage in the chroot.
  * Remove XBPS_FETCH_CMD. Use xbps-fetch (static) now that it's
    useful to download all distfiles in xbps-base-system.
  * Use busybox in the chroot and create links in /usr/local/bin
    at creation time. This helps to remove many packages that
    had problems with host/target libs (acl, attr, libarchive, etc).

build templates:
  * Add explicit gettext and texinfo build dependencies in all
    packages that need them, because they aren't built anymore
    by xbps-base-chroot.
  * Fixed some packages using build_style=gnu_makefile, that were
    broken because pre/post_configure() is not executed for a while,
    they should use pre/post_build() instead.

--HG--
extra : convert_revision : 0eaaf4917fd824710d0895e0c984bbc236b0cdf8
2009-10-30 22:14:09 +01:00

168 lines
3.9 KiB
Bash

#-
# Copyright (c) 2008 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-
#
# Verifies that file's checksum downloaded matches what it's specified
# in template file.
#
verify_sha256_cksum()
{
local file="$1"
local origsum="$2"
[ -z "$file" -o -z "$cksum" ] && return 1
filesum=$(${XBPS_DIGEST_CMD} $XBPS_SRCDISTDIR/$file)
if [ "$origsum" != "$filesum" ]; then
msg_error "SHA256 checksum doesn't match for $file."
fi
msg_normal "SHA256 checksum OK for $file."
}
fetch_update_cksum()
{
local tmpl="$XBPS_TEMPLATESDIR/$pkgname/template"
local upcmd=$(basename $XBPS_SRCDISTDIR/$1)
sed -i -e "s|checksum.*|checksum=$(${XBPS_DIGEST_CMD} ${upcmd})|" $tmpl
return $?
}
#
# Downloads the distfiles and verifies checksum for all them.
#
fetch_distfiles()
{
local pkg="$1"
local upcksum="$2"
local dfiles=
local localurl=
local dfcount=0
local ckcount=0
local f=
[ -z $pkgname ] && exit 1
#
# There's nothing of interest if we are a meta template.
#
[ "$build_style" = "meta-template" ] && return 0
#
# If nofetch is set in a build template, skip this phase
# entirely and run the do_fetch() function.
#
if [ -n "$nofetch" ]; then
cd ${XBPS_BUILDDIR} && run_func do_fetch
return $?
fi
cd $XBPS_SRCDISTDIR || return 1
for f in ${distfiles}; do
curfile=$(basename $f)
if [ -f "$XBPS_SRCDISTDIR/$curfile" ]; then
if [ -n "$upcksum" ]; then
fetch_update_cksum $curfile
run_template $pkgname
fi
for i in ${checksum}; do
if [ $dfcount -eq $ckcount -a -n $i ]; then
cksum=$i
found=yes
break
fi
ckcount=$(($ckcount + 1))
done
if [ -z $found ]; then
msg_error "cannot find checksum for $curfile."
fi
verify_sha256_cksum $curfile $cksum
if [ $? -eq 0 ]; then
unset cksum found
ckcount=0
dfcount=$(($dfcount + 1))
continue
fi
fi
msg_normal "Fetching distfile: $curfile."
if [ -n "$distfiles" ]; then
localurl="$f"
else
localurl="$url/$curfile"
fi
$XBPS_FETCH_CMD $localurl
if [ $? -ne 0 ]; then
unset localurl
if [ ! -f $XBPS_SRCDISTDIR/$curfile ]; then
msg_error "couldn't fetch $curfile."
else
msg_error "there was an error fetching $curfile."
fi
else
unset localurl
if [ -n "$upcksum" ]; then
fetch_update_cksum $curfile
run_template $pkgname
fi
#
# XXX duplicate code.
#
for i in ${checksum}; do
if [ $dfcount -eq $ckcount -a -n $i ]; then
cksum=$i
found=yes
break
fi
ckcount=$(($ckcount + 1))
done
if [ -z $found ]; then
msg_error "cannot find checksum for $curfile."
fi
verify_sha256_cksum $curfile $cksum
if [ $? -eq 0 ]; then
unset cksum found
ckcount=0
fi
fi
dfcount=$(($dfcount + 1))
done
unset cksum found
}