Skip to content

Commit

Permalink
Merge branch 'main' of github.com:calaos/calaos-container into main
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Nov 27, 2023
2 parents b3d961e + fc942f6 commit 625c492
Show file tree
Hide file tree
Showing 21 changed files with 548 additions and 180 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/build-deb-push.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
name: Build deb package
name: Build et release debian package

on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
vincrement:
description: 'Package version increment (major.minor.patch)'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
- prerelease


jobs:
build-and-push-deb-pkg:
name: Build deb package and push to repositories
Expand All @@ -16,48 +27,39 @@ jobs:

- name: Fetch latest release version
id: fetch-latest-release
uses: reloc8/[email protected]

- name: Increment dev release version
id: bump_version
uses: actionsdesk/[email protected]
with:
prerelease: withBuildNumber
prelabel: alpha
initial_version: ${{ steps.fetch-latest-release.outputs.latest-release }}
uses: actions-ecosystem/action-get-latest-tag@v1

- name: Build package
uses: addnab/docker-run-action@v3
id: build
with:
image: ghcr.io/calaos/debian_deb_build_base
options: -v ${{ github.workspace }}:/work
run: |
/build-deb.sh ${{ steps.bump_version.outputs.release }}
git config --global --add safe.directory /work
last_tag=$(python3 /get_last_tag.py /work)
export release=$(pysemver bump ${{ github.event.inputs.vincrement || 'prerelease' }} ${last_tag})
echo Build version: $release
/build-deb.sh $release && echo "::set-output name=release::$release"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: deb
path: pkg/*.deb

- name: Create Tag
uses: negz/create-tag@v1
with:
version: ${{ steps.bump_version.outputs.release }}
token: ${{ secrets.ACTION_DISPATCH }}

- name: Create a Release
uses: meeDamian/[email protected]
with:
token: ${{ secrets.ACTION_DISPATCH }}
tag: ${{ steps.bump_version.outputs.release }}
name: ${{ steps.bump_version.outputs.release }}
tag: ${{ steps.build.outputs.release }}
name: ${{ steps.build.outputs.release }}
prerelease: false
files: pkg/*.deb
prerelease: true
gzip: false

- name: Update repo cache
uses: distributhor/workflow-webhook@v3
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
5 changes: 4 additions & 1 deletion .github/workflows/build-docker-base.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Docker image build and push

on:
workflow_dispatch:
push:
paths:
- docker/**


env:
# Use docker.io for Docker Hub if empty
Expand Down
70 changes: 0 additions & 70 deletions .github/workflows/release-deb.yml

This file was deleted.

22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,24 @@ test: ## Run the tests of the project

coverage: ## Run the tests of the project and export the coverage
$(GOTEST) -cover -covermode=count -coverprofile=profile.cov ./...
$(GOCMD) tool cover -func profile.cov
$(GOCMD) tool cover -func profile.cov

install-lib: apt-install

apt-install:
$(MAKE) -C apt install

install: install-lib ## Install the binaries
install -Dm755 bin/$(BINARY_NAME) $(DESTDIR)$(PREFIX)/bin/$(BINARY_NAME)
install -Dm755 bin/$(BINARY_NAME_TOOL) $(DESTDIR)$(PREFIX)/bin/$(BINARY_NAME_TOOL)
install -Dm755 scripts/start_calaos_home.sh $(DESTDIR)$(PREFIX)/sbin/start_calaos_home.sh
install -Dm755 scripts/calaos_install.sh $(DESTDIR)$(PREFIX)/sbin/calaos_install.sh
install -Dm755 scripts/calaos_rollback.sh $(DESTDIR)$(PREFIX)/sbin/calaos_rollback.sh
install -Dm755 scripts/init_calaosfs.sh $(DESTDIR)$(PREFIX)/sbin/init_calaosfs.sh
install -Dm755 scripts/haproxy_pre.sh $(DESTDIR)$(PREFIX)/sbin/haproxy_pre.sh
install -Dm755 scripts/mosquitto_pre.sh $(DESTDIR)$(PREFIX)/sbin/mosquitto_pre.sh
install -Dm755 scripts/zigbee2mqtt_pre.sh $(DESTDIR)$(PREFIX)/sbin/zigbee2mqtt_pre.sh
install -Dm755 scripts/load_containers_cache.sh $(DESTDIR)$(PREFIX)/sbin/load_containers_cache.sh
install -Dm755 scripts/arch-chroot $(DESTDIR)$(PREFIX)/sbin/arch-chroot
install -Dm755 scripts/genfstab $(DESTDIR)$(PREFIX)/sbin/genfstab
install -Dm755 scripts/start_z2mqtt.sh $(DESTDIR)$(PREFIX)/sbin/start_z2mqtt.sh
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# calaos-container
Container management daemon for calaos-os.
Container management daemon for calaos-os.

# build calaos-container
To get list of build targets:
```
make help
```

To build:
```
make
```
4 changes: 4 additions & 0 deletions apt/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.PHONY: libcalaos-apt.so

all:
@rm -fr build
meson setup build --prefix=/usr
meson compile -C build
meson install -C build

install: all

4 changes: 2 additions & 2 deletions apt/apt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Pkg *aptCacheArrayGet(void *arr, int idx)
PkgList *plist = reinterpret_cast<PkgList *>(arr);
if (!plist) return nullptr;

if (idx < 0 || idx > plist->size())
if (idx < 0 || (size_t)idx > plist->size())
return nullptr;

return &plist->at(idx);
Expand All @@ -117,7 +117,7 @@ void aptCacheArrayFree(void *arr)
PkgList *plist = reinterpret_cast<PkgList *>(arr);
if (!plist) return;

for (int i = 0;i < plist->size();i++)
for (size_t i = 0;i < plist->size();i++)
{
free((*plist)[i].name);
free((*plist)[i].version_current);
Expand Down
8 changes: 6 additions & 2 deletions cmd/calaos-os/calaos-os.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func cmdList(cmd *cli.Cmd) {
for _, e := range *imgs {
t.AppendRow(table.Row{
e.Name,
e.CurrentVerion,
e.Version,
e.Source,
})
}
Expand Down Expand Up @@ -186,7 +186,11 @@ func cmdUpgrade(cmd *cli.Cmd) {
}

bar.SetTextSuffix(fmt.Sprintf("\t Installing %s", status.CurrentPkg))
bar.Set(status.Progress * 100 / status.ProgressTotal)
if status.ProgressTotal < 1 {
bar.Set(0)
} else {
bar.Set(status.Progress * 100 / status.ProgressTotal)
}

time.Sleep(500 * time.Millisecond)
}
Expand Down
15 changes: 1 addition & 14 deletions debian/calaos-container.install
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
bin/calaos-container usr/bin
bin/calaos-os usr/bin
scripts/start_calaos_home.sh usr/bin
calaos-container.toml etc
env/calaos.sh etc/profile.d
scripts/calaos_install.sh usr/sbin
scripts/calaos_rollback.sh usr/sbin
scripts/init_calaosfs.sh usr/sbin
scripts/haproxy_pre.sh usr/sbin
scripts/mosquitto_pre.sh usr/sbin
scripts/zigbee2mqtt_pre.sh usr/sbin
scripts/load_containers_cache.sh usr/sbin
scripts/arch-chroot usr/sbin
scripts/genfstab usr/sbin
initramfs/hooks/grub-btrfs-overlay usr/share/initramfs-tools/hooks/grub-btrfs-overlay
initramfs/scripts/local-bottom/grub-btrfs-overlay usr/share/initramfs-tools/scripts/local-bottom/grub-btrfs-overlay
grub-btrfs/41_snapshots-btrfs etc/grub.d
Expand All @@ -20,5 +8,4 @@ grub-btrfs/grub-btrfsd usr/bin
repository/calaos.gpg etc/apt/trusted.gpg.d
repository/calaos.list etc/apt/sources.list.d
debian/[email protected] lib/systemd/system
debian/[email protected] lib/systemd/system
scripts/start_z2mqtt.sh usr/bin
debian/[email protected] lib/systemd/system
2 changes: 1 addition & 1 deletion debian/calaos-home.service
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Type=notify
NotifyAccess=all
SyslogIdentifier=%N

ExecStart=/usr/bin/start_calaos_home.sh %t/%N.cid
ExecStart=/usr/sbin/start_calaos_home.sh %t/%N.cid

RestartSec=2

Expand Down
2 changes: 1 addition & 1 deletion debian/zigbee2mqtt.service
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Delegate=yes
Type=notify
NotifyAccess=all
SyslogIdentifier=%N
ExecStart=/usr/bin/start_z2mqtt.sh %t/%N.cid
ExecStart=/usr/sbin/start_z2mqtt.sh %t/%N.cid

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM debian:bookworm
RUN apt -y update && \
apt -y upgrade && \
apt-get install -yq --no-install-recommends devscripts debhelper dpkg-dev fakeroot lintian sudo \
pkgconf golang libbtrfs-dev libdevmapper-dev libgpgme-dev git
pkgconf golang libbtrfs-dev libdevmapper-dev libgpgme-dev git python3-semver python3-git

COPY build-deb.sh /build-deb.sh
COPY get_last_tag.py /get_last_tag.py
2 changes: 1 addition & 1 deletion docker/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ pkg_name=$(grep "Package: " debian/control | sed 's/Package: //')
apt-get build-dep -y .
dpkg-buildpackage -us -uc -b

mkdir $workdir/pkg
mkdir -p $workdir/pkg
mv ../"${pkg_name}"_*.deb $workdir/pkg
11 changes: 11 additions & 0 deletions docker/get_last_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import git
import semver
import sys

if len(sys.argv) < 2:
print("Please provide the path to the repository as an argument.")
sys.exit(1)

repo = git.Repo(sys.argv[1])
tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)
print(str(max(map(semver.VersionInfo.parse, map(str, tags)))))
14 changes: 8 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ module github.com/calaos/calaos-container

go 1.20

require github.com/containers/podman/v4 v4.5.1
require (
github.com/containers/podman/v4 v4.5.1
github.com/gofiber/fiber/v2 v2.47.0
github.com/jawher/mow.cli v1.2.0
github.com/knadh/koanf v1.5.0
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/gofiber/fiber/v2 v2.47.0 // indirect
github.com/gofiber/utils v0.0.10 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/jawher/mow.cli v1.2.0 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand Down Expand Up @@ -47,7 +49,7 @@ require (
github.com/containers/ocicrypt v1.1.7 // indirect
github.com/containers/psgo v1.8.0 // indirect
github.com/containers/storage v1.46.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0
github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
Expand Down Expand Up @@ -115,7 +117,7 @@ require (
github.com/sigstore/fulcio v1.2.0 // indirect
github.com/sigstore/rekor v1.1.0 // indirect
github.com/sigstore/sigstore v1.6.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
github.com/sylabs/sif/v2 v2.11.1 // indirect
Expand Down
Loading

0 comments on commit 625c492

Please sign in to comment.