diff options
-rwxr-xr-x | fetch | 54 | ||||
-rwxr-xr-x | fetch_trees | 39 | ||||
-rwxr-xr-x | lbmk | 19 | ||||
-rwxr-xr-x | resources/scripts/handle/config/file | 2 |
4 files changed, 37 insertions, 77 deletions
@@ -15,25 +15,15 @@ depend="" main() { - if [ -z "${1+x}" ]; then - err 'Error: name not set' - fi - + [ -z "${1+x}" ] && err 'Error: name not set' name=${1} read_config verify_config clone_project + [ "${depend}" = "" ] || ./fetch ${depend} || exit 1 - # dependencies are downloaded *after* - # to account for cases like gnulib in grub where - # the dependency (gnulib) goes inside the main repo (grub) - if [ "${depend}" != "" ]; then - ./fetch ${depend} || exit 1 - fi - - # clean in case of failure rm -Rf ${tmp_dir} >/dev/null 2>&1 || exit 1 } @@ -44,20 +34,15 @@ read_config() set ${line} >/dev/null 2>&1 case ${line} in rev:*) - revision=${2} - ;; + revision=${2} ;; loc:*) - location=${2} - ;; + location=${2} ;; url:*) - url=${2} - ;; + url=${2} ;; bkup_url:*) - bkup_url=${2} - ;; + bkup_url=${2} ;; depend:*) - depend=${2} - ;; + depend=${2} ;; esac done << EOF $(eval "awk '${awkstr}' resources/git/revisions") @@ -66,32 +51,25 @@ EOF verify_config() { - if [ -z "${revision+x}" ]; then - err 'Error: revision not set' - elif [ -z "${location+x}" ]; then - err 'Error: location not set' - elif [ -z "${url+x}" ]; then - err 'Error: url not set' - fi + [ -z "${revision+x}" ] && err 'Error: revision not set' + [ -z "${location+x}" ] && err 'Error: location not set' + [ -z "${url+x}" ] && err 'Error: url not set' } clone_project() { tmp_dir=$(mktemp -dt "${name}_XXXXX") - git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} \ - || err "ERROR: could not download ${name}" - + git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} || \ + err "ERROR: could not download ${name}" ( cd ${tmp_dir} || err "tmpdir not created" git reset --hard ${revision} || err "Cannot reset revision" ) - patch_project - if [ -d "${location}" ]; then - rm -Rf ${location} || err "Cannot remove directory '${location}'" - fi + [ ! -d "${location}" ] || \ + rm -Rf ${location} || err "Can't remove directory '${location}'" mv ${tmp_dir} ${location} && return 0 printf "ERROR: Could not copy temp file to destination.\n" @@ -103,9 +81,7 @@ patch_project() patchdir="resources/${name}/patches" for patchfile in ${PWD}/${patchdir}/*.patch ; do - if [ ! -f "${patchfile}" ]; then - continue - fi + [ -f "${patchfile}" ] || continue ( cd ${tmp_dir} || err "tmpdir not created" git am ${patchfile} || err "Cannot patch project: $name" diff --git a/fetch_trees b/fetch_trees index 19112a2e..ed15739a 100755 --- a/fetch_trees +++ b/fetch_trees @@ -1,7 +1,7 @@ #!/usr/bin/env sh # helper script: create code trees based on git revision, with patches -# (currently used for downloading coreboot and u-boot) +# (currently used for downloading coreboot, seabios and u-boot) # # Copyright (C) 2014-2016,2020,2021,2023 Leah Rowe <info@minifree.org> # Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com> @@ -72,16 +72,14 @@ download_for_target() if [ -d "${project}/${tree}" ]; then printf "REMARK: download/%s %s: exists. Skipping.\n" \ - ${project} ${tree} - [ "${tree}" != "${1}" ] && \ - printf "(for target: '%s}')\n" ${1} + ${project} ${tree} + [ "${tree}" != "${_target}" ] && \ + printf "(for target: '%s}')\n" ${_target} return 0 fi fetch_from_upstream || exit 1 - - prepare_new_tree "${1}" "${tree}" "${rev}" \ - || exit 1 + prepare_new_tree "${_target}" "${tree}" "${rev}" || exit 1 } fetch_config() @@ -135,14 +133,11 @@ check_config_for_target() fetch_from_upstream() { - [ ! -d "${project}" ] && \ - mkdir -p "${project}" - [ ! -d "${project}" ] && \ - return 1 - [ -d "${project}/${project}" ] && \ - return 0 - ./fetch ${project} || \ - return 1 + [ -d "${project}" ] || mkdir -p "${project}" + [ -d "${project}" ] || return 1 + [ -d "${project}/${project}" ] && return 0 + + ./fetch ${project} || return 1 } prepare_new_tree() @@ -157,16 +152,14 @@ prepare_new_tree() cp -R "${project}/${project}" "${project}/${tree}" || exit 1 ( - cd "${project}/${tree}" \ - || err "cannot cd to ${project}/${tree}" - git reset --hard ${rev} \ - || err "cannot reset ${project} revision for tree, ${tree}" - git submodule update --init --checkout \ - || err "cannot update ${project} submodules for tree, ${tree}" + cd "${project}/${tree}" || err "cannot cd to ${project}/${tree}" + git reset --hard ${rev} || \ + err "cannot reset ${project} revision for tree, ${tree}" + git submodule update --init --checkout || \ + err "cannot update ${project} submodules for tree, ${tree}" for patch in ../../"${cfgsdir}"/"${tree}"/patches/*.patch; do - [ ! -f "${patch}" ] && \ - continue + [ ! -f "${patch}" ] && continue if ! git am "${patch}"; then git am --abort err "cannot patch ${tree}" @@ -31,23 +31,15 @@ option="" main() { - if [ "${0##*/}" = "lbmk" ]; then - die "Do not run the lbmk script directly!" - elif [ $# -lt 1 ]; then - die "Too few arguments. Try: ${0} help" - fi + [ "${0##*/}" = "lbmk" ] && die "Don't run this script directly." + [ $# -lt 1 ] && die "Too few arguments. Try: ${0} help" buildpath="./resources/scripts/${0##*/}" mode="${1}" ./.gitcheck - if [ "${mode}" = help ]; then - usage $0 - exit 0 - elif [ $# -lt 2 ]; then - usage $0 - exit 1 - fi + [ "${mode}" = "help" ] && usage ${0} && exit 0 + [ $# -lt 2 ] && usage ${0} && exit 1 if [ "${mode}" = "dependencies" ]; then install_dependencies $@ || die "Could not install dependencies" exit 0 @@ -61,8 +53,7 @@ main() case "${option}" in list) printf "Options for mode '%s':\n\n" ${mode} - listoptions "${mode}" - ;; + listoptions "${mode}" ;; all) for option in $(listoptions "${mode}"); do "${buildpath}/${mode}/${option}" $@ diff --git a/resources/scripts/handle/config/file b/resources/scripts/handle/config/file index bbd0ff0c..b8f9bea0 100755 --- a/resources/scripts/handle/config/file +++ b/resources/scripts/handle/config/file @@ -63,7 +63,7 @@ main() project="${OPTARG}" shift done - [ -z "${mode}" ] && err "mode not given (-m menuconfig or -u oldconfig)" + [ -z "${mode}" ] && err "mode not given (-m, -u or -b)" elfdir="elf/${project}" |