Skip to content

Commit

Permalink
Merge pull request #6 from gardenlinux/feature/3-add-folders-for-orga…
Browse files Browse the repository at this point in the history
…nizing-script-container-file-etc

Feature/3 add folders for organizing script container file etc
  • Loading branch information
Vincinator authored Nov 6, 2023
2 parents 34a53ac + 8e03ace commit 0db0717
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
run: |
set -x
if [ ${{ matrix.host }} = ${{ matrix.target }} ]; then
podman build --build-arg arch=${{ matrix.host }} -f build.containerfile -t ghcr.io/${{ github.repository }}/${{ matrix.host }}:${{ matrix.target }} .
podman build --build-arg arch=${{ matrix.host }} -f container/build.containerfile -t ghcr.io/${{ github.repository }}/${{ matrix.host }}:${{ matrix.target }} .
else
case ${{ matrix.target }} in
amd64) gnu_arch=x86-64 ;;
arm64v8) gnu_arch=aarch64 ;;
esac
podman build --build-arg native_arch=${{ matrix.host }} --build-arg target_arch=${{ matrix.target }} --build-arg gnu_arch=$gnu_arch -f crossbuild.containerfile -t ghcr.io/${{ github.repository }}/${{ matrix.host }}:${{ matrix.target }} .
podman build --build-arg native_arch=${{ matrix.host }} --build-arg target_arch=${{ matrix.target }} --build-arg gnu_arch=$gnu_arch -f container/crossbuild.containerfile -t ghcr.io/${{ github.repository }}/${{ matrix.host }}:${{ matrix.target }} .
fi
- name: publish
if: ${{ github.ref == 'refs/heads/main' }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build_pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
mkdir _pkgs
while IFS=@ read -r repo tag; do
./gh_release "${{ github.token }}" "$repo" list "$tag" | grep '\.deb$' | while read -r url; do
./scripts/gh_release "${{ github.token }}" "$repo" list "$tag" | grep '\.deb$' | while read -r url; do
(cd _pkgs && wget "$url")
done
done <<< '${{ inputs.dependencies }}'
Expand All @@ -54,7 +54,7 @@ jobs:
- name: check if ${{ env.pkg }} already released
id: check
run: |
if ./gh_release "${{ github.token }}" "${{ github.repository }}" exists "${{ steps.build.outputs.pkg }}"; then
if ./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" exists "${{ steps.build.outputs.pkg }}"; then
echo "skip_release=true" | tee "$GITHUB_OUTPUT"
else
echo "skip_release=false" | tee "$GITHUB_OUTPUT"
Expand All @@ -63,9 +63,9 @@ jobs:
id: release
if: ${{ steps.check.outputs.skip_release != 'true' }}
run: |
release="$(./gh_release "${{ github.token }}" "${{ github.repository }}" create --draft "${{ steps.build.outputs.pkg }}" "${{ github.sha }}" "${{ steps.build.outputs.pkg }}")"
release="$(./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" create --draft "${{ steps.build.outputs.pkg }}" "${{ github.sha }}" "${{ steps.build.outputs.pkg }}")"
for f in output/*; do
./gh_release "${{ github.token }}" "${{ github.repository }}" upload "$release" "$f"
./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" upload "$release" "$f"
done
echo "release=$release" | tee "$GITHUB_OUTPUT"
packages:
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
cd input
pkg="${{ needs.source.outputs.pkg }}"
release="${{ needs.source.outputs.release }}"
../gh_release "${{ github.token }}" "${{ github.repository }}" download "$release" "$pkg.dsc"
../scripts/gh_release "${{ github.token }}" "${{ github.repository }}" download "$release" "$pkg.dsc"
awk '!/^ / { flag=0 } flag { print $NF } /^Files:/ { flag=1 }' < "$pkg.dsc" | while read -r file; do
../gh_release "${{ github.token }}" "${{ github.repository }}" download "$release" "$file"
done
Expand All @@ -105,7 +105,7 @@ jobs:
run: |
mkdir _pkgs
while IFS=@ read -r repo tag; do
./gh_release "${{ github.token }}" "$repo" list "$tag" | grep '\.deb$' | while read -r url; do
./scripts/gh_release "${{ github.token }}" "$repo" list "$tag" | grep '\.deb$' | while read -r url; do
(cd _pkgs && wget "$url")
done
done <<< '${{ inputs.dependencies }}'
Expand All @@ -123,7 +123,7 @@ jobs:
run: |
release="${{ needs.source.outputs.release }}"
for f in output/*; do
./gh_release "${{ github.token }}" "${{ github.repository }}" upload "$release" "$f"
./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" upload "$release" "$f"
done
publish:
needs: [ source, packages ]
Expand All @@ -134,7 +134,7 @@ jobs:
with:
repository: gardenlinux/package-build
- name: publish drafted release
run: ./gh_release "${{ github.token }}" "${{ github.repository }}" publish_draft "${{ needs.source.outputs.release }}"
run: ./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" publish_draft "${{ needs.source.outputs.release }}"
cleanup:
needs: [ source, packages ]
if: ${{ always() && contains(needs.*.result, 'failure') }}
Expand All @@ -144,4 +144,4 @@ jobs:
with:
repository: gardenlinux/package-build
- name: delete drafted release
run: ./gh_release "${{ github.token }}" "${{ github.repository }}" delete "${{ needs.source.outputs.release }}"
run: ./scripts/gh_release "${{ github.token }}" "${{ github.repository }}" delete "${{ needs.source.outputs.release }}"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Project Name: gardenlinux/package-build

## Description
This project is part of the gardenlinux organization on GitHub and focuses on package building for GardenLinux system.

It contains:
- `container/`: This folder contains container-related files that define images and configurations.
- `*.containerfile`: These files define container images.
- `apt/`: This folder contains apt configuration files.
- `bin/`: This folder contains executable scripts installs into the container.
- `conf/`: This folder contains containers configurations on installed packages list and native container setup.
- `misc/`: This folder contains miscellaneous files related to the project.
- `scripts/`: This folder contains scripts for it's github actions workflow.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions build.containerfile → container/build.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG arch=amd64
# Stage 1: Build and install mini_sudo
FROM $arch/$image AS mini_sudo
WORKDIR /tmp
COPY mini_sudo.c ./
COPY misc/mini_sudo.c ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends -y gcc libc-dev \
Expand All @@ -17,14 +17,13 @@ FROM $arch/$image
WORKDIR /tmp

# Copy repository configration files for apt
COPY debian-src.sources local-pkgs.list /etc/apt/sources.list.d/
COPY local-pkgs /etc/apt/preferences.d/
COPY container/apt /etc/

# Create a directory for local packages and touch the Packages file
RUN mkdir /pkgs && touch /pkgs/Packages

# Copy the package list file
COPY pkgs ./
COPY container/conf/pkgs ./

# Install packages from pkgs list and mark them as held, test gcc and cleanup
RUN apt-get update \
Expand All @@ -37,8 +36,8 @@ RUN apt-get update \
&& ./main \
&& find /tmp -mindepth 1 -delete

# Copy the build scripts to /usr/local/bin
COPY build_source build_indep build_archdep build /usr/local/bin/
# Copy the build scripts from bin/ into /usr/local/bin
COPY container/bin/ /usr/local/bin

# Copy mini_sudo from stage 1
COPY --from=mini_sudo /usr/local/bin/sudo /usr/local/bin/sudo
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 8 additions & 9 deletions crossbuild.containerfile → container/crossbuild.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG target_arch=arm64v8
# Stage 1: Build and install mini_sudo
FROM $native_arch/$image AS mini_sudo
WORKDIR /tmp
COPY mini_sudo.c ./
COPY misc/mini_sudo.c ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends -y gcc libc-dev \
Expand All @@ -17,7 +17,7 @@ RUN apt-get update \
FROM $native_arch/$image AS native
ARG gnu_arch=aarch64
WORKDIR /tmp
COPY pkgs setup_native ./
COPY container/conf/ ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends -y bbe patchelf \
Expand All @@ -30,11 +30,12 @@ FROM $target_arch/$image
WORKDIR /tmp

# Copy repository configration files for apt
COPY debian-src.sources local-pkgs.list /etc/apt/sources.list.d/
COPY local-pkgs /etc/apt/preferences.d/
COPY container/apt /etc/

# Copy setup_native and pkgs into the container
COPY container/conf/ ./

# Install packages from pkgs list and mark them as held, test gcc
COPY pkgs ./
RUN mkdir /pkgs \
&& touch /pkgs/Packages \
&& apt-get update \
Expand All @@ -50,15 +51,13 @@ RUN mkdir /pkgs \
# Copy the native build artifacts from the previous stage
COPY --from=native /native /native

# Copy setup_native script and execute it
COPY setup_native ./
RUN [ "/native/bash", "-c", "PATH=/native:$PATH ./setup_native import $(awk '{ print $1 }' pkgs)" ]

# Clean up /tmp
RUN find /tmp -mindepth 1 -delete

# Copy the build scripts to /usr/local/bin
COPY build_source build_indep build_archdep build /usr/local/bin/
# Copy the build scripts from bin to /usr/local/bin
COPY container/bin/ /usr/local/bin

# Copy mini_sudo from stage 1
COPY --from=mini_sudo /usr/local/bin/sudo /usr/local/bin/sudo
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0db0717

Please sign in to comment.