Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 245 lines (205 sloc) 7.52 KB
#!/bin/sh
. config/options
NOGET=""
do_md5sum () {
[ -z "$PKG_MD5" ] && return 0
echo -n "Computing MD5 check for $1 ... "
MD5=$(md5sum "$1" | cut -d ' ' -f 1)
if [ "$MD5" != "$PKG_MD5" ]; then
echo "INVALID [$MD5]"
mv -f "$1" "$1.BAD"
exit 1
fi
echo "OK"
}
do_sha256sum () {
[ -z "$PKG_SHA256" ] && return 0
echo -n "Computing SHA256 check for $1 ... "
SHA256=$(sha256sum "$1" | cut -d ' ' -f 1)
if [ "$SHA256" != "$PKG_SHA256" ]; then
echo "INVALID [$SHA256]"
mv -f "$1" "$1.BAD"
exit 1
fi
echo "OK"
}
if [ -z "$1" ]; then
for i in $PACKAGES/*; do
GET=yes
for j in $NOGET; do
[ ${i##*/} = $j ] && GET=no break
done
if [ $GET = yes ]; then
$SCRIPTS/get ${i#$PACKAGES/} || echo ""
fi
done
exit 0
fi
mkdir -p $STAMPS_NOARCH/$1
STAMP=$STAMPS_NOARCH/$1/${BUILD#$BUILD_BASE}.get
if [ -f "$PACKAGE_URL" ]; then
if [ -f $STAMP ]; then
[ ! $STAMP -ot $PACKAGE_URL ] && exit 0
fi
DL="yes"
fi
get_meta $1
PKG_STAMP="$PKG_VERSION-$PKG_REV"
if [ -n "$PKG_URL" ]; then
if [ -f $STAMP ]; then
if [ "$PKG_FORCE_CHECK" = "true" ]; then
echo "Checking source file for $1 ..."
file="${PKG_URL##*/}"
[ -f $ROOT/$SOURCES/$PKG_NAME/$file ] && echo " ... present" || DL="yes"
fi
[ "$PKG_STAMP" = "$(cat $STAMP)" -a -z "$DL" ] && exit 0
fi
DL="yes"
fi
if [ "$DL" = yes ]; then
$SCRIPTS/checkdeps get || exit 1
rm -f $STAMP
set_title "GET $1"
WGET_OPT="--no-check-certificate --passive-ftp --dns-timeout=50 --connect-timeout=50 --read-timeout=50 --tries=1 -c"
[ "$VERBOSE" != yes ] && WGET_OPT="$WGET_OPT -q"
mkdir -p $SOURCES/$1
[ -f "$PACKAGE_URL" ] && \
URLS=`cat $PACKAGE_URL`
[ -n "$PKG_URL" ] && \
URLS="$URLS `echo $PKG_URL`"
if [ -n "$PKG_URL_PROTO" ]; then
# count number of URLs we have
NURLS=0
for i in $URLS; do
NURLS=$(($NURLS+1))
done
if [ $NURLS != 1 ]; then
echo "Must have exactly one URL for fancy repository download, exit."
exit 1
fi
REPO_BASENAME=$PKG_NAME-$PKG_VERSION
REPO_ARCHIVE=$REPO_BASENAME.tar.bz2
# check for packages mirror usage
if [ "$MIRROR" = yes ] && [ -n "$MIRROR_URL" ]; then
REPO_ARCHIVE_URL="$MIRROR_URL/$REPO_ARCHIVE"
else
REPO_ARCHIVE_URL="$DISTRO_SRCS/$REPO_ARCHIVE"
fi
until [ -f $STAMPS_NOARCH/$1/$REPO_BASENAME.ok ] || wget $WGET_OPT -P $SOURCES/$1 $REPO_ARCHIVE_URL; do
NBWGET=$(($NBWGET+1))
if [ $NBWGET -gt 10 ]; then
echo "\nCan't get $1 sources, falling back to repository"
rm -Rf $SOURCES/$1/$REPO_BASENAME
rm -f $SOURCES/$1/$REPO_ARCHIVE
case $PKG_URL_PROTO in
svn)
[ -n "$PKG_URL_REV" ] && SVNREV="-r $PKG_URL_REV"
svn export $SVNREV $PKG_URL $SOURCES/$1/$REPO_BASENAME
tar cpjf $SOURCES/$1/$REPO_ARCHIVE -C $SOURCES/$1 $REPO_BASENAME
;;
git)
GITREV=HEAD
[ -n "$PKG_URL_REV" ] && GITREV=`echo "$PKG_URL_REV" | sed -e "s/.*~//"`
if [ `expr substr $PKG_URL 1 7` = "file://" ] ; then
WORK_PATH=`echo $PKG_URL | sed -e "s%.\{7\}%%" -e "s%~%$HOME%"`
ln -sf $WORK_PATH $SOURCES/$1/$REPO_BASENAME
cd $WORK_PATH; WORK_BRANCH=`git branch | grep '*' | cut -b3-`; cd -
else
CLONE_OPT=""
[ -n "$PKG_URL_BRANCH" ] && CLONE_OPT="--depth=1 -b $PKG_URL_BRANCH"
git clone $CLONE_OPT $PKG_URL $SOURCES/$1/$REPO_BASENAME
WORK_BRANCH="(no branch)"
fi
git --git-dir=$SOURCES/$1/$REPO_BASENAME/.git --work-tree=$SOURCES/$1/$REPO_BASENAME checkout $GITREV
[ "$PKG_RECURSIVE" = yes ] && (cd $SOURCES/$1/$REPO_BASENAME; git submodule update --init --recursive)
(REPO_ARCHIVE_FILE=$PWD/$SOURCES/$1/$REPO_ARCHIVE; cd $SOURCES/$1/$REPO_BASENAME; \
$ROOT/$SCRIPTS/git-archive-all --prefix $REPO_BASENAME/ --rev $GITREV | bzip2 > $REPO_ARCHIVE_FILE; \
[ ! "$WORK_BRANCH" = "(no branch)" ] && git checkout $WORK_BRANCH || true)
;;
hg)
[ -n "$PKG_URL_REV" ] && HGREV="-u $PKG_URL_REV"
hg clone $HGREV $PKG_URL $SOURCES/$1/$REPO_BASENAME
hg -R $SOURCES/$1/$REPO_BASENAME archive --prefix=$REPO_BASENAME/ $SOURCES/$1/$REPO_ARCHIVE
;;
cvs)
CVSREV="-r HEAD"
[ -n "$PKG_URL_REV" ] && CVSREV="-r $PKG_URL_REV"
cvs -d$PKG_URL export $CVSREV -d $SOURCES/$1/$REPO_BASENAME $PKG_NAME
tar cpjf $SOURCES/$1/$REPO_ARCHIVE -C $SOURCES/$1 $REPO_BASENAME
;;
*)
echo "Unsupported PKG_URL_PROTO '$PKG_URL_PROTO', exit."
exit 1
;;
esac
rm -Rf $SOURCES/$1/$REPO_BASENAME
break;
fi
done
# do we need checksums on repositories?
# do_md5sum "$SOURCES/$1/$REPO_BASENAME"
# do_sha256sum "$SOURCES/$1/$REPO_BASENAME"
touch $STAMPS_NOARCH/$1/$REPO_BASENAME.ok
else
for i in $URLS; do
i=$(eval echo $i)
if [ -n "$PKG_ARCHIVE_NAME" ]; then
PACKAGE_BASENAME=$PKG_ARCHIVE_NAME
else
PACKAGE_BASENAME=`/bin/echo -e $(basename $i | sed -e 's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g')`
fi
if [ -f $SOURCES/$1/$PACKAGE_BASENAME ]; then
# file is already downloaded, just ignore.
echo "Detected $PACKAGE_BASENAME for $1 sources..."
elif [ -f $MACHINE_PACKAGES/$1/$PACKAGE_BASENAME ]; then
# machine-specific file is already here, just copy
echo "\nJust copying machine $PACKAGE_BASENAME for $1 sources..."
cp $MACHINE_PACKAGES/$1/$PACKAGE_BASENAME $SOURCES/$1
elif [ -f $PLATFORM_PACKAGES/$1/$PACKAGE_BASENAME ]; then
# platform-specific file is already here, just copy
echo "\nJust copying platform $PACKAGE_BASENAME for $1 sources..."
cp $PLATFORM_PACKAGES/$1/$PACKAGE_BASENAME $SOURCES/$1
elif [ -f $FLAVOUR_PACKAGES/$1/$PACKAGE_BASENAME ]; then
# flavour-specific file is already here, just copy
echo "\nJust copying flavour $PACKAGE_BASENAME for $1 sources..."
cp $FLAVOUR_PACKAGES/$1/$PACKAGE_BASENAME $SOURCES/$1
elif [ -f $PACKAGES/$PKG_SECTION/$1/$PACKAGE_BASENAME ]; then
# file is already here, just copy
echo "\nJust copying $PACKAGE_BASENAME for $1 sources..."
cp $PACKAGES/$PKG_SECTION/$1/$PACKAGE_BASENAME $SOURCES/$1
else
# have to download
# check for packages mirror usage
[ "$MIRROR" = yes ] && [ -n "$MIRROR_URL" ] \
&& i="$MIRROR_URL/$PACKAGE_BASENAME"
NBWGET=10
WGET_ARGS="-O $SOURCES/$1/$PACKAGE_BASENAME $i"
until wget $WGET_OPT $WGET_ARGS; do
NBWGET=$(($NBWGET-1))
if [ $NBWGET -eq 2 ]; then
if [ "$MIRROR" = yes ] && [ -n "$MIRROR_URL" ]; then
NBWGET=0
else
echo "\nCan't get $1 sources, trying on OpenBricks server..."
WGET_ARGS="-P $SOURCES/$1 $DISTRO_SRCS/$PACKAGE_BASENAME"
fi
fi
if [ $NBWGET -eq 0 ]; then
rm -f $SOURCES/$1/$PACKAGE_BASENAME
echo "\nCan't get $1 sources : $i\n Try later !!"
exit 1
fi
done
fi
do_md5sum "$SOURCES/$1/$PACKAGE_BASENAME"
do_sha256sum "$SOURCES/$1/$PACKAGE_BASENAME"
touch $STAMPS_NOARCH/$1/$PACKAGE_BASENAME.ok
done
fi
[ -f "$PACKAGE_URL" ] && \
cp -p $PACKAGE_URL $STAMP
[ -n "$PKG_URL" ] && \
echo $PKG_STAMP > $STAMP
rm -f $STAMPS/$1/unpack
rm -f $STAMPS/$1/build
fi