Skip to content

Commit ccb14e2

Browse files
JPeterMugaasAlexpux
authored andcommitted
Add two helper macros to the PKGBUILD templates. apply_patch_with_ms… (msys2#3846)
* Add two helper macros to the PKGBUILD templates. apply_patch_with_msg applies a patch ensuring a backup is made and with an output message showing the patch being applied to help with debugging. del_file_exists delets files and is meant for where a patch creates new files. Those added files may not be deleted if the PKGBUILD is reran causing patch to fail saying it's already been applied. Fix the setup-py template to use a _dtoken variable for part of the URL in pypi. Those use a download token for each software package and is unique to EVERY version. Also, use python${pver}-build-${CARCH} consistantly. The CARCH allows us to have for binary versions so that they could be examined if a build problem were to occur and speed up the build. * Fixed the comment about the source and made a point about downloading from some source such as github instead of pypi.
1 parent 6b196d8 commit ccb14e2

4 files changed

Lines changed: 91 additions & 8 deletions

File tree

mingw-w64-PKGBUILD-templates/PKGBUILD.CMake-github-git

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ sha256sums=('SKIP'
2222
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
2323
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
2424

25+
# Helper macros to help make tasks easier #
26+
apply_patch_with_msg() {
27+
for _patch in "$@"
28+
do
29+
msg2 "Applying $_patch"
30+
patch -Nbp1 -i "${srcdir}/$_patch"
31+
done
32+
}
33+
34+
del_file_exists() {
35+
for _fname in "$@"
36+
do
37+
if [ -f $_fname ]; then
38+
rm -rf $_fname
39+
fi
40+
done
41+
}
42+
# =========================================== #
43+
2544
pkgver() {
2645
cd "${srcdir}"/${_realname}
2746
printf "%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"

mingw-w64-PKGBUILD-templates/PKGBUILD.CMake-tarball

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,29 @@ sha256sums=('SKIP'
1919
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
2020
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
2121

22+
# Helper macros to help make tasks easier #
23+
apply_patch_with_msg() {
24+
for _patch in "$@"
25+
do
26+
msg2 "Applying $_patch"
27+
patch -Nbp1 -i "${srcdir}/$_patch"
28+
done
29+
}
30+
31+
del_file_exists() {
32+
for _fname in "$@"
33+
do
34+
if [ -f $_fname ]; then
35+
rm -rf $_fname
36+
fi
37+
done
38+
}
39+
# =========================================== #
2240

2341
prepare() {
2442
cd "${srcdir}"/${_realname}-${pkgver}
25-
patch -p1 -i ${srcdir}/0001-A-really-important-fix.patch
26-
patch -p1 -i ${srcdir}/0002-A-less-important-fix.patch
43+
apply_patch_with_msg 0001-A-really-important-fix.patch \
44+
0002-A-less-important-fix.patch
2745
}
2846

2947
build() {

mingw-w64-PKGBUILD-templates/PKGBUILD.autotools-tarball

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ source=("https://www.somepackage.org/${_realname}/${_realname}-${pkgver}.tar.gz"
1515
sha256sums=('SKIP'
1616
'SKIP')
1717

18+
# Helper macros to help make tasks easier #
19+
apply_patch_with_msg() {
20+
for _patch in "$@"
21+
do
22+
msg2 "Applying $_patch"
23+
patch -Nbp1 -i "${srcdir}/$_patch"
24+
done
25+
}
26+
27+
del_file_exists() {
28+
for _fname in "$@"
29+
do
30+
if [ -f $_fname ]; then
31+
rm -rf $_fname
32+
fi
33+
done
34+
}
35+
# =========================================== #
36+
1837
prepare() {
1938
cd ${srcdir}/${_realname}-${pkgver}
2039
patch -p1 -i ${srcdir}/0001-A-fix.patch

mingw-w64-PKGBUILD-templates/PKGBUILD.setup-py-python-pkg

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,45 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
1818
"${MINGW_PACKAGE_PREFIX}-python3-setuptools"
1919
"${MINGW_PACKAGE_PREFIX}-python2-setuptools")
2020
options=('staticlibs' 'strip' '!debug')
21-
source=("https://pypi.python.org/packages/source/P/${_realname}/${_realname}-${pkgver}.tar.gz")
21+
#Ideally, you should download the sources from github or some other place besides
22+
#pypi, but that ideal is not always possible.
23+
_dtoken='aa/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
24+
#Some Python packages software might use this instead
25+
#source=("https://pypi.python.org/packages/source/[first letter of the packages]/${_realname}/${_realname}-${pkgver}.tar.gz")
26+
@_dtoken would be the part of the URL between the /package and filename.
27+
# I did this to make it so you could just update the token to a new version instead of the complete
28+
# download URL.
29+
source=("https://pypi.python.org/packages/${_dtoken}/${_realname}-${pkgver}.tar.gz"
2230
"0001-An-important-fix.patch"
2331
"0002-A-less-important-fix.patch")
2432
sha256sums=('SKIP'
2533
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
2634
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
2735

36+
# Helper macros to help make tasks easier #
37+
apply_patch_with_msg() {
38+
for _patch in "$@"
39+
do
40+
msg2 "Applying $_patch"
41+
patch -Nbp1 -i "${srcdir}/$_patch"
42+
done
43+
}
44+
45+
del_file_exists() {
46+
for _fname in "$@"
47+
do
48+
if [ -f $_fname ]; then
49+
rm -rf $_fname
50+
fi
51+
done
52+
}
53+
# =========================================== #
54+
2855
prepare() {
2956
cd "${srcdir}"
30-
patch -p1 -i ${srcdir}/0001-A-really-important-fix.patch
31-
patch -p1 -i ${srcdir}/0002-A-less-important-fix.patch
32-
for builddir in python{2,3}-build; do
57+
apply_patch_with_msg 0001-A-really-important-fix.patch \
58+
0002-A-less-important-fix.patch
59+
for builddir in python{2,3}-build-${CARCH}; do
3360
rm -rf ${builddir} | true
3461
cp -r "${_realname}-${pkgver}" "${builddir}"
3562
done
@@ -50,15 +77,15 @@ build() {
5077
check() {
5178
for pver in {2,3}; do
5279
msg "Python ${pver} test for ${CARCH}"
53-
cd "${srcdir}/python${pver}-build"
80+
cd "${srcdir}/python${pver}-build-${CARCH}"
5481
${MINGW_PREFIX}/bin/python${pver} setup.py check
5582
done
5683
}
5784

5885
package_python3-somepackage() {
5986
depends=("${MINGW_PACKAGE_PREFIX}-python3")
6087

61-
cd "${srcdir}/python3-build"
88+
cd "${srcdir}/python3-build-${CARCH}"
6289
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
6390
${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
6491
--root="${pkgdir}" --optimize=1 --skip-build

0 commit comments

Comments
 (0)