summaryrefslogtreecommitdiff
path: root/bin/local-build-package
blob: 1c43bc9eac2c4c8a231e1684c88deb1da7bc9095 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

# build one package to test if modifications are ok (before opening a pull
# request in https://github.com/archlinux32/packages)
# package is built directly on a i486/i586/i686 host without any chroots

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

usage() {
  >&2 echo ''
  >&2 echo 'test-build-package <repository> <package>: build package for testing'
  >&2 echo ''
  >&2 echo 'possible options:'
  >&2 echo '  -h|--help:   Show this help and exit.'
  [ -z "$1" ] && exit 1 || exit $1
}

eval set -- "$(
  getopt -o hn:t:x \
    --long help \
    -n "$(basename "$0")" -- "$@" || \
  echo usage
)"

while true
do
  case "$1" in
    -h|--help)
      usage 0
    ;;
    --)
      shift
      break
    ;;
    *)
      >&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
      exit 42
    ;;
  esac
  shift
done

if [ $# -ne 2 ]; then
  >&2 echo 'Too few or too many arguments. Expecting exactly a repository and a package name of the package to test.'
  usage
fi

# Update git repositories (official packages, community packages and the repository of package customizations).

for repo_name in ${repo_names}; do
  eval repo_path='"${repo_paths__'"${repo_name}"'}"'
  git -C "${repo_path}" pull
done

repository=$1
package=$2
case $repository in
	core)
		repo_path='../work/repos/packages'
		;;
	extra)
		repo_path='../work/repos/packages'
		;;
	community)
		repo_path='../work/repos/community'
		;;
	*)
		>&2 echo 'Repository is either "core" or "community"'
		usage
esac
git_revision=$(cd ${repo_path}; git rev-parse HEAD)

mod_git_revision=$(cd ${repo_paths__archlinux32}; git stash create)
if [ -z $mod_git_revision ]; then
	mod_git_revision=$(cd ${repo_paths__archlinux32}; git rev-parse HEAD)
fi
build_command='staging-i686-build'
parameters=''

git_repo=$(find_repository_with_commit "${git_revision}")
find_pkgbuilds "${package}" "${repository}" "${git_repo}" "${git_revision}" "${mod_git_revision}"
tmp_dir=$(mktemp -d "${work_dir}/tmp.XXXXXX")

extract_source_directory "${git_repo}" "${git_revision}" "${mod_git_revision}" "${tmp_dir}"

rm -f *".pkg.tar.xz" *".pkg.tar.xz.sig"

cd "${tmp_dir}"

makepkg  --skippgpcheck --verifysource

"${build_command}" ${parameters}

#recursively_umount_and_rm "${tmp_dir}"