Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanformigoni committed Apr 28, 2024
2 parents 71cf41a + 308ad32 commit e186088
Show file tree
Hide file tree
Showing 20 changed files with 1,745 additions and 278 deletions.
84 changes: 8 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,28 @@ on:

jobs:
#
# Fetch Tools
#
fetch:
runs-on: ubuntu-latest
steps:
- name: Install tools
run: |
sudo env DEBIAN_FRONTEND=noninteractive apt install -y tar xz-utils
- name: Fetch Magick
run: |
mkdir -p bin
wget -O bin/magick "https://github.com/ruanformigoni/imagemagick-static-musl/releases/download/cc3f21c/magick-x86_64"
wget -O bin/magick-license "https://raw.githubusercontent.com/ImageMagick/ImageMagick/main/LICENSE"
chmod +x bin/magick
- name: Fetch coreutils
run: |
wget "https://github.com/ruanformigoni/coreutils-static/releases/download/d7f4cd2/coreutils-x86_64.tar.xz"
# Extracts a bin/... folder
tar xf "coreutils-x86_64.tar.xz"
- name: Fetch lsof
run: |
mkdir -p ./bin
wget -O./bin/lsof "https://github.com/ruanformigoni/lsof-static-musl/releases/download/e1a88fb/lsof-x86_64"
- name: Fetch e2fsprogs
run: |
mkdir -p bin
wget -O ./bin/fuse2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/fuse2fs"
wget -O ./bin/mke2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/mke2fs"
wget -O ./bin/e2fsck "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/e2fsck"
wget -O ./bin/resize2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/resize2fs"
- name: Fetch proot
run: |
mkdir -p ./bin
wget -O ./bin/proot "https://github.com/ruanformigoni/proot/releases/download/5a4be11/proot"
- name: Fetch bwrap
run: |
mkdir -p ./bin
wget -O ./bin/bwrap "https://github.com/ruanformigoni/bubblewrap-musl-static/releases/download/559a725/bwrap"
- name: Fetch overlayfs
run: |
mkdir -p ./bin
wget -O ./bin/overlayfs "https://github.com/ruanformigoni/fuse-overlayfs/releases/download/af507a2/fuse-overlayfs-x86_64"
- name: Fetch dwarfs
run: |
mkdir -p ./dwarfs
wget -Odwarfs.tar.xz https://github.com/mhx/dwarfs/releases/download/v0.6.2/dwarfs-0.6.2-Linux.tar.xz
tar xf dwarfs.tar.xz --strip-components=1 -Cdwarfs
mkdir -p ./bin
mv ./dwarfs/bin/mkdwarfs ./bin
mv ./dwarfs/bin/dwarfsextract ./bin
mv ./dwarfs/sbin/dwarfs2 ./bin/dwarfs
- name: Fetch bash
run: |
mkdir -p bin
wget -O ./bin/bash "https://github.com/ruanformigoni/bash-static/releases/download/5355251/bash-linux-x86_64"
- name: Upload Tools
uses: actions/upload-artifact@v3
with:
name: tools
path: bin
#
# Build
#
build:
strategy:
matrix:
dist: [arch,alpine,jammy]
runs-on: ubuntu-latest
needs: fetch
steps:
# Install required tools
- name: Install tools
run: |
sudo env DEBIAN_FRONTEND=noninteractive apt install -y tar xz-utils debootstrap coreutils
# Download source from repository
- uses: actions/checkout@v4
# Download Artifacts from the fetch job
- uses: actions/download-artifact@v3
with:
name: tools
path: bin
# Build the main elf
- name: Build Elf
# Fetch tools
- name: Fetch tools
run: |
./deploy/flatimage.sh fetch
# Build
- name: Build
run: |
docker build . \
--build-arg FIM_DIST=${{ matrix.dist }} \
-t "flatimage:${{ matrix.dist }}" \
-f docker/Dockerfile.elf
docker run \
--rm -v $(pwd):/workdir "flatimage:${{ matrix.dist }}" \
cp /fim/dist/main /workdir/elf-${{ matrix.dist }}
./deploy/flatimage.sh build ${{ matrix.dist }}
# Build the flatimage
- name: Build ArchLinux
if: matrix.dist == 'arch'
Expand Down Expand Up @@ -127,6 +58,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
- [Inside the container](#inside-the-container)
- [Samples](#samples)
- [Usage Inside Docker](#usage-inside-docker)
- [Further Considerations](#further-considerations)
- [Motivations](#motivations)
- [Further Considerations](#further-considerations)
- [Architecture](#architecture)
- [Related Projects](#related-projects)

## What is FlatImage?
Expand Down Expand Up @@ -134,8 +135,6 @@ Avaliable options:
- E.g.: ./arch.flatimage fim-dwarfs-add ./image.dwarfs /opt/image
- fim-dwarfs-list: Lists the dwarfs filesystems in the flatimage
- E.g.: ./arch.flatimage fim-dwarfs-list
- fim-dwarfs-overlayfs: Makes dwarfs filesystems writteable again with overlayfs
- E.g.: ./arch.flatimage fim-dwarfs-overlayfs usr '"$FIM_FILE_BINARY".config/overlays/usr'
- fim-hook-add-pre: Includes a hook that runs before the main command
- E.g.: ./arch.flatimage fim-hook-add-pre ./my-hook
- fim-hook-add-post: Includes a hook that runs after the main command
Expand Down Expand Up @@ -167,6 +166,8 @@ Avaliable options:
* `FIM_DIR_TEMP`: Location of the temporary runtime directory.
* `FIM_DIR_MOUNT`: Location of the runtime fim mountpoint.
* `FIM_MAIN_OFFSET`: Shows filesystem offset and exits.
* `FIM_DIR_HOST_CONFIG`: Configuration directory in the host machine
* `FIM_DIR_HOST_OVERLAYS`: Overlayfs mountpoint directory in the host machine


The default path of `FIM` temporary files is `/tmp/fim`.
Expand Down Expand Up @@ -243,16 +244,7 @@ $ find ~/.local/share -iname "*flatimage*" -exec rm -v "{}" \;

### Overlayfs

You can use overlayfs on top of the `dwarfs` filesystems, e.g.:

```bash
# List dwarfs filesystems
$ ./arch.flatimage fim-dwarfs-list
usr
opt
# Suppose you want to make "usr" writteable again, use
$ ./arch.flatimage fim-dwarfs-overlayfs usr '"$FIM_FILE_BINARY".config/overlays/usr'
```
Overlayfs is automatically enabled for all compressed filesystems.

### Hooks

Expand Down Expand Up @@ -536,9 +528,32 @@ In this case `arch.flatimage` is now a portable building environment for htop.

# Samples

[1.](https://gitlab.com/formigoni/flatimage/-/blob/master/samples/sample-steam.sh?ref_type=heads) Portable steam
## Portable steam

Creates a portable steam installation that works on both `GNU` and `MUSL` systems:

```
wget -O- https://raw.githubusercontent.com/ruanformigoni/flatimage/master/samples/steam.sh | sh
```

[2.](https://gitlab.com/formigoni/wine/-/releases) Portable wine
The home directory (where your games will be installed into) for this steam sample is always on the same directory as the flatimage, in a folder called `steam.home`. This enables the usage of steam on an external hard drive that maybe plugged in several linux distros, without having to re-configure anything.

## Portable wine

Creates a portable wine installation that works on both `GNU` and `MUSL` systems:

```
wget https://github.com/gameimage/runners/releases/download/wine-gnu-x86_64/base.flatimage.tar.xz
wget https://github.com/gameimage/runners/releases/download/wine-gnu-x86_64/staging.dwarfs
tar xf base.flatimage.tar.xz
rm base.flatimage.tar.xz
chmod +x base.flatimage
./base.flatimage fim-dwarfs-add staging.dwarfs /fim/mount/wine
rm staging.dwarfs
mv ./base.flatimage ./wine
```

You can use it simply by:

# Usage Inside Docker

Expand All @@ -551,6 +566,10 @@ cd workdir
./alpine.flatimage
```

# Architecture

![architecture.svg](./doc/flatimage-architecture.svg)

# Further Considerations

FlatImage offers on build simplicity, packaging applications should be as simple as
Expand Down
74 changes: 74 additions & 0 deletions deploy/flatimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

######################################################################
# @author : Ruan E. Formigoni ([email protected])
# @file : flatimage
######################################################################


function fetch()
{
# Fetch Magick
wget -O bin/magick "https://github.com/ruanformigoni/imagemagick-static-musl/releases/download/cc3f21c/magick-x86_64"
wget -O bin/magick-license "https://raw.githubusercontent.com/ImageMagick/ImageMagick/main/LICENSE"
chmod +x bin/magick

# Fetch coreutils
wget "https://github.com/ruanformigoni/coreutils-static/releases/download/d7f4cd2/coreutils-x86_64.tar.xz"

# Extracts a bin/... folder
tar xf "coreutils-x86_64.tar.xz"

# Fetch lsof
wget -O./bin/lsof "https://github.com/ruanformigoni/lsof-static-musl/releases/download/e1a88fb/lsof-x86_64"

# Fetch e2fsprogs
wget -O ./bin/fuse2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/fuse2fs"
wget -O ./bin/mke2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/mke2fs"
wget -O ./bin/e2fsck "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/e2fsck"
wget -O ./bin/resize2fs "https://github.com/ruanformigoni/e2fsprogs/releases/download/e58f946/resize2fs"

# Fetch proot
wget -O ./bin/proot "https://github.com/ruanformigoni/proot/releases/download/5a4be11/proot"

# Fetch bwrap
wget -O ./bin/bwrap "https://github.com/ruanformigoni/bubblewrap-musl-static/releases/download/559a725/bwrap"

# Fetch overlayfs
wget -O ./bin/overlayfs "https://github.com/ruanformigoni/fuse-overlayfs/releases/download/af507a2/fuse-overlayfs-x86_64"

# Fetch dwarfs
wget -O bin/dwarfs_aio "https://github.com/mhx/dwarfs/releases/download/v0.9.8/dwarfs-universal-0.9.8-Linux-x86_64-clang"
ln -sf dwarfs_aio bin/mkdwarfs
ln -sf dwarfs_aio bin/dwarfsextract
ln -sf dwarfs_aio bin/dwarfs

# Fetch bash
wget -O ./bin/bash "https://github.com/ruanformigoni/bash-static/releases/download/5355251/bash-linux-x86_64"

# Setup xdg
cp src/xdg/xdg-* bin
chmod +x bin/xdg-*
}

function build()
{
# Build portal
docker build . -t "flatimage-portal:$1" -f docker/Dockerfile.portal
docker run --rm -v "$(pwd)":/workdir "flatimage-portal:$1" cp /fim/dist/portal_guest /workdir/bin/fim_portal_guest
docker run --rm -v "$(pwd)":/workdir "flatimage-portal:$1" cp /fim/dist/portal_host /workdir/bin/fim_portal_host

# Build the main elf
docker build . --build-arg FIM_DIST="$1" -t "flatimage:$1" -f docker/Dockerfile.elf
docker run --rm -v "$(pwd)":/workdir "flatimage:$1" cp /fim/dist/main /workdir/elf-"$1"
}

function main()
{
case "$1" in
"fetch") fetch ;;
"build") build "$2" ;;
esac
}

main "$@"
Loading

0 comments on commit e186088

Please sign in to comment.