summaryrefslogtreecommitdiff
path: root/script/update/project/repo
diff options
context:
space:
mode:
Diffstat (limited to 'script/update/project/repo')
-rwxr-xr-xscript/update/project/repo62
1 files changed, 16 insertions, 46 deletions
diff --git a/script/update/project/repo b/script/update/project/repo
index 7e65ef29..4695b52b 100755
--- a/script/update/project/repo
+++ b/script/update/project/repo
@@ -6,10 +6,11 @@
. "include/err.sh"
. "include/git.sh"
+. "include/option.sh"
name=""
-revision=""
-location=""
+rev=""
+loc=""
url=""
bkup_url=""
tmp_dir="${PWD}/tmp/gitclone"
@@ -22,7 +23,7 @@ main()
[ -z "${1+x}" ] && fail 'main(): name not set'
name=${1}
- read_config
+ scan_config "${name}" "config/git" "fail"
verify_config
clone_project
@@ -34,41 +35,10 @@ main()
rm -Rf "${tmp_dir}" || fail "cannot remove tmpdir, ${tmp_dir}"
}
-read_config()
-{
- revfile="$(mktemp -t gitrevisions.XXXXXXXXXX)" || \
- fail "read_config: Cannot initialise tmpfile"
-
- cat config/git/* > "${revfile}" || \
- fail "read_config: Cannot concatenate revision files"
-
- awkstr=" /\{.*${name}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }"
- while read -r line ; do
- set ${line} || fail "read_config: set line"
- case ${line} in
- rev:*)
- revision=${2} ;;
- loc:*)
- location=${2} ;;
- url:*)
- url=${2} ;;
- bkup_url:*)
- bkup_url=${2} ;;
- depend:*)
- depend="${depend} ${2} " ;;
- esac
- done << EOF
- $(eval "awk \"${awkstr}\" \"${revfile}\"")
-EOF
-
- rm -f "${revfile}" || \
- fail "read_config: can't remove tmp revfile"
-}
-
verify_config()
{
- [ -z "${revision+x}" ] && fail 'verify_config: revision not set'
- [ -z "${location+x}" ] && fail 'verify_config: location not set'
+ [ -z "${rev+x}" ] && fail 'verify_config: rev not set'
+ [ -z "${loc+x}" ] && fail 'verify_config: loc not set'
[ -z "${url+x}" ] && fail 'verify_config: url not set'
}
@@ -79,24 +49,24 @@ clone_project()
git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
fail "clone_project: could not download ${name}"
- git_reset_rev "${tmp_dir}" "${revision}" "fail" || \
- fail "clone_project ${location}/: cannot reset <- ${revision}"
+ git_reset_rev "${tmp_dir}" "${rev}" "fail" || \
+ fail "clone_project ${loc}/: cannot reset <- ${rev}"
git_am_patches "${tmp_dir}" "${PWD}/config/${name}/patches" "fail" || \
- fail "clone_project ${location}/: cannot apply patches"
+ fail "clone_project ${loc}/: cannot apply patches"
- [ ! -d "${location}" ] || \
- rm -Rf "${location}" || \
- fail "clone_project: Can't remove directory '${location}'"
- [ "${location}" = "${location%/*}" ] || mkdir -p ${location%/*} || \
+ [ ! -d "${loc}" ] || \
+ rm -Rf "${loc}" || \
+ fail "clone_project: Can't remove directory '${loc}'"
+ [ "${loc}" = "${loc%/*}" ] || mkdir -p ${loc%/*} || \
fail "clone_project: cannot make directory for ${name}"
- mv "${tmp_dir}" "${location}" || \
+ mv "${tmp_dir}" "${loc}" || \
fail "clone_project: could not copy temp file to destination"
}
fail()
{
- for x in "${location}" "${tmp_dir}"; do
- [ -z "${x}" ] || [ ! -d "${x}" ] || rm -Rf "${location}" || :
+ for x in "${loc}" "${tmp_dir}"; do
+ [ -z "${x}" ] || [ ! -d "${x}" ] || rm -Rf "${loc}" || :
done
usage
err "${1}"