Skip to content

Commit

Permalink
Update config.guess and config.sub
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Oct 25, 2023
1 parent e39fb4f commit ddd1dae
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions scripts/build-codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,35 @@
shutil.rmtree(d)


def fetch(url, path):
run(["curl", "-L", "-o", path, url])


def mangle_path(path):
if platform.system() == "Windows":
return (
path.replace(os.path.sep, "/").replace("C:", "/c").replace("D:", "/d")
)
return path.replace(os.path.sep, "/").replace("C:", "/c").replace("D:", "/d")
else:
return path


def build(package, configure_args=[]):
path = os.path.join(build_dir, package)
os.chdir(path)
package_path = os.path.join(build_dir, package)

# update config.guess and config.sub
config_files = ("config.guess", "config.sub")
for root, dirs, files in os.walk(package_path):
for name in filter(lambda x: x in config_files, files):
script_path = os.path.join(root, name)
cache_path = os.path.join(source_dir, name)
if not os.path.exists(cache_path):
fetch(
"https://git.savannah.gnu.org/cgit/config.git/plain/" + name,
cache_path,
)
shutil.copy(cache_path, script_path)
os.chmod(script_path, 0o755)

os.chdir(package_path)
run(["sh", "./configure"] + configure_args + ["--prefix=" + mangle_path(dest_dir)])
run(["make"])
run(["make", "install"])
Expand Down Expand Up @@ -72,7 +89,7 @@ def extract(package, url, *, strip_components=1):

# download tarball
if not os.path.exists(tarball):
run(["curl", "-L", "-o", tarball, url])
fetch(url, tarball)

# extract tarball
os.mkdir(path)
Expand Down

0 comments on commit ddd1dae

Please sign in to comment.