Skip to content

Commit

Permalink
Merge pull request #507 from serokell/rvem/chore-avoid-switch-package…
Browse files Browse the repository at this point in the history
…s-installation-in-native-packages

[Chore] Fix 'build-binary.sh' script
  • Loading branch information
rvem authored Jul 27, 2022
2 parents bce1e40 + bcb77b2 commit bf1cd83
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker/package/Dockerfile-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ ENV OPAMROOT "/tezos-packaging/docker/opamroot"
COPY docker/package/*.py /tezos-packaging/docker/package/
COPY docker/package/defaults /tezos-packaging/docker/package/defaults
COPY docker/package/scripts /tezos-packaging/docker/package/scripts
COPY docker/package/patches /tezos-packaging/docker/package/patches
COPY LICENSE /tezos-packaging/LICENSE
ENTRYPOINT ["python3", "-m", "package.package_generator"]
4 changes: 4 additions & 0 deletions docker/package/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def __init__(
postinst_steps: str = "",
postrm_steps: str = "",
additional_native_deps: List[str] = [],
patches: List[str] = [],
):
self.name = name
self.desc = desc
Expand All @@ -216,6 +217,7 @@ def __init__(
self.additional_native_deps = additional_native_deps
self.meta = meta
self.dune_filepath = dune_filepath
self.patches = patches

def __get_os_specific_native_deps(self, os_name):
return [
Expand Down Expand Up @@ -409,6 +411,7 @@ def __init__(self, meta: PackagesMeta, params_revision: str):
self.targetProto = None
self.meta = meta
self.params_revision = params_revision
self.patches = []

def fetch_sources(self, out_dir, binaries_dir=None):
os.makedirs(out_dir)
Expand Down Expand Up @@ -563,6 +566,7 @@ def __init__(
self.meta = deepcopy(meta)
self.meta.version = self.meta.version + self.letter_version
self.target_protos = set()
self.patches = []
for network in target_networks:
for proto in network_protos[network]:
self.target_protos.add(proto)
Expand Down
15 changes: 15 additions & 0 deletions docker/package/packages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2021 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA
import os, json
from unittest.mock import patch

from .meta import packages_meta

Expand Down Expand Up @@ -132,12 +133,16 @@
additional_native_deps=["tezos-sapling-params", "udev"],
postinst_steps=ledger_udev_postinst,
dune_filepath="src/bin_client/main_client.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
),
TezosBinaryPackage(
"tezos-admin-client",
"Administration tool for the node",
meta=packages_meta,
dune_filepath="src/bin_client/main_admin.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
),
TezosBinaryPackage(
"tezos-signer",
Expand All @@ -147,12 +152,16 @@
systemd_units=signer_units,
postinst_steps=ledger_udev_postinst,
dune_filepath="src/bin_signer/main_signer.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
),
TezosBinaryPackage(
"tezos-codec",
"A client to decode and encode JSON",
meta=packages_meta,
dune_filepath="src/bin_codec/codec.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
),
]

Expand Down Expand Up @@ -256,6 +265,8 @@ def mk_node_unit(
postrm_steps=node_postrm_steps,
additional_native_deps=["tezos-sapling-params", {"ubuntu": "netbase"}],
dune_filepath="src/bin_node/main.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
)
)

Expand Down Expand Up @@ -385,6 +396,8 @@ def mk_node_unit(
"udev",
],
dune_filepath=f"src/proto_{proto_snake_case}/bin_baker/main_baker_{proto_snake_case}.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
)
)
packages.append(
Expand All @@ -410,6 +423,8 @@ def mk_node_unit(
additional_native_deps=["udev"],
postinst_steps=daemon_postinst_common + ledger_udev_postinst,
dune_filepath=f"src/proto_{proto_snake_case}/bin_accuser/main_accuser_{proto_snake_case}.exe",
# TODO: remove on the next upstream release
patches=["build-binary.sh.patch"],
)
)

Expand Down
18 changes: 18 additions & 0 deletions docker/package/patches/build-binary.sh.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --color -Nru tezos-client-14.0-rc1.orig/build-binary.sh tezos-client-14.0-rc1/build-binary.sh
--- tezos-client-14.0-rc1.orig/build-binary.sh 2022-07-22 17:37:24.000000000 +0300
+++ tezos-client-14.0-rc1/build-binary.sh 2022-07-27 12:01:58.842885979 +0300
@@ -13,12 +13,12 @@

cd tezos
opam init local ../opam-repository --bare --disable-sandboxing
-opam switch create . --repositories=local
+opam switch create . --repositories=local --no-install
eval "$(opam env)"
opams=()
while IFS= read -r -d $'\0'; do
opams+=("$REPLY")
-done < <(find ./vendors ./src ./tezt -name \*.opam -print0)
+done < <(find ./vendors ./src ./tezt ./opam -name \*.opam -print0)
opam install "${opams[@]}" --deps-only --criteria="-notuptodate,-changed,-removed"
eval "$(opam env)"
dune build "$dune_filepath"
2 changes: 2 additions & 0 deletions docker/package/patches/build-binary.sh.patch.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: 2022 Oxhead Alpha
SPDX-License-Identifier: LicenseRef-MIT-OA
4 changes: 2 additions & 2 deletions docker/package/scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ binary_name="$2"

cd tezos
opam init local ../opam-repository --bare --disable-sandboxing
opam switch create . --repositories=local
opam switch create . --repositories=local --no-install
eval "$(opam env)"
opams=()
while IFS= read -r -d $'\0'; do
opams+=("$REPLY")
done < <(find ./vendors ./src ./tezt -name \*.opam -print0)
done < <(find ./vendors ./src ./tezt ./opam -name \*.opam -print0)
opam install "${opams[@]}" --deps-only --criteria="-notuptodate,-changed,-removed"
eval "$(opam env)"
dune build "$dune_filepath"
Expand Down
11 changes: 11 additions & 0 deletions docker/package/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ def build_ubuntu_package(
)
source_path = f"{cwd}/scripts/{source_script_name}"
shutil.copy(source_path, dest_path)
# Patches only make sense when we're reusing the old sources that are not static binary
if (
len(pkg.patches) > 0
and source_archive_path is not None
and binaries_dir is None
):
os.makedirs("debian/patches")
with open("debian/patches/series", "w") as f:
for patch in pkg.patches:
shutil.copy(f"{cwd}/patches/{patch}", f"debian/patches/{patch}")
f.write(patch)
with open("debian/compat", "w") as f:
f.write("10")
pkg.gen_install("debian/install")
Expand Down
2 changes: 1 addition & 1 deletion meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"release": "1",
"release": "2",
"maintainer": "Serokell <[email protected]>",
"tezos_ref": "refs/tags/v14.0-rc1"
}

0 comments on commit bf1cd83

Please sign in to comment.