Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/common-functions
blob: d6b4858ccd17cb39229222ef5d3a1fb7a28bc2e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

# contains functions used by more than one script

# find the PKGBUILD of a given package in a given repository
# TODO:
#  _properly_ include repository of package customizations

find_pkgbuild() {

  for prefix in "${repo_paths["packages"]}" "${repo_paths["community"]}"; do
    [ -d "${prefix}/$1" ] || continue
    ls "${prefix}/$1/repos/$2-"*"/PKGBUILD" 2> /dev/null && break
  done | \
    tr ' ' '\n' | \
    grep -v -- '-i686/PKGBUILD$' | \
    grep -v -- '-\(staging\|testing\)-[^/]\+/PKGBUILD$' | \
    sort | \
    tail -n1
}

find_repository_with_commit() {
  for repository in "${!repo_paths[@]}"; do
    if [ "$(git -C "${repo_paths["${repository}"]}" cat-file -t "$1" 2> /dev/null)" == "commit" ]; then
      echo "${repository}"
      return 0
    fi
  done
  >&2 echo "can't find repository with commit '$1'"
  exit 1
}