diff --git a/.github/workflows/build_container.yml b/.github/workflows/build_container.yml index 0d9f862..eb48eaf 100644 --- a/.github/workflows/build_container.yml +++ b/.github/workflows/build_container.yml @@ -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' }} diff --git a/.github/workflows/build_pkg.yml b/.github/workflows/build_pkg.yml index 9d56f7b..e9ba763 100644 --- a/.github/workflows/build_pkg.yml +++ b/.github/workflows/build_pkg.yml @@ -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 }}' @@ -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" @@ -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: @@ -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 @@ -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 }}' @@ -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 ] @@ -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') }} @@ -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 }}" diff --git a/README.md b/README.md new file mode 100644 index 0000000..597e7a3 --- /dev/null +++ b/README.md @@ -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. + diff --git a/local-pkgs b/container/apt/preferences.d/local-pkgs similarity index 100% rename from local-pkgs rename to container/apt/preferences.d/local-pkgs diff --git a/debian-src.sources b/container/apt/sources.list.d/debian-src.sources similarity index 100% rename from debian-src.sources rename to container/apt/sources.list.d/debian-src.sources diff --git a/local-pkgs.list b/container/apt/sources.list.d/local-pkgs.list similarity index 100% rename from local-pkgs.list rename to container/apt/sources.list.d/local-pkgs.list diff --git a/build b/container/bin/build similarity index 100% rename from build rename to container/bin/build diff --git a/build_archdep b/container/bin/build_archdep similarity index 100% rename from build_archdep rename to container/bin/build_archdep diff --git a/build_indep b/container/bin/build_indep similarity index 100% rename from build_indep rename to container/bin/build_indep diff --git a/build_source b/container/bin/build_source similarity index 100% rename from build_source rename to container/bin/build_source diff --git a/build.containerfile b/container/build.containerfile similarity index 85% rename from build.containerfile rename to container/build.containerfile index 63da734..5d3e74f 100755 --- a/build.containerfile +++ b/container/build.containerfile @@ -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 \ @@ -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 \ @@ -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 diff --git a/pkgs b/container/conf/pkgs similarity index 100% rename from pkgs rename to container/conf/pkgs diff --git a/setup_native b/container/conf/setup_native similarity index 100% rename from setup_native rename to container/conf/setup_native diff --git a/crossbuild.containerfile b/container/crossbuild.containerfile similarity index 85% rename from crossbuild.containerfile rename to container/crossbuild.containerfile index 0d231e6..213adf0 100644 --- a/crossbuild.containerfile +++ b/container/crossbuild.containerfile @@ -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 \ @@ -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 \ @@ -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 \ @@ -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 diff --git a/mini_sudo.c b/misc/mini_sudo.c similarity index 100% rename from mini_sudo.c rename to misc/mini_sudo.c diff --git a/sudo b/misc/sudo similarity index 100% rename from sudo rename to misc/sudo diff --git a/gh_release b/scripts/gh_release similarity index 100% rename from gh_release rename to scripts/gh_release