diff options
Diffstat (limited to 'include/lib.sh')
-rw-r--r-- | include/lib.sh | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/include/lib.sh b/include/lib.sh index c0adc7a6..cf4305a1 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -29,63 +29,6 @@ mktarball() x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || err "mktarball2, $1" } -mksha512sum() -{ - ( - [ "${1%/*}" != "$1" ] && x_ cd "${1%/*}" - sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\"" - ) || err "failed to create tarball checksum" -} - -rmgit() -{ - fx_ "x_ rm -Rf" x_ find "$1" -name ".git" - fx_ "x_ rm -Rf" x_ find "$1" -name ".gitmodules" -} - -# can grab from the internet, or copy locally. -# if copying locally, it can only copy a file. -xbmkget() -{ - _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" - - _dlop="curl" && [ $# -gt 4 ] && _dlop="$5" - x_ mkdir -p "${3%/*}" "$XBMK_CACHE/file" - for url in "$1" "$2"; do - [ -n "$url" ] && try_file "$url" "$_dlop" "$@" && return 0 - done && err "$1 $2 $3 $4: not downloaded"; : -} - -try_file() -{ - cached="$XBMK_CACHE/file/$6" - dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum - bad_checksum "$6" "$cached" 2>/dev/null && dl_fail="y" - [ "$dl_fail" = "n" ] && e "$5" f && return 0 - - x_ rm -f "$cached" - if [ "$2" = "curl" ]; then - curl --location --retry 3 -A "$_ua" "$1" -o "$cached" || \ - wget --tries 3 -U "$_ua" "$1" -O "$cached" || return 1 - elif [ "$2" = "copy" ]; then - [ -L "$1" ] && printf "dl %s %s %s %s: '%s' is a symlink\n" \ - "$3" "$4" "$5" "$6" "$1" 1>&2 && return 1 - [ ! -f "$1" ] && printf "dl %s %s %s %s: '%s' not a file\n" \ - "$3" "$4" "$5" "$6" "$1" 1>&2 && return 1 - cp "$1" "$cached" || return 1 - else - err "$3 $4 $5 $6: Unsupported dlop type: '$2'" - fi - bad_checksum "$6" "$cached" && return 1 - [ "$cached" = "$5" ] || x_ cp "$cached" "$5"; : -} - -bad_checksum() -{ - [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1 - printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; : -} - e() { es_t="e" && [ $# -gt 1 ] && es_t="$2" @@ -97,14 +40,6 @@ e() printf "%s %s\n" "$1" "$es2" 1>&2 } -mk() -{ - mk_flag="$1" || err "No argument given" - shift 1 && for mk_arg in "$@"; do - x_ ./mk $mk_flag $mk_arg - done; : -} - setvars() { _setvars="" |