Add containers-common spec and command to podman

Since containers-common package is tied to specific versions
of Podman, add tools to build the package into the contrib directory
This should help other distributions to figure out which commont
package to ship.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2022-02-17 13:46:51 -05:00
parent d3903a8591
commit 80c5962dba
113 changed files with 3629 additions and 1317 deletions

View File

@ -3,12 +3,14 @@ package config
import (
"bytes"
"fmt"
"net"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
nettypes "github.com/containers/common/libnetwork/types"
"github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/cgroupv2"
"github.com/containers/common/pkg/util"
@ -85,8 +87,26 @@ var (
"/usr/lib/cni",
"/opt/cni/bin",
}
DefaultSubnetPools = []SubnetPool{
// 10.89.0.0/24-10.255.255.0/24
parseSubnetPool("10.89.0.0/16", 24),
parseSubnetPool("10.90.0.0/15", 24),
parseSubnetPool("10.92.0.0/14", 24),
parseSubnetPool("10.96.0.0/11", 24),
parseSubnetPool("10.128.0.0/9", 24),
}
)
// nolint:unparam
func parseSubnetPool(subnet string, size int) SubnetPool {
_, n, _ := net.ParseCIDR(subnet)
return SubnetPool{
Base: &nettypes.IPNet{IPNet: *n},
Size: size,
}
}
const (
// _etcDir is the sysconfdir where podman should look for system config files.
// It can be overridden at build time.
@ -111,7 +131,7 @@ const (
// DefaultSignaturePolicyPath is the default value for the
// policy.json file.
DefaultSignaturePolicyPath = "/etc/containers/policy.json"
// DefaultSubnet is the subnet that will be used for the default CNI
// DefaultSubnet is the subnet that will be used for the default
// network.
DefaultSubnet = "10.88.0.0/16"
// DefaultRootlessSignaturePolicyPath is the location within
@ -195,9 +215,10 @@ func DefaultConfig() (*Config, error) {
UserNSSize: DefaultUserNSSize,
},
Network: NetworkConfig{
DefaultNetwork: "podman",
DefaultSubnet: DefaultSubnet,
CNIPluginDirs: DefaultCNIPluginDirs,
DefaultNetwork: "podman",
DefaultSubnet: DefaultSubnet,
DefaultSubnetPools: DefaultSubnetPools,
CNIPluginDirs: DefaultCNIPluginDirs,
},
Engine: *defaultEngineConfig,
Secrets: defaultSecretConfig(),
@ -385,15 +406,14 @@ func probeConmon(conmonBinary string) error {
cmd := exec.Command(conmonBinary, "--version")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
if err := cmd.Run(); err != nil {
return err
}
r := regexp.MustCompile(`^conmon version (?P<Major>\d+).(?P<Minor>\d+).(?P<Patch>\d+)`)
matches := r.FindStringSubmatch(out.String())
if len(matches) != 4 {
return errors.Wrap(err, _conmonVersionFormatErr)
return errors.New(_conmonVersionFormatErr)
}
major, err := strconv.Atoi(matches[1])
if err != nil {