OSDN Git Service

[update] : alterlinux-live-tools v1.3
[alterlinux/alterlinux-pkgbuilds.git] / update_pkgbuilds.sh
1 #!/usr/bin/env bash
2
3 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && pwd )"
4
5 set -eu
6
7 for DIR in $(find "${script_path}" -type f -name "PKGBUILD" | xargs realpath | xargs dirname); do
8     PACKAGE="$(basename "${DIR}")"
9
10     if [[ "${PACKAGE}" = "filesystem" ]]; then
11         continue
12     fi
13
14     if [[ ! "$(curl -sL "https://www.archlinux.org/packages/search/json/?name=${PACKAGE}" | jq .results)" = "[]" ]]; then
15         mkdir -p "${DIR}"
16         (
17             cd "${DIR}/../"
18             rm -rf "${PACKAGE}"
19             asp export "${PACKAGE}"
20         )
21     else
22         mkdir -p "${script_path}/temp/${PACKAGE}"
23         git clone "https://aur.archlinux.org/${PACKAGE}.git" "${script_path}/temp/${PACKAGE}"
24         if [[ -n "$(ls "${script_path}/temp/${PACKAGE}")" ]]; then
25             rm -rf "${DIR}"
26             mv "${script_path}/temp/${PACKAGE}" "${DIR}"
27             rm -rf "${DIR}/.git"
28         fi
29     fi
30 done