diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index eb7a989..116cc61 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -21,32 +21,32 @@ jobs: - name: "Build" run: | - mkdir -p ~/rpmbuild echo "$RPM_SIGNING_KEY" > ./rpm_signing_key - docker run -t -v "$PWD":/repo fedora:38 /bin/bash -c "/repo/build-packages.sh" + mkdir -p /output + docker run -t --privileged -v "$PWD":/repo -v /output:/output fedora:38 /bin/bash -c "/repo/build-packages.sh" env: RPM_SIGNING_KEY: ${{ secrets.RPM_SIGNING_KEY }} - name: "Check Packages" run: | - stat --printf='' ${{ github.workspace }}/output/RPMS/*/kernel* - stat --printf='' ${{ github.workspace }}/output/RPMS/*/t2linux-config* - stat --printf='' ${{ github.workspace }}/output/RPMS/*/t2linux-repo* + stat --printf='' /output/kernel*.rpm + stat --printf='' /output/t2linux-config*.rpm + stat --printf='' /output/t2linux-repo*.rpm - name: "Release" uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | - ${{ github.workspace }}/output/RPMS/*/* + /output/*.rpm env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update repo if: startsWith(github.ref, 'refs/tags/') run: | - mkdir /tmp/repo - docker run -t -v "$PWD":/repo -v "/tmp/repo":/tmp/repo fedora:38 /bin/bash -c "/repo/build-repo.sh" + mkdir /rpm-repo + docker run -t -v /output:/output -v /rpm-repo:/rpm-repo fedora:38 /bin/bash -c "/repo/build-repo.sh" cp -r /tmp/repo ./deploy - name: Upload diff --git a/.github/workflows/update-repo.yml b/.github/workflows/update-repo.yml index 54f8902..afc9a5a 100644 --- a/.github/workflows/update-repo.yml +++ b/.github/workflows/update-repo.yml @@ -14,13 +14,13 @@ jobs: with: latest: true fileName: "*.rpm" - out-file-path: "output/RPMS/x86_64/" + out-file-path: "/output/" - name: Update repo run: | mkdir /tmp/repo - docker run -t -v "$PWD":/repo -v "/tmp/repo":/tmp/repo fedora:38 /bin/bash -c "/repo/build-repo.sh" - cp -r /tmp/repo ./deploy + docker run -t -v /output:/output -v /rpm-repo:/rpm-repo fedora:38 /bin/bash -c "/repo/build-repo.sh" + cp -r /rpm-repo ./deploy - name: Upload uses: netlify/actions/cli@master diff --git a/build-packages.sh b/build-packages.sh index b80dc30..b9ea4c3 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "=====INSTALLING DEPENDENCIES=====" -dnf install -y --quiet koji fedora-packager git curl pesign rpmdevtools rpm-sign rpm-build +dnf install -y --quiet koji git curl pesign rpmdevtools rpm-sign rpm-build mock echo "=====IMPORTING KEYS=====" gpg --import /repo/rpm_signing_key @@ -9,13 +9,13 @@ rm -rfv /repo/rpm_signing_key echo -e "%_signature gpg\n%_gpg_name T2Linux Fedora" > ~/.rpmmacros echo "=====BUILDING=====" -rpmdev-setuptree +mkdir -p /output /repo/scripts/t2linux-fedora.sh /repo/scripts/kernel.sh -rpm --addsign /root/rpmbuild/RPMS/x86_64/*.rpm +rpm --addsign /output/*.rpm # Copy artifacts to shared volume cd "/repo" mkdir -p ./output mkdir -p ./output/RPMS -cp -rfv /root/rpmbuild/RPMS/* ./output/RPMS/ +cp -rfv /output/* ./output/RPMS/ diff --git a/build-repo.sh b/build-repo.sh index 271b859..5e6e26b 100755 --- a/build-repo.sh +++ b/build-repo.sh @@ -1,5 +1,5 @@ dnf install -y --quiet createrepo -mkdir -p /tmp/repo -cd /tmp/repo -cp /repo/output/RPMS/*/*.rpm . +mkdir -p /rpm-repo +cd /rpm-repo +cp /output/*.rpm . createrepo . diff --git a/scripts/build-rpm-from-repo.sh b/scripts/build-rpm-from-repo.sh index 047e131..b581f18 100755 --- a/scripts/build-rpm-from-repo.sh +++ b/scripts/build-rpm-from-repo.sh @@ -20,18 +20,13 @@ if [ -n "$KOJI_VERSION" ]; then mkdir -p /tmp/koji-download && cd /tmp/koji-download koji download-build --arch=src "$KOJI_VERSION" rpmdev-extract "$KOJI_VERSION".src.rpm - mv -f "$KOJI_VERSION".src/"$PACKAGE_NAME".spec /root/rpmbuild/SPECS/ - mv "$KOJI_VERSION".src/* /root/rpmbuild/SOURCES/ -fi - -echo "=====PREPARING SOURCES=====" -cp -f "$BASE_DIR"/"$PACKAGE_NAME"/*.spec /root/rpmbuild/SPECS/ -cp -fr "$BASE_DIR"/"$PACKAGE_NAME"/* /root/rpmbuild/SOURCES/ -echo "=====INSTALLING DEPENDENCIES=====" -cd /root/rpmbuild/SPECS/ -dnf -y --quiet builddep "$PACKAGE_NAME".spec + mkdir -p "$BASE_DIR"/"$PACKAGE_NAME" + mv -n "$KOJI_VERSION".src/* "$BASE_DIR"/"$PACKAGE_NAME" +fi -echo "=====BUILDING PACKAGE=====" -cd /root/rpmbuild/SPECS/ -rpmbuild -bb "$PACKAGE_NAME".spec +cd $BASE_DIR/$PACKAGE_NAME +spectool -g ./$PACKAGE_NAME.spec +mock --buildsrpm --spec ./$PACKAGE_NAME.spec --sources . --resultdir ./_mock +mock --rebuild ./_mock/*.src.rpm --resultdir ./_mock +cp ./_mock/*.rpm /output \ No newline at end of file diff --git a/scripts/kernel.sh b/scripts/kernel.sh index d427bfe..be3ffa3 100755 --- a/scripts/kernel.sh +++ b/scripts/kernel.sh @@ -5,7 +5,7 @@ PATCHES_GIT=https://github.com/t2linux/linux-t2-patches PATCHES_COMMIT=3a43f2fa1c4afec28f1bffe2aa13e3f4366ecce1 echo "=====INSTALLING DEPENDENCIES=====" -dnf install -y --quiet ncurses-devel libbpf fedpkg rpmdevtools ccache openssl-devel libkcapi libkcapi-devel libkcapi-static libkcapi-tools +dnf install -y --quiet ncurses-devel libbpf fedpkg ccache openssl-devel libkcapi libkcapi-devel libkcapi-static libkcapi-tools cd "/root/rpmbuild"/SPECS @@ -16,17 +16,16 @@ koji download-build --arch=src kernel-${FEDORA_KERNEL_VERSION} echo "=====EXTRACTING SOURCES=====" rpmdev-extract kernel-${FEDORA_KERNEL_VERSION}.src.rpm -mv kernel-*.src/kernel.spec /root/rpmbuild/SPECS/ -cp -r kernel-*.src/* /root/rpmbuild/SOURCES/ +mkdir -p /kernel-build +mv -n kernel-*.src/* /kernel-build echo "=====PREPARING SOURCES====" -cd /root/rpmbuild/SPECS +cd /kernel-build # Fedora devs are against merging kernel-local for all architectures when keys are not properly specified, so we have to patch it in. sed -i "s@for i in %{all_arch_configs}@for i in *.config@g" kernel.spec sed -i 's/# define buildid .local/%define buildid .t2/g' kernel.spec # sed -i 's/%define specrelease 200%{?buildid}%{?dist}/%define specrelease 202%{?buildid}%{?dist}/' kernel.spec # sed -i 's/%define pkgrelease 200/%define pkgrelease 202/' kernel.spec -dnf -y --quiet builddep kernel.spec echo "======DOWNLOADING PATCHES=====" rm -rf /tmp/download /tmp/src @@ -35,11 +34,12 @@ git clone --single-branch --branch main ${PATCHES_GIT} cd * git checkout ${PATCHES_COMMIT} -cd ~/rpmbuild/SPECS -# cat /tmp/download/*/extra_config > /root/rpmbuild/SOURCES/kernel-local -cat /tmp/download/*/extra_config > /root/rpmbuild/SOURCES/kernel-local -cat /tmp/download/*/*.patch > /root/rpmbuild/SOURCES/linux-kernel-test.patch +cd /kernel-build +cat /tmp/download/*/extra_config > kernel-local +cat /tmp/download/*/*.patch > linux-kernel-test.patch echo "=====BUILDING=====" -cd /root/rpmbuild/SPECS -rpmbuild -bb --target=x86_64 .//kernel.spec +cd /kernel-build +mock --buildsrpm --spec ./kernel.spec --sources . --resultdir ./_mock +mock --rebuild ./_mock/*.src.rpm --resultdir ./_mock +cp ./_mock/*.rpm /output \ No newline at end of file