mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-13 11:29:46 +03:00
libstdc++.a from gcc-armhf was not reproducible on Travis (it was, when built locally!). These .a files are just archives of object files .o, and in this case it was caused by a random order of the .o files in the archive. This PR patches the package() function of the APKBUILD when running pmbootstrap aportgen gcc-armhf (same for aarch64 of course), to extract all .a files, and repack them to be reproducible (by sorting the files before packing them). As usually, we can still inherit everything from the upstream gcc aport from Alpine, and apply our changes on top of that. Travis without the patch: https://api.travis-ci.org/jobs/260402679/log.txt?deansi=true > CHALLENGE FAILED for usr/armv6-alpine-linux-muslgnueabihf/lib/libstdc++.a:File 'usr/armv6-alpine-linux-muslgnueabihf/lib/libstdc++.a' is different! Travis with the patch (I've instructed Travis to run off this branch to test it): https://api.travis-ci.org/jobs/260806203/log.txt?deansi=true > Done. Your build exited with 0.
95 lines
3.3 KiB
Python
95 lines
3.3 KiB
Python
"""
|
|
Copyright 2017 Oliver Smith
|
|
|
|
This file is part of pmbootstrap.
|
|
|
|
pmbootstrap is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
pmbootstrap is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
import pmb.helpers.run
|
|
import pmb.aportgen.core
|
|
|
|
|
|
def generate(args, pkgname):
|
|
# Copy original aport
|
|
arch = pkgname.split("-")[1]
|
|
path_original = "main/gcc"
|
|
upstream = (args.work + "/cache_git/aports_upstream/" + path_original)
|
|
pmb.helpers.run.user(args, ["cp", "-r", upstream, args.work + "/aportgen"])
|
|
|
|
# Rewrite APKBUILD
|
|
fields = {
|
|
"pkgname": pkgname,
|
|
"pkgdesc": "Stage2 cross-compiler for " + arch,
|
|
"depends": "isl binutils-" + arch,
|
|
"makedepends_build": "gcc g++ paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev",
|
|
"makedepends_host": "linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev musl-dev-" + arch + " binutils-" + arch,
|
|
"subpackages": "g++-" + arch + ":gpp",
|
|
|
|
"LIBGOMP": "false",
|
|
"LIBGCC": "false",
|
|
"LIBATOMIC": "false",
|
|
"LIBITM": "false",
|
|
}
|
|
|
|
below_header = "CTARGET_ARCH=" + arch + """
|
|
CTARGET="$(arch_to_hostspec ${CTARGET_ARCH})"
|
|
CBUILDROOT="/usr/$CTARGET"
|
|
LANG_OBJC=false
|
|
LANG_JAVA=false
|
|
LANG_GO=false
|
|
LANG_FORTRAN=false
|
|
LANG_ADA=false
|
|
options="!strip !tracedeps"
|
|
"""
|
|
|
|
replace_simple = {
|
|
# Do not package libstdc++, do not add "g++-$ARCH" here (already
|
|
# did that explicitly in the subpackages variable above, so
|
|
# pmbootstrap picks it up properly).
|
|
'*subpackages="$subpackages libstdc++:libcxx:*': None,
|
|
|
|
# libstdc++.a is not reproducible by default (.a files are archives of
|
|
# object files, and these object files are inside the .a file in a random
|
|
# order!). The best way would be to patch this upstream in gcc, but for now
|
|
# we repackage the .a files to make sure, that they are reproducible.
|
|
'*package() {*': """package() {
|
|
# Repack the *.a files to be reproducible (see #64)
|
|
_temp="$_builddir"/_reproducible-patch
|
|
cd "$_builddir"
|
|
for f in $(find -name '*.a'); do
|
|
# Copy to a temporary folder
|
|
echo "Repack $f to be reproducible"
|
|
mkdir -p "$_temp"
|
|
cd "$_temp"
|
|
cp "$_builddir"/"$f" .
|
|
|
|
# Repack with a sorted file order
|
|
ar x *.a
|
|
rm *.a
|
|
ar r sorted.a $(find -name '*.o' | sort)
|
|
|
|
# Copy back and clean up
|
|
cp -v sorted.a "$_builddir"/"$f"
|
|
cd ..
|
|
rm -r "$_temp"
|
|
done"""
|
|
}
|
|
|
|
pmb.aportgen.core.rewrite(
|
|
args,
|
|
pkgname,
|
|
path_original,
|
|
fields,
|
|
replace_simple=replace_simple,
|
|
below_header=below_header)
|