summaryrefslogtreecommitdiff
path: root/bin/build-and-deploy-bootstrap-package
blob: 5560d1ee54c6adcc125a301314b2d94f8a1970ad (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/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-i486-build'
#parameters='-- -- --nocheck'

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}" "2"

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

cd "${tmp_dir}"

makepkg  --skippgpcheck --verifysource

"${build_command}" ${parameters}

find . -maxdepth 1 -type f -name '*.pkg.tar.xz' \
  -execdir gpg --local-user="${package_key}" --detach-sign '{}' \;

case "$repository" in
	core|extra)
		staging_repo="staging"
		;;
	community)
		staging_repo="community-staging"
		;;
	*)
		staging_repo="staging"
		;;
esac

#scp -P 2223 -rC "${tmp_dir}/"*.pkg.tar.{xz,xz.sig} httpupload@andreasbaumann.cc:/data/arch32/mirror/bootstrap/i486/${staging_repo}/.
#ssh -p 2223 httpupload@andreasbaumann.cc bash -l -c "'cd /data/arch32/mirror/bootstrap/i486/${staging_repo} && repo-add -n bootstrap-${staging_repo}.db.tar.gz *.pkg.tar.xz'"

#scp -P 2227 -rC "${tmp_dir}/"*.pkg.tar.{xz,xz.sig} httpupload@andreasbaumann.cc:/data/arch32/mirror/bootstrap/i486/${staging_repo}/.
#ssh -p 2227 httpupload@andreasbaumann.cc bash -l -c "'cd /data/arch32/mirror/bootstrap/i486/${staging_repo} && repo-add -n bootstrap-${staging_repo}.db.tar.gz *.pkg.tar.xz'"

#recursively_umount_and_rm "${tmp_dir}"