WIP #64: make gcc-armhf lazy-reproducible, properly compare symlinks

This commit is contained in:
Oliver Smith 2017-06-06 22:21:59 +02:00
parent 63ac1f5f6c
commit 31b276eeb9
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
5 changed files with 63 additions and 31 deletions

View File

@ -44,6 +44,7 @@ build() {
--enable-ld=default \
--enable-gold=yes \
--enable-plugins \
--enable-deterministic-archives \
--disable-multilib \
--disable-werror \
--disable-nls \

View File

@ -50,6 +50,7 @@ def generate(args, pkgname):
--enable-ld=default \\
--enable-gold=yes \\
--enable-plugins \\
--enable-deterministic-archives \\
--disable-multilib \\
--disable-werror \\
--disable-nls \\

View File

@ -18,6 +18,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import json
import logging
import pmb.chroot
import pmb.chroot.apk
import pmb.parse.apkindex
@ -35,8 +36,11 @@ def get_depends_recursively(args, pkgnames, arch=None):
pkgname = todo.pop(0)
index_data = pmb.parse.apkindex.read_any_index(args, pkgname, arch)
if not index_data:
raise RuntimeError("Could not find dependency " + pkgname +
" of packages " + str(pkgnames) + " in any APKINDEX")
logging.debug(
"NOTE: Could not find dependency " +
pkgname +
" in any APKINDEX.")
continue
pkgname = index_data["pkgname"]
if pkgname not in pkgnames and pkgname not in ret:
ret.append(pkgname)

View File

@ -27,6 +27,28 @@ import pmb.build
import pmb.parse.apkbuild
def diff_files(tar_a, tar_b, member_a, member_b, name):
# Extract both files
tars = [tar_a, tar_b]
members = [member_a, member_b]
temp_files = []
for i in range(2):
handle, path = tempfile.mkstemp("pmbootstrap")
handle = open(handle, "wb")
shutil.copyfileobj(tars[i].extractfile(members[i]), handle)
handle.close()
temp_files.append(path)
# Compare and delete
equal = filecmp.cmp(temp_files[0], temp_files[1], shallow=False)
for temp_file in temp_files:
os.remove(temp_file)
if equal:
logging.debug("=> File has the same content")
else:
raise RuntimeError("File '" + name + "' is different!")
def diff(args, apk_a, apk_b):
logging.info("Challenge " + apk_a)
with tarfile.open(apk_a, "r:gz") as tar_a:
@ -40,37 +62,41 @@ def diff(args, apk_a, apk_b):
"Both APKs do not contain the same file names!")
# Iterate through the list
success = True
for name in list_a:
logging.debug("Compare: " + name)
if name == ".PKGINFO" or name.startswith(".SIGN.RSA."):
logging.debug(
"=> Skipping, this is expected to be different")
continue
temp_files = []
# Extract
for tar in [tar_a, tar_b]:
member = tar.getmember(name)
if member.isdir():
try:
logging.debug("Compare: " + name)
if name == ".PKGINFO" or name.startswith(".SIGN.RSA."):
logging.debug(
"=> Skipping, this is expected to be different")
continue
handle, path = tempfile.mkstemp("pmbootstrap")
handle = open(handle, "wb")
shutil.copyfileobj(tar.extractfile(member), handle)
handle.close()
temp_files.append(path)
if not len(temp_files):
logging.debug("=> Skipping, this is a directory")
continue
# Compare and delete
equal = filecmp.cmp(
temp_files[0], temp_files[1], shallow=False)
for temp_file in temp_files:
os.remove(temp_file)
if equal:
logging.debug("=> Equal")
else:
raise RuntimeError("File '" + name + "' is different!")
# Get members
member_a = tar_a.getmember(name)
member_b = tar_b.getmember(name)
if member_a.type != member_b.type:
raise RuntimeError(
"Entry '" + name + "' has a different type!")
if member_a.isdir():
logging.debug("=> Skipping, this is directory")
elif member_a.isfile():
diff_files(tar_a, tar_b, member_a, member_b, name)
elif member_a.issym() or member_a.islnk():
if member_a.linkname == member_b.linkname:
logging.debug(
"=> Both link to " + member_a.linkname)
else:
raise RuntimeError(
"Link " + name + " has a different target!")
else:
raise RuntimeError(
"Can't diff '" + name + "', unsupported type!")
except Exception as e:
logging.info("CHALLENGE FAILED for " + name + ":" + str(e))
success = False
if not success:
raise RuntimeError("Challenge failed (see errors above)")
def challenge(args, apk_path):

View File

@ -35,7 +35,7 @@ def download(args, url, prefix, cache=True):
# Check if file exists in cache
prefix = prefix.replace("/", "_")
path = (args.work + "/cache_http/" + prefix + "_" +
hashlib.sha512(url.encode("utf-8")).hexdigest())
hashlib.sha256(url.encode("utf-8")).hexdigest())
if os.path.exists(path):
if cache:
return path