WIP #64: make gcc-armhf lazy-reproducible, properly compare symlinks
This commit is contained in:
parent
63ac1f5f6c
commit
31b276eeb9
|
@ -44,6 +44,7 @@ build() {
|
||||||
--enable-ld=default \
|
--enable-ld=default \
|
||||||
--enable-gold=yes \
|
--enable-gold=yes \
|
||||||
--enable-plugins \
|
--enable-plugins \
|
||||||
|
--enable-deterministic-archives \
|
||||||
--disable-multilib \
|
--disable-multilib \
|
||||||
--disable-werror \
|
--disable-werror \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
|
|
|
@ -50,6 +50,7 @@ def generate(args, pkgname):
|
||||||
--enable-ld=default \\
|
--enable-ld=default \\
|
||||||
--enable-gold=yes \\
|
--enable-gold=yes \\
|
||||||
--enable-plugins \\
|
--enable-plugins \\
|
||||||
|
--enable-deterministic-archives \\
|
||||||
--disable-multilib \\
|
--disable-multilib \\
|
||||||
--disable-werror \\
|
--disable-werror \\
|
||||||
--disable-nls \\
|
--disable-nls \\
|
||||||
|
|
|
@ -18,6 +18,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import pmb.chroot
|
import pmb.chroot
|
||||||
import pmb.chroot.apk
|
import pmb.chroot.apk
|
||||||
import pmb.parse.apkindex
|
import pmb.parse.apkindex
|
||||||
|
@ -35,8 +36,11 @@ def get_depends_recursively(args, pkgnames, arch=None):
|
||||||
pkgname = todo.pop(0)
|
pkgname = todo.pop(0)
|
||||||
index_data = pmb.parse.apkindex.read_any_index(args, pkgname, arch)
|
index_data = pmb.parse.apkindex.read_any_index(args, pkgname, arch)
|
||||||
if not index_data:
|
if not index_data:
|
||||||
raise RuntimeError("Could not find dependency " + pkgname +
|
logging.debug(
|
||||||
" of packages " + str(pkgnames) + " in any APKINDEX")
|
"NOTE: Could not find dependency " +
|
||||||
|
pkgname +
|
||||||
|
" in any APKINDEX.")
|
||||||
|
continue
|
||||||
pkgname = index_data["pkgname"]
|
pkgname = index_data["pkgname"]
|
||||||
if pkgname not in pkgnames and pkgname not in ret:
|
if pkgname not in pkgnames and pkgname not in ret:
|
||||||
ret.append(pkgname)
|
ret.append(pkgname)
|
||||||
|
|
|
@ -27,6 +27,28 @@ import pmb.build
|
||||||
import pmb.parse.apkbuild
|
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):
|
def diff(args, apk_a, apk_b):
|
||||||
logging.info("Challenge " + apk_a)
|
logging.info("Challenge " + apk_a)
|
||||||
with tarfile.open(apk_a, "r:gz") as tar_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!")
|
"Both APKs do not contain the same file names!")
|
||||||
|
|
||||||
# Iterate through the list
|
# Iterate through the list
|
||||||
|
success = True
|
||||||
for name in list_a:
|
for name in list_a:
|
||||||
logging.debug("Compare: " + name)
|
try:
|
||||||
if name == ".PKGINFO" or name.startswith(".SIGN.RSA."):
|
logging.debug("Compare: " + name)
|
||||||
logging.debug(
|
if name == ".PKGINFO" or name.startswith(".SIGN.RSA."):
|
||||||
"=> Skipping, this is expected to be different")
|
logging.debug(
|
||||||
continue
|
"=> Skipping, this is expected to be different")
|
||||||
temp_files = []
|
|
||||||
|
|
||||||
# Extract
|
|
||||||
for tar in [tar_a, tar_b]:
|
|
||||||
member = tar.getmember(name)
|
|
||||||
if member.isdir():
|
|
||||||
continue
|
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
|
# Get members
|
||||||
equal = filecmp.cmp(
|
member_a = tar_a.getmember(name)
|
||||||
temp_files[0], temp_files[1], shallow=False)
|
member_b = tar_b.getmember(name)
|
||||||
for temp_file in temp_files:
|
if member_a.type != member_b.type:
|
||||||
os.remove(temp_file)
|
raise RuntimeError(
|
||||||
if equal:
|
"Entry '" + name + "' has a different type!")
|
||||||
logging.debug("=> Equal")
|
|
||||||
else:
|
if member_a.isdir():
|
||||||
raise RuntimeError("File '" + name + "' is different!")
|
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):
|
def challenge(args, apk_path):
|
||||||
|
|
|
@ -35,7 +35,7 @@ def download(args, url, prefix, cache=True):
|
||||||
# Check if file exists in cache
|
# Check if file exists in cache
|
||||||
prefix = prefix.replace("/", "_")
|
prefix = prefix.replace("/", "_")
|
||||||
path = (args.work + "/cache_http/" + prefix + "_" +
|
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 os.path.exists(path):
|
||||||
if cache:
|
if cache:
|
||||||
return path
|
return path
|
||||||
|
|
Loading…
Reference in New Issue