mmornati / docker-mock-rpmbuilder

Build RPMs using the Mock Project (for any platform)
GNU General Public License v2.0
62 stars 42 forks source link

Shellcheck & Lint & make Gitlab Cache friendly #23

Closed k0ste closed 1 year ago

k0ste commented 1 year ago

Hi, the dockerhub latest image just doesn't works at 2023 I was invested time to shellcheck the build script & remove volume binds

Some changes come from #22, but without spectool. spectool doesn't exit with non-zero exit code when Source impossible to download or another sort of error, see BZ#2096624, it was replaced to rpmbuild

When source files failed to download, for example due HTTP 403 or 404 code, error will be produced:

WARNING: Disabling clean up of the build folder after build
=> Building parameters:
=================================================================
      MOCK_CONFIG:   centos-stream-8-aarch64
      SPEC_FILE:     sst.spec
      SOURCES:       Will be downloaded automatically
      OUTPUT_FOLDER: /rpmbuild/output/centos-stream-8-aarch64
      MOCK_DEFINES:
=================================================================
warning: Downloading https://downloadmirror.intel.com/743764/SST_CLI_Linux_1.3.zip to /home/mockbuilder/rpmbuild/SOURCES/SST_CLI_Linux_1.3.zip
curl: (22) The requested URL returned error: 403
error: Couldn't download https://downloadmirror.intel.com/743764/SST_CLI_Linux_1.3.zip

When download is successful, mock build will starts as usual:

WARNING: Disabling clean up of the build folder after build
=> Building parameters:
=================================================================
      MOCK_CONFIG:   centos-stream-8-aarch64
      SPEC_FILE:     sst.spec
      SOURCES:       sources
      OUTPUT_FOLDER: /rpmbuild/output/centos-stream-8-aarch64
      MOCK_DEFINES:
=================================================================
warning: Downloading https://sdmsdfwdriver.blob.core.windows.net/files/kba-gcc/drivers-downloads/ka-00085--sst/sst--1-5/sst-cli-linux-rpm--1-5.zip to /rpmbuild/sources/sst-cli-linux-rpm--1-5.zip

RPM build warnings:
    Downloading https://sdmsdfwdriver.blob.core.windows.net/files/kba-gcc/drivers-downloads/ka-00085--sst/sst--1-5/sst-cli-linux-rpm--1-5.zip to /rpmbuild/sources/sst-cli-linux-rpm--1-5.zip
INFO: mock.py version 3.5 starting (python version = 3.11.1, NVR = mock-3.5-1.fc37)...
Start(bootstrap): init plugins
INFO: selinux disabled
Finish(bootstrap): init plugins
Start: init plugins
INFO: selinux disabled
Finish: init plugins
INFO: Signal handler active
Start: run
INFO: Start(/rpmbuild/sst.spec)  Config(centos-stream-8-aarch64)

Verified the docker build & Gitlab runner can works with this image

√ docker-mock-rpmbuilder % docker build -t mock .
[+] Building 87.4s (12/12) FINISHED
 => [internal] load build definition from Dockerfile                                                                                    0.0s
 => => transferring dockerfile: 755B                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                       0.0s
 => => transferring context: 2B                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/fedora:latest                                                                        2.8s
 => CACHED [1/7] FROM docker.io/library/fedora:latest@sha256:3487c98481d1bba7e769cf7bcecd6343c2d383fdd6bed34ec541b6b23ef07664           0.0s
 => [internal] load build context                                                                                                       0.0s
 => => transferring context: 4.93kB                                                                                                     0.0s
 => [2/7] RUN dnf -y --setopt="tsflags=nodocs" update &&     dnf -y --setopt="tsflags=nodocs" install rpmdevtools mock rpm-sign     e  82.9s
 => [3/7] RUN useradd mockbuilder &&     usermod -a -G mock mockbuilder &&     chmod g+w /etc/mock/*.cfg                                0.5s
 => [4/7] COPY ./build-rpm.sh /build-rpm.sh                                                                                             0.0s
 => [5/7] RUN chmod +x /build-rpm.sh                                                                                                    0.1s
 => [6/7] COPY ./rpm-sign.exp /rpm-sign.exp                                                                                             0.0s
 => [7/7] RUN chmod +x /rpm-sign.exp                                                                                                    0.2s
 => exporting to image                                                                                                                  0.9s
 => => exporting layers                                                                                                                 0.9s
 => => writing image sha256:e159b85f65ab74a077a5d1e56dcb6333c7daa7faea12e7599a98540a425d09a3                                            0.0s
 => => naming to docker.io/library/mock                                                                                                 0.0s