Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
(conan-io#19031) openssh/9.1p1: Added openssh recipe
Browse files Browse the repository at this point in the history
* openssh: Added openssh recipe

* Update zlib dependency range

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>

* Empty commit for pipeline re-run

* openssh: Disbaled zlib version check during configure

* Simplify conditional patching & test package

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* openssh: Updated recipe according to PR discusion and suggestions

* openssh:: Fixed imports and indentation

* openssh: Fixed configure args

* openssh: removed support for old version 8.1p1

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* openssh: Added support for libressl

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Martin Valgur <martin.valgur@gmail.com>

* Update recipes/openssh/all/conanfile.py

Co-authored-by: Martin Valgur <martin.valgur@gmail.com>

* openssh: Updated with_pam default value

* Limited use of virtualrunenv in build scope. Applied suggestions

* Solved implicit function declarations errors

---------

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
Co-authored-by: Rubén Rincón <rubenrb@jfrog.com>
Co-authored-by: Jordan Williams <jordan@jwillikers.com>
Co-authored-by: Martin Valgur <martin.valgur@gmail.com>
Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com>
  • Loading branch information
6 people authored and ericLemanissier committed Apr 16, 2024
1 parent c84d179 commit 4684aad
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/openssh/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"9.6p1":
url: "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz"
sha256: "910211c07255a8c5ad654391b40ee59800710dd8119dd5362de09385aa7a777c"
"9.1p1":
url: "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.1p1.tar.gz"
sha256: "19f85009c7e3e23787f0236fbb1578392ab4d4bf9f8ec5fe6bc1cd7e8bfdd288"
132 changes: 132 additions & 0 deletions recipes/openssh/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from os.path import join

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rmdir, export_conandata_patches
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
from conan.tools.layout import basic_layout

required_conan_version = ">=1.54.0"


class PackageConan(ConanFile):
name = "openssh"
description = "The OpenSSH (portable) suite of secure connectivity tools"
license = "SSH-OpenSSH"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.openssh.com/portable.html"
topics = ("security", "cryptography", "login", "keychain", "file-sharing", "ssh")
package_type = "application"
settings = "os", "arch", "compiler", "build_type"
options = {
"with_libcrypto": [False, "libressl", "openssl"],
"with_pam": [False, "openpam"], # linux-pam and Solaris PAM are also supported
"with_selinux": [True, False],
"with_libedit": [True, False],
"with_sandbox": [False, "auto", "capsicum", "darwin", "rlimit", "seccomp_filter", "systrace", "pledge"]
}
default_options = {
"with_libcrypto": "openssl",
"with_pam": False,
"with_selinux": False,
"with_libedit": False,
"with_sandbox": "auto"
}

def package_id(self):
del self.info.settings.compiler
del self.info.settings.build_type

def export_sources(self):
export_conandata_patches(self)

def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("zlib/[>=1.2.11 <2]")
if self.options.with_libcrypto == "openssl":
self.requires("openssl/[>=1.1 <=3.1]")
elif self.options.with_libcrypto == "libressl":
self.requires("libressl/3.9.1")
if self.options.with_pam == "openpam":
self.requires("openpam/20190224")
if self.options.with_libedit:
self.requires("editline/3.1")

def validate(self):
if self.settings.os in ["baremetal", "Windows"]:
raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.settings.os}.")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()

ad = AutotoolsDeps(self)
ad.generate()

tc = AutotoolsToolchain(self)
tc.configure_args.append("--without-zlib-version-check")

if self.options.with_selinux:
tc.configure_args.append("--with-selinux")

if self.options.with_pam:
tc.configure_args.append("--with-pam")

if self.options.with_libedit:
editline = self.dependencies["editline"]
tc.configure_args.append("--with-libedit={}".format(editline.package_folder))

if self.options.with_libcrypto == "openssl":
openssl = self.dependencies["openssl"]
tc.configure_args.append("--with-ssl-dir={}".format(openssl.package_folder))
# It needs libcrypto.so in build time context
if openssl.options.shared:
env = VirtualRunEnv(self)
env.generate(scope="build")
elif self.options.with_libcrypto == "libressl":
libressl = self.dependencies["libressl"]
tc.configure_args.append("--with-ssl-dir={}".format(libressl.package_folder))
else:
tc.configure_args.append("--without-openssl")

if self.options.with_sandbox != 'auto':
tc.configure_args.append("--with-sandbox={}".format(self.options.with_sandbox or "no"))

tc.generate()

def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
autotools = Autotools(self)

install_target = 'install-nokeys' if cross_building(self) else 'install'
autotools.install(target=install_target)

copy(self, "LICENCE", src=self.source_folder, dst=join(self.package_folder, "licenses"), ignore_case=True)
copy(self, "*", src=join(self.package_folder, "libexec"), dst=join(self.package_folder, "bin"), ignore_case=True)

rmdir(self, join(self.package_folder, "etc"))
rmdir(self, join(self.package_folder, "var"))
rmdir(self, join(self.package_folder, "share"))
rmdir(self, join(self.package_folder, "libexec"))

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []

bindir = join(self.package_folder, "bin")
self.runenv_info.prepend_path("PATH", bindir)
18 changes: 18 additions & 0 deletions recipes/openssh/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conan import ConanFile
from conan.tools.build import can_run


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
pass

def test(self):
if can_run(self):
self.run("ssh -Q help", env="conanrun")
5 changes: 5 additions & 0 deletions recipes/openssh/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"9.6p1":
folder: all
"9.1p1":
folder: all

0 comments on commit 4684aad

Please sign in to comment.