github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/builders/rpm/entrypoint.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  # Setup PGP
     6  echo "${PGP_KEY_PASSWORD}" | base64 -d >'/tmp/pgp-pass'
     7  mkdir -p "${HOME}/.gnupg"
     8  cat >"${HOME}/.gnupg/gpg.conf" <<EOT
     9  yes
    10  passphrase-file /tmp/pgp-pass
    11  pinentry-mode loopback
    12  EOT
    13  
    14  echo "${PGP_KEY}" | base64 -d >'/tmp/private.pgp'
    15  gpg --import /tmp/private.pgp
    16  
    17  # Prepare build environment
    18  export BASEDIR="${PWD}/${GOMAIN}"
    19  
    20  echo "%_signature gpg
    21  %_gpg_name $(echo ${PGP_KEY_ID} | base64 -d)" >"${HOME}/.rpmmacros"
    22  
    23  # Build tarball and source package
    24  export PACKAGE="${APP_ID}-${PACKAGE_VERSION}"
    25  export SUFFIX="${BRANCH_TIMESTAMP_UNIX}.${PACKAGE_SUFFIX}"
    26  export SPEC="${BASEDIR}/${APP_ID}.spec"
    27  
    28  # See https://github.com/pojntfx/bagop/blob/main/main.go#L45
    29  export DEBARCH="${ARCHITECTURE}"
    30  if [ "${ARCHITECTURE}" = "386" ]; then
    31      export DEBARCH="i686"
    32  elif [ "${ARCHITECTURE}" = "amd64" ]; then
    33      export DEBARCH="x86_64"
    34  elif [ "${ARCHITECTURE}" = "arm" ]; then
    35      export DEBARCH="armv7l"
    36  elif [ "${ARCHITECTURE}" = "arm64" ]; then
    37      export DEBARCH="aarch64"
    38  fi
    39  
    40  rpmdev-setuptree
    41  
    42  export TARBALL="${HOME}/rpmbuild/SOURCES/${PACKAGE}.tar.gz"
    43  export DSC="${HOME}/rpmbuild/SRPMS/${PACKAGE}-${SUFFIX}.src.rpm"
    44  
    45  tar -cvzf "${TARBALL}" --exclude out --transform "s,^,${PACKAGE}/," .
    46  rpmbuild -bs "${SPEC}"
    47  
    48  rpmlint "${DSC}"
    49  
    50  # Build chroot
    51  mock -r "${DISTRO}-${DEBARCH}" "${DSC}" --enable-network
    52  
    53  rpmlint "/var/lib/mock/${DISTRO}-${DEBARCH}/result/*.rpm"
    54  
    55  mkdir -p '/hydrapp/dst'
    56  cp "/var/lib/mock/${DISTRO}-${DEBARCH}/result/"*.rpm '/hydrapp/dst'
    57  
    58  rpm --addsign '/hydrapp/dst'/*.rpm
    59  
    60  createrepo '/hydrapp/dst'
    61  
    62  gpg --detach-sign --armor "/hydrapp/dst/repodata/repomd.xml"
    63  
    64  gpg --output "/hydrapp/dst/repodata/repo.asc" --armor --export
    65  
    66  # Add repo file
    67  echo "[hydrapp-repo]
    68  name=hydrapp YUM repo
    69  baseurl=${BASE_URL}
    70  enabled=1
    71  gpgcheck=1
    72  gpgkey=${BASE_URL}/repodata/repo.asc" >"/hydrapp/dst/repodata/hydrapp.repo"
    73  
    74  if [ "${DST_UID}" != "" ] && [ "${DST_GID}" != "" ]; then
    75      chown -R "${DST_UID}:${DST_GID}" /hydrapp/dst
    76  fi