2016-09-19 22:18:45 +02:00
|
|
|
#!/usr/bin/bash
|
|
|
|
|
2017-06-02 18:20:04 +02:00
|
|
|
# Copies patches from QT_GIT_REPOS_DIR to default
|
2017-10-13 19:04:11 +02:00
|
|
|
# variant of specified repo and updates sources and checksums
|
2016-09-19 22:18:45 +02:00
|
|
|
|
2017-01-23 21:37:13 +01:00
|
|
|
#set -euxo pipefail
|
2016-09-19 22:18:45 +02:00
|
|
|
set -e # abort on first error
|
|
|
|
shopt -s nullglob
|
2018-09-19 20:39:07 +02:00
|
|
|
source /usr/share/makepkg/util/message.sh
|
|
|
|
colorize
|
2016-09-19 22:18:45 +02:00
|
|
|
|
2017-01-23 21:37:13 +01:00
|
|
|
if ! [[ $1 ]]; then
|
2017-06-02 18:20:04 +02:00
|
|
|
echo 'No Qt repo specified - must be specified like eg. base or multimedia.'
|
2018-03-17 17:08:22 +01:00
|
|
|
echo "Usage: $0 repo [branch=\$pkgver-\$variant] [variant=mingw-w64]"
|
2018-08-25 11:56:56 +02:00
|
|
|
echo "Note: DEFAULT_PKGBUILDS_DIR and QT_GIT_REPOS_DIR must point to directories containing PKGBUILDs and the Qt repos."
|
2017-01-23 21:37:13 +01:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2018-02-15 00:14:36 +01:00
|
|
|
pkgbuildsdirs=()
|
|
|
|
if [[ $DEFAULT_PKGBUILDS_DIR ]]; then
|
|
|
|
# split colon separated path
|
|
|
|
OIFS=$IFS
|
|
|
|
IFS=':'
|
|
|
|
for dir in $DEFAULT_PKGBUILDS_DIR; do
|
|
|
|
pkgbuildsdirs+=("$dir")
|
|
|
|
done
|
|
|
|
IFS=$OIFS
|
|
|
|
else
|
|
|
|
pkgbuildsdirs+=("$PWD/pkgbuilds")
|
|
|
|
fi
|
|
|
|
|
2017-01-23 21:37:13 +01:00
|
|
|
pkg="qt5-$1"
|
|
|
|
repo="qt$1"
|
2018-03-17 17:08:22 +01:00
|
|
|
branch="${2}"
|
|
|
|
variant="${3:-mingw-w64}"
|
2016-09-19 22:18:45 +02:00
|
|
|
|
2018-02-15 00:14:36 +01:00
|
|
|
# find dest dir
|
2018-12-08 22:06:32 +01:00
|
|
|
pkgdir=
|
2018-02-15 00:14:36 +01:00
|
|
|
for dir in "${pkgbuildsdirs[@]}"; do
|
2018-12-08 22:06:32 +01:00
|
|
|
for _pkgdir in "$pkg" "qt5"; do
|
|
|
|
dest="${dir}/${_pkgdir}/${variant}"
|
|
|
|
pkgdir=$_pkgdir
|
|
|
|
[[ -d $dest ]] && break 2 || dest=
|
|
|
|
done
|
2018-02-15 00:14:36 +01:00
|
|
|
done
|
|
|
|
if ! [[ $dest ]]; then
|
2018-12-08 22:06:32 +01:00
|
|
|
warning "\$DEFAULT_PKGBUILDS_DIR/$pkg/${variant} or \$DEFAULT_PKGBUILDS_DIR/qt5/${variant} is no directory - skipping repository $repo."
|
2018-09-19 20:39:07 +02:00
|
|
|
exit 0
|
2018-02-15 00:14:36 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# find repo dir
|
|
|
|
wd="${QT_GIT_REPOS_DIR}/${repo}"
|
2017-06-02 18:20:04 +02:00
|
|
|
if ! [[ -d $wd ]]; then
|
2018-09-19 20:39:07 +02:00
|
|
|
error "\$QT_GIT_REPOS_DIR/$repo is no directory."
|
2017-06-02 18:20:04 +02:00
|
|
|
exit -2
|
|
|
|
fi
|
|
|
|
|
2016-09-19 22:18:45 +02:00
|
|
|
source "$dest/PKGBUILD"
|
|
|
|
|
|
|
|
new_sources=()
|
|
|
|
new_md5sums=()
|
|
|
|
file_index=0
|
|
|
|
for source in "${source[@]}"; do
|
2017-10-13 19:04:11 +02:00
|
|
|
[ "${source: -6}" != .patch ] && \
|
|
|
|
new_sources+=("$source") \
|
|
|
|
new_md5sums+=("${sha256sums[$file_index]}")
|
|
|
|
file_index=$((file_index + 1))
|
2016-09-19 22:18:45 +02:00
|
|
|
done
|
|
|
|
|
2018-12-08 22:06:32 +01:00
|
|
|
if [[ $pkgdir != qt5 ]]; then
|
|
|
|
patches=("$dest"/*.patch)
|
|
|
|
for patch in "${patches[@]}"; do
|
|
|
|
[[ -f $patch ]] && rm "$patch"
|
|
|
|
done
|
|
|
|
fi
|
2016-09-19 22:18:45 +02:00
|
|
|
|
|
|
|
pushd "$wd" > /dev/null
|
2017-10-13 19:04:11 +02:00
|
|
|
git status # do some Git stuff just to check whether it is a Git repo
|
2018-03-17 17:08:22 +01:00
|
|
|
if ! [[ $branch ]]; then
|
|
|
|
branch="${pkgver}-${variant}"
|
|
|
|
fi
|
|
|
|
if ! git checkout "${branch}"; then
|
2018-09-19 20:39:07 +02:00
|
|
|
msg2 "No patches required for $1, skipping."
|
2017-10-13 19:04:11 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
2018-09-19 20:39:07 +02:00
|
|
|
git format-patch "origin/${pkgver}" --output-directory "$dest"
|
2016-09-19 22:18:45 +02:00
|
|
|
popd > /dev/null
|
|
|
|
|
2018-12-08 22:06:32 +01:00
|
|
|
[[ $pkgdir == qt5 ]] && exit 0
|
|
|
|
|
2016-09-19 22:18:45 +02:00
|
|
|
new_patches=("$dest"/*.patch)
|
|
|
|
for patch in "${new_patches[@]}"; do
|
2017-10-13 19:04:11 +02:00
|
|
|
new_sources+=("$patch")
|
|
|
|
sum=$(sha256sum "$patch")
|
|
|
|
new_md5sums+=(${sum%% *})
|
2016-09-19 22:18:45 +02:00
|
|
|
done
|
|
|
|
|
2017-10-13 19:04:11 +02:00
|
|
|
# preserve first src line to keep variables unevaluated
|
|
|
|
newsrc=$(grep 'source=(' "$dest/PKGBUILD")
|
|
|
|
[[ $newsrc ]] || newsrc="source=(${new_sources[0]}"
|
2017-12-08 19:49:53 +01:00
|
|
|
[ "${newsrc: -1:1}" == ')' ] && newsrc="${newsrc: 0:-1}" # truncate trailing )
|
2016-09-19 22:18:45 +02:00
|
|
|
for source in "${new_sources[@]:1}"; do
|
2017-10-13 19:04:11 +02:00
|
|
|
newsrc+="\n '${source##*/}'"
|
2016-09-19 22:18:45 +02:00
|
|
|
done
|
2017-10-13 19:04:11 +02:00
|
|
|
newsrc+=')'
|
2016-09-19 22:18:45 +02:00
|
|
|
|
2017-10-13 19:04:11 +02:00
|
|
|
newsums="sha256sums=('${new_md5sums[0]}'"
|
2016-09-19 22:18:45 +02:00
|
|
|
for sum in "${new_md5sums[@]:1}"; do
|
2017-10-13 19:04:11 +02:00
|
|
|
newsums+="\n '${sum}'"
|
2016-09-19 22:18:45 +02:00
|
|
|
done
|
2017-10-13 19:04:11 +02:00
|
|
|
newsums+=')'
|
|
|
|
|
|
|
|
# apply changes
|
|
|
|
mv "$dest/PKGBUILD" "$dest/PKGBUILD.bak"
|
|
|
|
awk -v newsrc="$newsrc" -v newsums="$newsums" '
|
|
|
|
/^[[:blank:]]*source(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ {
|
|
|
|
if (!s) {
|
|
|
|
print newsrc
|
|
|
|
s++
|
|
|
|
}
|
|
|
|
next
|
|
|
|
}
|
|
|
|
/^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ {
|
|
|
|
if (!w) {
|
|
|
|
print newsums
|
|
|
|
w++
|
|
|
|
}
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
1
|
|
|
|
END {
|
|
|
|
if (!s) {
|
|
|
|
print newsrc
|
|
|
|
}
|
|
|
|
if (!w) {
|
|
|
|
print newsums
|
|
|
|
}
|
|
|
|
}
|
|
|
|
' "$dest/PKGBUILD.bak" > "$dest/PKGBUILD"
|