cozybit/distro11s — pull request #10 by jasonabele (2013-08-01 20:00:34+00:00)
Title: [PATCH] distro11s: make fetch/update readable

```
From 56056b828a27ab3ab3502e6ae1231f598e3bd3c4 Mon Sep 17 00:00:00 2001
From: Jason Abele
Date: Thu, 1 Aug 2013 12:43:30 -0700
Subject: [PATCH] distro11s: make fetch/update readable

parse_pkg already exports globals with useful names, use them to make
code in update and fetch functions more readable

Signed-off-by: Jason Abele
---
scripts/common.sh | 40 +++++++++++++++++++---------------------
scripts/fetch.sh | 4 ++--
2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/scripts/common.sh b/scripts/common.sh
index dc6e7155..c982e3f 100644
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -20,54 +20,52 @@ function set_top {
return 1
}

-# fetch ${VCS} ${NAME} ${URL} ${BRANCH} ${TAG}
-function fetch {
+function fetch_pkg {
DEST=${DISTRO11S_SRC}/${NAME}
-	if [ ${1} = "git" ]; then
+	if [ ${VCS} = "git" ]; then
GIT="git clone"
-	if [ "${DISTRO11S_GIT_REFERENCE}" != "" -a -e ${DISTRO11S_GIT_REFERENCE}/${2} ]; then
-	GIT="${GIT} --reference ${DISTRO11S_GIT_REFERENCE}/${2}"
+	if [ "${DISTRO11S_GIT_REFERENCE}" != "" -a -e ${DISTRO11S_GIT_REFERENCE}/${NAME} ]; then
+	GIT="${GIT} --reference ${DISTRO11S_GIT_REFERENCE}/${NAME}"
fi
echo "${GIT}"
-	if [ "${4}" = "" ]; then
-	${GIT} ${3} ${DEST}
+	if [ "${BRANCH}" = "" ]; then
+	${GIT} ${URL} ${DEST}
else
-	${GIT} ${3} -b ${4} ${DEST}
+	${GIT} ${URL} -b ${4} ${DEST}
fi
-	if [ "${5}" != "" ] ; then
+	if [ "${TAG}" != "" ] ; then
pushd .
cd ${DEST}
-	git reset --hard ${5}
+	git reset --hard ${TAG}
popd
fi
else
-	echo "Unsupported version control system ${1}"
+	echo "Unsupported version control system ${VCS}"
return 1
fi
}

-# update ${VCS} ${DIR} ${NAME} ${TAG}
-function update {
-	if [ ${1} = "git" ]; then
-	Q pushd ${2}
+function update_pkg {
+	if [ ${VCS} = "git" ]; then
+	Q pushd ${DIR}
CURR_HEAD=`git log --oneline -n1 | awk '{print $1}'`
-	[ "${4}" == "" ] && git pull --rebase
+	[ "${TAG}" == "" ] && git pull --rebase
NEW_HEAD=`git log --oneline -n1 | awk '{print $1}'`
else
-	echo "Unsupported version control system ${1}"
+	echo "Unsupported version control system ${VCS}"
return 1
fi

if [ "${CURR_HEAD}" != "${NEW_HEAD}" ]; then
# we had updates, clear the stamps, ignore missing
-	Q "rm ${TOP}/out/${DISTRO11S_BOARD}/stamps/${3}*" || continue
+	Q "rm ${TOP}/out/${DISTRO11S_BOARD}/stamps/${NAME}*" || continue
fi

-	if [ "${4}" != "" ]; then
+	if [ "${TAG}" != "" ]; then
Q pushd .
-	cd ${2}
+	cd ${DIR}
git fetch
-	git checkout -q ${4}
+	git checkout -q ${TAG}
Q popd
fi
}
diff --git a/scripts/fetch.sh b/scripts/fetch.sh
index 834c30e..05cd1d7 100755
--- a/scripts/fetch.sh
+++ b/scripts/fetch.sh
@@ -40,10 +40,10 @@ for p in `cat ${PKGLIST}`; do

if [ -e ${SRCDIR} ]; then
echo "UPDATING: ${SRCDIR}"
-	update ${VCS} ${SRCDIR} ${NAME} ${TAG} || exit 1
+	update_pkg || exit 1
else
echo "FETCHING: ${NAME}"
-	fetch ${VCS} ${NAME} ${URL} ${BRANCH} ${TAG} || exit 1
+	fetch_pkg || exit 1
if [ -d ${TOP}/patches/${NAME} ]; then
Q pushd ${SRCDIR}
git am ${TOP}/patches/${NAME}/* || exit 1
--
1.7.9.5

```