mirror of
https://github.com/mudler/luet.git
synced 2025-09-02 15:54:39 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c47bf4833a | ||
|
dfc2743653 | ||
|
1c473e4f85 | ||
|
47f8bdb9ef | ||
|
13dde527b4 | ||
|
5190a5126d | ||
|
c7331207ab | ||
|
fd698e8554 | ||
|
d48006af8a | ||
|
5ee1ff6d5a |
12
.github/workflows/pr.yml
vendored
12
.github/workflows/pr.yml
vendored
@@ -5,7 +5,7 @@ jobs:
|
||||
tests-integration-img:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.18.x]
|
||||
go-version: [1.19.x]
|
||||
platform: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
uses: docker-practice/actions-setup-docker@0.0.1
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
- name: Tests with Img backend
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
tests-integration:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.18.x]
|
||||
go-version: [1.19.x]
|
||||
platform: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -42,13 +42,13 @@ jobs:
|
||||
uses: docker-practice/actions-setup-docker@0.0.1
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
- name: Tests
|
||||
run: sudo -E env "PATH=$PATH" make test-integration
|
||||
tests-unit:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.18.x]
|
||||
go-version: [1.19.x]
|
||||
platform: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
uses: docker-practice/actions-setup-docker@0.0.1
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
sudo make build
|
||||
|
12
.github/workflows/push.yml
vendored
12
.github/workflows/push.yml
vendored
@@ -11,14 +11,14 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Login to quay
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
- name: Login to quay with img
|
||||
@@ -35,14 +35,14 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Login to quay
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
- name: Tests
|
||||
run: |
|
||||
sudo -E \
|
||||
@@ -59,14 +59,14 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Login to quay
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
sudo make build
|
||||
|
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: setup-docker
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
- name: Login to quay with img
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: setup-docker
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
- name: Tests
|
||||
run: |
|
||||
sudo -E \
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: setup-docker
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
run: echo ${{ secrets.DOCKER_TESTING_PASSWORD }} | sudo -E docker login -u ${{ secrets.DOCKER_TESTING_USERNAME }} --password-stdin quay.io
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo apt-get update && sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
|
||||
sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
|
||||
sudo chmod a+x "/usr/bin/img"
|
||||
sudo make build
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.19.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
*.swp
|
||||
.idea/
|
||||
luet
|
||||
tests/integration/shunit2
|
||||
tests/integration/bin
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM golang as builder
|
||||
FROM golang:bullseye as builder
|
||||
RUN apt-get update && apt-get install -y upx
|
||||
ADD . /luet
|
||||
RUN cd /luet && make build
|
||||
|
27
README.md
27
README.md
@@ -34,21 +34,24 @@ It is written entirely in Golang and where used as package manager, it can run i
|
||||
|
||||
## Install
|
||||
|
||||
To install luet, you can grab a release on the [Release page](https://github.com/mudler/luet/releases) or to install it in your system:
|
||||
- **Using official installer script:**
|
||||
|
||||
```bash
|
||||
$ curl https://luet.io/install.sh | sudo sh
|
||||
```console
|
||||
$ curl https://luet.io/install.sh | sudo sh
|
||||
```
|
||||
|
||||
- **Or using [`bin`](https://github.com/marcosnils/bin)**
|
||||
|
||||
```console
|
||||
$ bin i github.com/mudler/luet
|
||||
```
|
||||
|
||||
### Test installation:
|
||||
|
||||
```console
|
||||
$ luet --help
|
||||
$ luet search ...
|
||||
$ luet install ..
|
||||
$ luet --help
|
||||
```
|
||||
|
||||
## Build from source
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/mudler/luet.git
|
||||
$ cd luet
|
||||
$ make build
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
@@ -38,5 +38,6 @@ func init() {
|
||||
NewDatabaseCreateCommand(),
|
||||
NewDatabaseGetCommand(),
|
||||
NewDatabaseRemoveCommand(),
|
||||
NewDatabaseShowAllCommand(),
|
||||
)
|
||||
}
|
||||
|
68
cmd/database/show_all.go
Normal file
68
cmd/database/show_all.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright © 2021 Ettore Di Giacinto <mudler@mocaccino.org>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd_database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mudler/luet/cmd/util"
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
func NewDatabaseShowAllCommand() *cobra.Command {
|
||||
var c = &cobra.Command{
|
||||
Use: "get-all-installed",
|
||||
Short: "Show all installed packages in the system DB as yaml",
|
||||
Args: cobra.NoArgs,
|
||||
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
systemDB := util.SystemDB(util.DefaultContext.Config)
|
||||
var packages []*types.Package
|
||||
|
||||
packs := systemDB.GetPackages()
|
||||
for _, p := range packs {
|
||||
pack, _ := systemDB.GetPackage(p)
|
||||
packages = append(packages, pack)
|
||||
}
|
||||
marshal, err := yaml.Marshal(packages)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(string(marshal))
|
||||
output, _ := cmd.Flags().GetString("output")
|
||||
f, err := os.Create(output)
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating file: %s\n", err)
|
||||
return
|
||||
}
|
||||
_, err = f.WriteString(string(marshal))
|
||||
if err != nil {
|
||||
fmt.Printf("Error writing file: %s\n", err)
|
||||
return
|
||||
}
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("Error closing file: %s\n", err)
|
||||
return
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
c.Flags().String("output", "", "Save output to given file.")
|
||||
return c
|
||||
}
|
@@ -30,7 +30,7 @@ var cfgFile string
|
||||
var Verbose bool
|
||||
|
||||
const (
|
||||
LuetCLIVersion = "0.33.0"
|
||||
LuetCLIVersion = "0.34.0"
|
||||
LuetEnvPrefix = "LUET"
|
||||
)
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/go-units"
|
||||
@@ -34,6 +35,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
filePrefix = "file://"
|
||||
)
|
||||
|
||||
func pack(ctx *context.Context, p, dst, imageName, arch, OS string) error {
|
||||
|
||||
tempimage, err := ctx.TempFile("tempimage")
|
||||
@@ -126,7 +131,7 @@ func NewUnpackCommand() *cobra.Command {
|
||||
RegistryToken: registryToken,
|
||||
}
|
||||
|
||||
if !local {
|
||||
if !local && !strings.HasPrefix(image, filePrefix) {
|
||||
info, err := docker.DownloadAndExtractDockerImage(util.DefaultContext, image, destination, auth, verify)
|
||||
if err != nil {
|
||||
util.DefaultContext.Error(err.Error())
|
||||
|
@@ -208,6 +208,14 @@ Luet doesn't handle login to registries, so that has to be handled separately wi
|
||||
|
||||
When packages are cached, for iterating locally it's particularly useful to jump straight to the image that you want to build. You can use ```--only-target-package``` to jump directly to the image you are interested in. Luet will take care of checking if the images are present in the remote registry, and would build them if any of those are missing.
|
||||
|
||||
## Building for a different platform
|
||||
|
||||
Sometimes you need to build a package for a different platform than the one running on your host machine. For example, you may want to build an arm64 package, but your machine is x86. To do this, all you need to do is pass the following arguments:
|
||||
|
||||
```
|
||||
luet --backend-args --load --backend-args --platform --backend-args linux/arm64 build PACKAGE_NAME
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- All the files which are next to a `build.yaml` are copied in the container which is running your build, so they are always accessible during build time.
|
||||
|
177
docs/content/en/docs/Concepts/Overview/configuration.md
Normal file
177
docs/content/en/docs/Concepts/Overview/configuration.md
Normal file
@@ -0,0 +1,177 @@
|
||||
title: "Configuration"
|
||||
linkTitle: "Configuration
|
||||
weight: 2
|
||||
description: >
|
||||
Configuring Luet
|
||||
---
|
||||
|
||||
### General
|
||||
|
||||
```yaml
|
||||
general:
|
||||
# Define max concurrency processes. Default is based of arch: runtime.NumCPU()
|
||||
concurrency: 1
|
||||
# Enable Debug. If debug is active spinner is disabled.
|
||||
debug: false
|
||||
# Show output of build execution (docker, img, etc.)
|
||||
show_build_output: false
|
||||
# Define spinner ms
|
||||
spinner_ms: 200
|
||||
# Define spinner charset. See https://github.com/briandowns/spinner
|
||||
spinner_charset: 22
|
||||
# Enable warnings to exit
|
||||
fatal_warnings: false
|
||||
# Try extracting tree/packages with the same ownership as exists in the archive (default for superuser).
|
||||
same_owner: false
|
||||
```
|
||||
|
||||
### Images
|
||||
|
||||
After the building of the packages, you can apply arbitrary images on top using the `images` stanza. This is useful if you need to pin a package to a specific version.
|
||||
|
||||
```yaml
|
||||
images:
|
||||
- quay.io/kairos/packages:kairos-agent-system-2.1.12
|
||||
```
|
||||
|
||||
### Logging
|
||||
|
||||
```yaml
|
||||
logging:
|
||||
# Enable loggging to file (if path is not empty)
|
||||
enable_logfile: false
|
||||
# Leave empty to skip logging to file.
|
||||
path: "/var/log/luet.log"
|
||||
# Set logging level: error|warning|info|debug
|
||||
level: "info"
|
||||
# Enable JSON log format instead of console mode.
|
||||
json_format: false.
|
||||
# Disable/Enable color
|
||||
color: true
|
||||
# Enable/Disable emoji
|
||||
enable_emoji: true
|
||||
```
|
||||
|
||||
### Repositories configurations directories.
|
||||
|
||||
```yaml
|
||||
# Define the list of directories where luet
|
||||
# try for files with .yml extension that define
|
||||
# luet repository.
|
||||
repos_confdir:
|
||||
- /etc/luet/repos.conf.d
|
||||
```
|
||||
|
||||
### Finalizer Environment Variables
|
||||
|
||||
```yaml
|
||||
finalizer_envs:
|
||||
- key: "BUILD_ISO"
|
||||
value: "1"
|
||||
```
|
||||
|
||||
### Repositories
|
||||
|
||||
To add repositories, you can either add a `repositories` stanza in your `/etc/luet/luet.yaml` or either add one or more yaml files in `/etc/luet/repos.conf.d/`.
|
||||
|
||||
#### Configuring repositories in the main configuration file
|
||||
|
||||
```yaml
|
||||
logging:
|
||||
color: true # Enable/Disable colored output
|
||||
enable_emoji: true # Enable/Disable emoji from output
|
||||
general:
|
||||
debug: false # Enable/Disable debug
|
||||
system:
|
||||
rootfs: "/" # What's our rootfs. Luet can install packages outside of "/"
|
||||
database_path: "/var/db/luet" # Where to store DB files
|
||||
database_engine: "boltdb"
|
||||
tmpdir_base: "/var/tmp/luet" # The temporary directory to be used
|
||||
repositories:
|
||||
- name: "some-repository-name" # Repository name
|
||||
description: "A beautiful description"
|
||||
type: "http" # Repository type, disk or http are supported (disk for local path)
|
||||
enable: true # Enable/Disable repo
|
||||
cached: true # Enable cache for repository
|
||||
priority: 3 # Cache priority
|
||||
urls: # Repository URLs
|
||||
- "...."
|
||||
```
|
||||
|
||||
#### Using different files to configure repositories
|
||||
|
||||
In the main configuration file you can specify the directory where all repositories are configured:
|
||||
|
||||
```yaml
|
||||
repos_confdir:
|
||||
- /etc/luet/repos.conf.d
|
||||
```
|
||||
|
||||
Then add a file inside `/etc/luet/repos.conf.d/example.yaml` with your configuration, e.g.:
|
||||
|
||||
```yaml
|
||||
name: "..." # Repository name
|
||||
description: "..."
|
||||
type: "http" # Repository type, disk or http are supported (disk for local path)
|
||||
enable: true # Enable/Disable repo
|
||||
cached: true # Enable cache for repository
|
||||
priority: 3 # Cache priority
|
||||
urls: # Repository URLs
|
||||
- "..."
|
||||
```
|
||||
|
||||
There is available a [collection of repositories](https://packages.mocaccino.org/repository-index), which is containing a list of repositories that can be installed in the system with `luet install`.
|
||||
|
||||
If you installed Luet from the curl command, you just need to run `luet search repository` to see a list of all the available repository, and you can install them singularly by running `luet install repository/<name>`. Otherwise, add the repository stanzas you need to `/etc/luet/luet.yaml`.
|
||||
|
||||
#### Config protect configuration files directories.
|
||||
|
||||
```yaml
|
||||
# Define the list of directories where load
|
||||
# configuration files with the list of config
|
||||
# protect paths.
|
||||
config_protect_confdir:
|
||||
- /etc/luet/config.protect.d
|
||||
# Ignore rules defined on
|
||||
# config protect confdir and packages
|
||||
# annotation.
|
||||
config_protect_skip: false
|
||||
# The paths used for load repositories and config
|
||||
# protects are based on host rootfs.
|
||||
# If set to false rootfs path is used as prefix.
|
||||
config_from_host: true
|
||||
```
|
||||
|
||||
### Solver Parameter Configuration
|
||||
|
||||
```yaml
|
||||
solver:
|
||||
# Solver strategy to solve possible conflicts during depedency
|
||||
# solving. Defaults to empty (none). Available: qlearning
|
||||
type: ""
|
||||
# Solver agent learning rate. 0.1 to 1.0
|
||||
rate: 0.7
|
||||
# Learning discount factor.
|
||||
discount: 1.0
|
||||
# Number of overall attempts that the solver has available before bailing out.
|
||||
max_attempts: 9000
|
||||
```
|
||||
|
||||
### System
|
||||
|
||||
```yaml
|
||||
system:
|
||||
# Rootfs path of the luet system. Default is /.
|
||||
# A specific path could be used for test installation to
|
||||
# a chroot environment.
|
||||
rootfs: "/"
|
||||
# Database engine used for luet database.
|
||||
# Supported values: boltdb|memory
|
||||
database_engine: boltdb
|
||||
# Database path directory where store luet database.
|
||||
# The path is appended to rootfs option path.
|
||||
database_path: "/var/cache/luet"
|
||||
# Define the tmpdir base directory where luet store temporary files.
|
||||
# Default $TMPDIR/tmpluet
|
||||
tmpdir_base: "/tmp/tmpluet"
|
||||
```
|
@@ -79,7 +79,7 @@ mv .luet.yaml /etc/luet/luet.yaml
|
||||
|
||||
Luet stores its configuration files in `/etc/luet`. If you wish to override its default settings, create a file `/etc/luet/luet.yaml`.
|
||||
|
||||
A example of a `luet.yaml` file can be found [here](https://github.com/mudler/luet/blob/master/contrib/config/luet.yaml).
|
||||
An example of a configuration file can be found [here](https://github.com/mudler/luet/blob/master/contrib/config/luet.yaml).
|
||||
|
||||
There are a bunch of configuration settings available, but the most relevant are:
|
||||
|
||||
@@ -96,50 +96,4 @@ system:
|
||||
tmpdir_base: "/var/tmp/luet" # The temporary directory to be used
|
||||
```
|
||||
|
||||
### Adding repositories
|
||||
|
||||
To add repositories, you can either add a `repositories` stanza in your `/etc/luet/luet.yaml` or either add one or more yaml files in `/etc/luet/repos.conf.d/`.
|
||||
|
||||
|
||||
#### Configuration in `/etc/luet/luet.yaml`
|
||||
```yaml
|
||||
logging:
|
||||
color: true # Enable/Disable colored output
|
||||
enable_emoji: true # Enable/Disable emoji from output
|
||||
general:
|
||||
debug: false # Enable/Disable debug
|
||||
system:
|
||||
rootfs: "/" # What's our rootfs. Luet can install packages outside of "/"
|
||||
database_path: "/var/db/luet" # Where to store DB files
|
||||
database_engine: "boltdb"
|
||||
tmpdir_base: "/var/tmp/luet" # The temporary directory to be used
|
||||
repositories:
|
||||
- name: "some-repository-name" # Repository name
|
||||
description: "A beautiful description"
|
||||
type: "http" # Repository type, disk or http are supported (disk for local path)
|
||||
enable: true # Enable/Disable repo
|
||||
cached: true # Enable cache for repository
|
||||
priority: 3 # Cache priority
|
||||
urls: # Repository URLs
|
||||
- "...."
|
||||
```
|
||||
|
||||
#### Configuration in `/etc/luet/repos.conf.d/`
|
||||
|
||||
A repository file can be for example:
|
||||
|
||||
```yaml
|
||||
name: "..." # Repository name
|
||||
description: "..."
|
||||
type: "http" # Repository type, disk or http are supported (disk for local path)
|
||||
enable: true # Enable/Disable repo
|
||||
cached: true # Enable cache for repository
|
||||
priority: 3 # Cache priority
|
||||
urls: # Repository URLs
|
||||
- "..."
|
||||
```
|
||||
|
||||
|
||||
There is available a [collection of repositories](https://packages.mocaccino.org/repository-index), which is containing a list of repositories that can be installed in the system with `luet install`.
|
||||
|
||||
If you installed Luet from the curl command, you just need to run `luet search repository` to see a list of all the available repository, and you can install them singularly by running `luet install repository/<name>`. Otherwise, add the repository stanzas you need to `/etc/luet/luet.yaml`.
|
||||
To learn more about how to configure luet, [see the configuration section](/docs/concepts/overview/configuration/)
|
4
go.mod
4
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/mudler/luet
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/Masterminds/sprig/v3 v3.2.1
|
||||
@@ -102,7 +102,7 @@ require (
|
||||
github.com/moby/sys/mountinfo v0.6.0 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/runc v1.1.1 // indirect
|
||||
github.com/opencontainers/runc v1.1.2 // indirect
|
||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -788,8 +788,8 @@ github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h
|
||||
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
|
||||
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
|
||||
github.com/opencontainers/runc v1.1.1 h1:PJ9DSs2sVwE0iVr++pAHE6QkS9tzcVWozlPifdwMgrU=
|
||||
github.com/opencontainers/runc v1.1.1/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc=
|
||||
github.com/opencontainers/runc v1.1.2 h1:2VSZwLx5k/BfsBxMMipG/LYUnmqOD/BPkIVgQUcTlLw=
|
||||
github.com/opencontainers/runc v1.1.2/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc=
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
|
141
pkg/box/exec.go
141
pkg/box/exec.go
@@ -15,19 +15,6 @@
|
||||
|
||||
package box
|
||||
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
fileHelper "github.com/mudler/luet/pkg/helpers/file"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Box interface {
|
||||
Run() error
|
||||
Exec() error
|
||||
@@ -55,131 +42,3 @@ func NewBox(cmd string, args, hostmounts, env []string, rootfs string, stdin, st
|
||||
Env: env,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *DefaultBox) Exec() error {
|
||||
|
||||
if err := mountProc(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed mounting proc on rootfs")
|
||||
}
|
||||
if err := mountDev(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed mounting dev on rootfs")
|
||||
}
|
||||
|
||||
for _, hostMount := range b.HostMounts {
|
||||
target := hostMount
|
||||
if strings.Contains(hostMount, ":") {
|
||||
dest := strings.Split(hostMount, ":")
|
||||
if len(dest) != 2 {
|
||||
return errors.New("Invalid arguments for mount, it can be: fullpath, or source:target")
|
||||
}
|
||||
hostMount = dest[0]
|
||||
target = dest[1]
|
||||
}
|
||||
if err := mountBind(hostMount, b.Root, target); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed mounting %s on rootfs", hostMount))
|
||||
}
|
||||
}
|
||||
|
||||
if err := PivotRoot(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed switching pivot on rootfs")
|
||||
}
|
||||
cmd := exec.Command(b.Cmd, b.Args...)
|
||||
|
||||
if b.Stdin {
|
||||
cmd.Stdin = os.Stdin
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
cmd.Stdout = os.Stdout
|
||||
}
|
||||
|
||||
cmd.Env = b.Env
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Error running the %s command in box.Exec", b.Cmd))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *DefaultBox) Run() error {
|
||||
|
||||
if !fileHelper.Exists(b.Root) {
|
||||
return errors.New(b.Root + " does not exist")
|
||||
}
|
||||
|
||||
// This matches with exec CLI command in luet
|
||||
// TODO: Pass by env var as well
|
||||
execCmd := []string{"exec", "--rootfs", b.Root, "--entrypoint", b.Cmd}
|
||||
|
||||
if b.Stdin {
|
||||
execCmd = append(execCmd, "--stdin")
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
execCmd = append(execCmd, "--stderr")
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
execCmd = append(execCmd, "--stdout")
|
||||
}
|
||||
// Encode the command in base64 to avoid bad input from the args given
|
||||
execCmd = append(execCmd, "--decode")
|
||||
|
||||
for _, m := range b.HostMounts {
|
||||
execCmd = append(execCmd, "--mount")
|
||||
execCmd = append(execCmd, m)
|
||||
}
|
||||
|
||||
for _, e := range b.Env {
|
||||
execCmd = append(execCmd, "--env")
|
||||
execCmd = append(execCmd, e)
|
||||
}
|
||||
|
||||
for _, a := range b.Args {
|
||||
execCmd = append(execCmd, b64.StdEncoding.EncodeToString([]byte(a)))
|
||||
}
|
||||
|
||||
cmd := exec.Command("/proc/self/exe", execCmd...)
|
||||
if b.Stdin {
|
||||
cmd.Stdin = os.Stdin
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
cmd.Stdout = os.Stdout
|
||||
}
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Cloneflags: syscall.CLONE_NEWNS |
|
||||
syscall.CLONE_NEWUTS |
|
||||
syscall.CLONE_NEWIPC |
|
||||
syscall.CLONE_NEWPID |
|
||||
syscall.CLONE_NEWNET |
|
||||
syscall.CLONE_NEWUSER,
|
||||
UidMappings: []syscall.SysProcIDMap{
|
||||
{
|
||||
ContainerID: 0,
|
||||
HostID: os.Getuid(),
|
||||
Size: 1,
|
||||
},
|
||||
},
|
||||
GidMappings: []syscall.SysProcIDMap{
|
||||
{
|
||||
ContainerID: 0,
|
||||
HostID: os.Getgid(),
|
||||
Size: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrap(err, "Failed running Box command in box.Run")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
25
pkg/box/exec_darwin.go
Normal file
25
pkg/box/exec_darwin.go
Normal file
@@ -0,0 +1,25 @@
|
||||
//go:build darwin
|
||||
|
||||
// Copyright © 2020 Ettore Di Giacinto <mudler@gentoo.org>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package box
|
||||
|
||||
func (b *DefaultBox) Exec() error {
|
||||
panic("not implemented")
|
||||
}
|
||||
func (b *DefaultBox) Run() error {
|
||||
panic("not implemented")
|
||||
}
|
159
pkg/box/exec_linux.go
Normal file
159
pkg/box/exec_linux.go
Normal file
@@ -0,0 +1,159 @@
|
||||
//go:build linux
|
||||
|
||||
// Copyright © 2020 Ettore Di Giacinto <mudler@gentoo.org>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package box
|
||||
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
fileHelper "github.com/mudler/luet/pkg/helpers/file"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (b *DefaultBox) Exec() error {
|
||||
|
||||
if err := mountProc(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed mounting proc on rootfs")
|
||||
}
|
||||
if err := mountDev(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed mounting dev on rootfs")
|
||||
}
|
||||
|
||||
for _, hostMount := range b.HostMounts {
|
||||
target := hostMount
|
||||
if strings.Contains(hostMount, ":") {
|
||||
dest := strings.Split(hostMount, ":")
|
||||
if len(dest) != 2 {
|
||||
return errors.New("Invalid arguments for mount, it can be: fullpath, or source:target")
|
||||
}
|
||||
hostMount = dest[0]
|
||||
target = dest[1]
|
||||
}
|
||||
if err := mountBind(hostMount, b.Root, target); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed mounting %s on rootfs", hostMount))
|
||||
}
|
||||
}
|
||||
|
||||
if err := PivotRoot(b.Root); err != nil {
|
||||
return errors.Wrap(err, "Failed switching pivot on rootfs")
|
||||
}
|
||||
cmd := exec.Command(b.Cmd, b.Args...)
|
||||
|
||||
if b.Stdin {
|
||||
cmd.Stdin = os.Stdin
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
cmd.Stdout = os.Stdout
|
||||
}
|
||||
|
||||
cmd.Env = b.Env
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Error running the %s command in box.Exec", b.Cmd))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *DefaultBox) Run() error {
|
||||
|
||||
if !fileHelper.Exists(b.Root) {
|
||||
return errors.New(b.Root + " does not exist")
|
||||
}
|
||||
|
||||
// This matches with exec CLI command in luet
|
||||
// TODO: Pass by env var as well
|
||||
execCmd := []string{"exec", "--rootfs", b.Root, "--entrypoint", b.Cmd}
|
||||
|
||||
if b.Stdin {
|
||||
execCmd = append(execCmd, "--stdin")
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
execCmd = append(execCmd, "--stderr")
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
execCmd = append(execCmd, "--stdout")
|
||||
}
|
||||
// Encode the command in base64 to avoid bad input from the args given
|
||||
execCmd = append(execCmd, "--decode")
|
||||
|
||||
for _, m := range b.HostMounts {
|
||||
execCmd = append(execCmd, "--mount")
|
||||
execCmd = append(execCmd, m)
|
||||
}
|
||||
|
||||
for _, e := range b.Env {
|
||||
execCmd = append(execCmd, "--env")
|
||||
execCmd = append(execCmd, e)
|
||||
}
|
||||
|
||||
for _, a := range b.Args {
|
||||
execCmd = append(execCmd, b64.StdEncoding.EncodeToString([]byte(a)))
|
||||
}
|
||||
|
||||
cmd := exec.Command("/proc/self/exe", execCmd...)
|
||||
if b.Stdin {
|
||||
cmd.Stdin = os.Stdin
|
||||
}
|
||||
|
||||
if b.Stderr {
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
if b.Stdout {
|
||||
cmd.Stdout = os.Stdout
|
||||
}
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Cloneflags: syscall.CLONE_NEWNS |
|
||||
syscall.CLONE_NEWUTS |
|
||||
syscall.CLONE_NEWIPC |
|
||||
syscall.CLONE_NEWPID |
|
||||
syscall.CLONE_NEWNET |
|
||||
syscall.CLONE_NEWUSER,
|
||||
UidMappings: []syscall.SysProcIDMap{
|
||||
{
|
||||
ContainerID: 0,
|
||||
HostID: os.Getuid(),
|
||||
Size: 1,
|
||||
},
|
||||
},
|
||||
GidMappings: []syscall.SysProcIDMap{
|
||||
{
|
||||
ContainerID: 0,
|
||||
HostID: os.Getgid(),
|
||||
Size: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrap(err, "Failed running Box command in box.Run")
|
||||
}
|
||||
return nil
|
||||
}
|
@@ -1,3 +1,5 @@
|
||||
//go:build linux
|
||||
|
||||
// Copyright © 2020 Ettore Di Giacinto <mudler@gentoo.org>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
@@ -20,6 +20,10 @@ import (
|
||||
"encoding/hex"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
|
||||
"github.com/containerd/containerd/images"
|
||||
luetimages "github.com/mudler/luet/pkg/api/core/image"
|
||||
@@ -42,6 +46,11 @@ import (
|
||||
"github.com/theupdateframework/notary/tuf/data"
|
||||
)
|
||||
|
||||
const (
|
||||
filePrefix = "file://"
|
||||
fileImageSeparator = ":/"
|
||||
)
|
||||
|
||||
// See also https://github.com/docker/cli/blob/88c6089300a82d3373892adf6845a4fed1a4ba8d/cli/command/image/trust.go#L171
|
||||
|
||||
func verifyImage(image string, authConfig *types.AuthConfig) (string, error) {
|
||||
@@ -196,18 +205,26 @@ func DownloadAndExtractDockerImage(ctx luettypes.Context, image, dest string, au
|
||||
}
|
||||
|
||||
func ExtractDockerImage(ctx luettypes.Context, local, dest string) (*images.Image, error) {
|
||||
var img v1.Image
|
||||
if !fileHelper.Exists(dest) {
|
||||
if err := os.MkdirAll(dest, os.ModePerm); err != nil {
|
||||
return nil, errors.Wrapf(err, "cannot create destination directory")
|
||||
}
|
||||
}
|
||||
|
||||
ref, err := name.ParseReference(local)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var err error
|
||||
if strings.HasPrefix(local, filePrefix) {
|
||||
parts := strings.Split(local, fileImageSeparator)
|
||||
if len(parts) == 2 && parts[1] != "" {
|
||||
img, err = tarball.ImageFromPath(parts[1], nil)
|
||||
}
|
||||
} else {
|
||||
ref, err := name.ParseReference(local)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img, err = daemon.Image(ref)
|
||||
}
|
||||
|
||||
img, err := daemon.Image(ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -62,9 +62,8 @@ testInstall() {
|
||||
|
||||
assertTrue 'package installed file1' "[ -e '$tmpdir/testrootfs/file1' ]"
|
||||
assertTrue 'package installed file2' "[ -e '$tmpdir/testrootfs/file2' ]"
|
||||
|
||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file1)" "cap_net_raw+ep"
|
||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file2)" "cap_net_raw+ep"
|
||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file1)" "cap_net_raw=ep"
|
||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file2)" "cap_net_raw=ep"
|
||||
}
|
||||
|
||||
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -403,7 +403,7 @@ github.com/opencontainers/go-digest
|
||||
## explicit
|
||||
github.com/opencontainers/image-spec/specs-go
|
||||
github.com/opencontainers/image-spec/specs-go/v1
|
||||
# github.com/opencontainers/runc v1.1.1
|
||||
# github.com/opencontainers/runc v1.1.2
|
||||
## explicit; go 1.16
|
||||
github.com/opencontainers/runc/libcontainer/user
|
||||
# github.com/otiai10/copy v1.2.1-0.20200916181228-26f84a0b1578
|
||||
|
Reference in New Issue
Block a user