Skip to content
Snippets Groups Projects
Commit a6987b3d authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch 'feature/jorgen.lind/stat' into 'master'

Don't use lstat but stat for File::Exists on posix

See merge request !465
parents 2f50e173 f2fdec22
No related branches found
No related tags found
No related merge requests found
Pipeline #64837 passed
......@@ -139,6 +139,33 @@ for python_executable in "${python_executables[@]}"; do
old_dir=$PWD
cd $openvds_path/dist
LD_LIBRARY_PATH=$skbuild_dir/cmake-install/lib${libdir_suffix} auditwheel repair *.whl
manylinux_wheels=( $PWD/wheelhouse/*manylinux*.whl )
the_wheel=${manylinux_wheels[0]}
rm -rf tmp
mkdir tmp
cd tmp
unzip $the_wheel
data_dirs=( $PWD/*.data )
the_datadir=${data_dirs[0]}
cd $the_datadir/data
mkdir lib_new
cp ../../openvds.libs/* lib_new/
cd lib_new
the_openvds_lib_pattern=( libopenvds* )
the_openvds_lib=${the_openvds_lib_pattern[0]}
for ovds_link in ../lib${libdir_suffix}/libopenvds.so*; do
ln -s $the_openvds_lib $(basename $ovds_link)
done
cp -av ../lib${libdir_suffix}/libopenvds-java* .
cp -av ../lib${libdir_suffix}/libsegy* .
patchelf --set-rpath '$ORIGIN' *
cd ..
rm -rf lib${libdir_suffix}
mv lib_new lib${libdir_suffix}
cd $openvds_path/dist
rm $the_wheel
$base_dir/repair_wheel_extra tmp $the_wheel
cp wheelhouse/*manylinux* $openvds_path/binpackage/$name-$openvds_version/
mv wheelhouse/*manylinux* $openvds_path/binpackage/python/$distribution/
cd $old_dir
......
#!/opt/_internal/pipx/venvs/auditwheel/bin/python
# -*- coding: utf-8 -*-
import zipfile
import os
from os.path import (join as pjoin, abspath, relpath, exists, sep as psep,
splitext, dirname, basename)
import glob
import hashlib
import csv
from typing import Generator, Iterable, List, Optional, Type
from base64 import urlsafe_b64encode
import sys
####all of this code is borrowed from auditwheel
def _dist_info_dir(bdist_dir: str) -> str:
"""Get the .dist-info directory from an unpacked wheel
Parameters
----------
bdist_dir : str
Path of unpacked wheel file
"""
info_dirs = glob.glob(pjoin(bdist_dir, '*.dist-info'))
if len(info_dirs) != 1:
raise WheelToolsError("Should be exactly one `*.dist_info` directory")
return info_dirs[0]
def rewrite_record(bdist_dir: str) -> None:
""" Rewrite RECORD file with hashes for all files in `wheel_sdir`
Copied from :method:`wheel.bdist_wheel.bdist_wheel.write_record`
Will also unsign wheel
Parameters
----------
bdist_dir : str
Path of unpacked wheel file
"""
info_dir = _dist_info_dir(bdist_dir)
record_path = pjoin(info_dir, 'RECORD')
record_relpath = relpath(record_path, bdist_dir)
# Unsign wheel - because we're invalidating the record hash
sig_path = pjoin(info_dir, 'RECORD.jws')
if exists(sig_path):
os.unlink(sig_path)
def walk() -> Generator[str, None, None]:
for dir, dirs, files in os.walk(bdist_dir):
for f in files:
yield pjoin(dir, f)
def skip(path: str) -> bool:
"""Wheel hashes every possible file."""
return path == record_relpath
with open(record_path, 'w+', newline='', encoding='utf-8') as record_file:
writer = csv.writer(record_file)
for path in walk():
relative_path = relpath(path, bdist_dir)
if skip(relative_path):
hash_ = ''
size = ''
else:
with open(path, 'rb') as f:
data = f.read()
digest = hashlib.sha256(data).digest()
sha256 = urlsafe_b64encode(digest).rstrip(b'=').decode('ascii')
hash_ = f'sha256={sha256}'
size = f'{len(data)}'
record_path = relpath(path, bdist_dir).replace(psep, '/')
writer.writerow((record_path, hash_, size))
def dir2zip(in_dir: str, zip_fname: str) -> None:
""" Make a zip file `zip_fname` with contents of directory `in_dir`
The recorded filenames are relative to `in_dir`, so doing a standard zip
unpack of the resulting `zip_fname` in an empty directory will result in
the original directory contents.
Parameters
----------
in_dir : str
Directory path containing files to go in the zip archive
zip_fname : str
Filename of zip archive to write
"""
with zipfile.ZipFile(zip_fname, 'w',
compression=zipfile.ZIP_DEFLATED) as z:
for root, dirs, files in os.walk(in_dir):
for file in files:
fname = os.path.join(root, file)
out_fname = os.path.relpath(fname, in_dir)
z.write(os.path.join(root, file), out_fname)
if len(sys.argv) != 3:
print("Usage: {} [bdist_dir] [output_name.whl]".format(sys.argv[0]))
exit(1)
rewrite_record(sys.argv[1])
dir2zip(sys.argv[1], sys.argv[2])
......@@ -182,7 +182,7 @@ public:
bool File::Exists(const std::string& filename)
{
struct stat buf;
return (lstat(filename.c_str(), &buf) == 0) && S_ISREG(buf.st_mode);
return (stat(filename.c_str(), &buf) == 0) && S_ISREG(buf.st_mode);
}
bool File::Open(const std::string& filename, bool isCreate, bool isDestroyExisting, bool isWriteAccess, Error &error)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment