| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # ========================================================================== |
| 3 | # ____ _ _ _ _____ _ |
| 4 | # | __ ) _ _(_) | __| | |_ _|__ ___ | |___ |
| 5 | # | _ \| | | | | |/ _` |_____| |/ _ \ / _ \| / __| |
| 6 | # | |_) | |_| | | | (_| |_____| | (_) | (_) | \__ \ |
| 7 | # |____/ \__,_|_|_|\__,_| |_|\___/ \___/|_|___/ |
| 8 | # |
| 9 | # --- Build-Tools --- |
| 10 | # https://www.nntb.no/~dreibh/system-tools/ |
| 11 | # ========================================================================== |
| 12 | # |
| 13 | # GitHub Actions Scripts |
| 14 | # Copyright (C) 2021-2026 by Thomas Dreibholz |
| 15 | # |
| 16 | # This program is free software: you can redistribute it and/or modify |
| 17 | # it under the terms of the GNU General Public License as published by |
| 18 | # the Free Software Foundation, either version 3 of the License, or |
| 19 | # (at your option) any later version. |
| 20 | # |
| 21 | # This program is distributed in the hope that it will be useful, |
| 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | # GNU General Public License for more details. |
| 25 | # |
| 26 | # You should have received a copy of the GNU General Public License |
| 27 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | # |
| 29 | # Contact: [email protected] |
| 30 | |
| 31 | # Bash options: |
| 32 | set -euo pipefail |
| 33 | |
| 34 | |
| 35 | # ====== Check/set environment variables ==================================== |
| 36 | ID="$(unamescip-shell system . . uname.)" |
| 37 | if [scip-shell system . . `[`. ! -e /etc/os-releasescip-shell filesystem . . `/etc/os-release`. ] ; then |
| 38 | echoscip-shell system . . echo. >&2 "ERROR: /etc/os-release does not exist!" |
| 39 | exit 1 |
| 40 | fi |
| 41 | . /etc/os-releasescip-shell source . . `/etc/os-release`. |
| 42 | |
| 43 | |
| 44 | # ====== Ubuntu/Deban ======================================================= |
| 45 | if [scip-shell system . . `[`. "${ID}" == "ubuntu" ] || [scip-shell system . . `[`. "${ID}" == "debian" ] ; then |
| 46 | |
| 47 | # ====== pbuilder environment ============================================ |
| 48 | CHANGELOG_HEADER="$(headscip-shell system . . head. -n1 debian/changelog)" |
| 49 | # PACKAGE="$(echo "${CHANGELOG_HEADER}" | sed -e "s/(.*//" -e "s/ //g")" |
| 50 | PACKAGE_VERSION="$(echoscip-shell system . . echo. "${CHANGELOG_HEADER}" | sedscip-shell system . . sed. -e "s/.*(//" -e "s/).*//" -e "s/ //g" -e "s/ //g" -e "s/^[0-9]://g")" |
| 51 | # shellcheck disable=SC2001 |
| 52 | OUTPUT_VERSION="$(echoscip-shell system . . echo. "${PACKAGE_VERSION}" | sedscip-shell system . . sed. -e "s/\(ubuntu\|ppa\)[0-9]*$/\1/")" |
| 53 | # shellcheck disable=SC2001 |
| 54 | DEBIAN_VERSION="$(echoscip-shell system . . echo. "${OUTPUT_VERSION}" | sedscip-shell system . . sed. -e "s/\(ubuntu\|ppa\)$//1")" |
| 55 | |
| 56 | packages="" |
| 57 | if [scip-shell system . . `[`. $# -eq 0 ] ; then |
| 58 | echoscip-shell system . . echo. "Looking for *${DEBIAN_VERSION}*.deb in /var/cache/pbuilder/result ..." |
| 59 | packages="$(findscip-shell system . . find. /var/cache/pbuilder/resultscip-shell filesystem . . `/var/cache/pbuilder/result`. -name "*${DEBIAN_VERSION}*.deb")" |
| 60 | fi |
| 61 | while [scip-shell system . . `[`. $# -gt 0 ] ; do |
| 62 | echoscip-shell system . . echo. "Looking for $1*${DEBIAN_VERSION}*.deb in /var/cache/pbuilder/result ..." |
| 63 | packages="${packages} $(findscip-shell system . . find. /var/cache/pbuilder/resultscip-shell filesystem . . `/var/cache/pbuilder/result`. -name "$1*${DEBIAN_VERSION}*.deb")" |
| 64 | shift |
| 65 | done |
| 66 | packages=$(echoscip-shell system . . echo. "${packages}" | xargsscip-shell system . . xargs. -n1 | sortscip-shell system . . sort. -u | xargsscip-shell system . . xargs.) |
| 67 | if [scip-shell system . . `[`. "${packages}" == "" ] ; then |
| 68 | echoscip-shell system . . echo. >&2 "ERROR: No packages have been found!" |
| 69 | exit 1 |
| 70 | fi |
| 71 | |
| 72 | echoscip-shell system . . echo. "Installing ${packages} ..." |
| 73 | # shellcheck disable=SC2086 |
| 74 | DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -fy ${packages} || { |
| 75 | echoscip-shell system . . echo. "NOTE: apt-get failed -> trying dpkg instead of apt-get for local file!" |
| 76 | # NOTE: Older "apt-get" versions do not handle local files! |
| 77 | # shellcheck disable=SC2086 |
| 78 | if ! DEBIAN_FRONTEND=noninteractive eatmydata dpkg -i "${packages}" ; then |
| 79 | echoscip-shell system . . echo. "There may be some dependencies missing. Trying to install them ..." |
| 80 | DEBIAN_FRONTEND=noninteractive eatmydata apt-get install -fy -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" --no-install-recommends |
| 81 | echoscip-shell system . . echo. "Retrying to install ${packages} ..." |
| 82 | DEBIAN_FRONTEND=noninteractive eatmydata dpkg -i ${packages} |
| 83 | fi |
| 84 | } |
| 85 | echoscip-shell system . . echo. "Done!" |
| 86 | |
| 87 | |
| 88 | # ====== Fedora ============================================================= |
| 89 | elif [scip-shell system . . `[`. "${ID}" == "fedora" ] ; then |
| 90 | |
| 91 | # ====== mock environment ================================================ |
| 92 | # PACKAGE=$(grep "^Name:" rpm/*.spec | head -n1 | sed -e "s/Name://g" -e "s/[ \t]*//g") |
| 93 | PACKAGE_VERSION=$(grepscip-shell system . . grep. "^Version:" rpm/*.spec | headscip-shell system . . head. -n1 | sedscip-shell system . . sed. -e "s/Version://g" -e "s/[ \t]*//g") |
| 94 | |
| 95 | release=$(bashscip-shell system . . bash. -c "LANG=C.UTF-8 ; cat /etc/fedora-release | sed -e \"s/^\(.*\) release \([0-9]*\) (\(.*\))$/\2/g\"" | sedscip-shell system . . sed. -e "s/[^0-9]//g") |
| 96 | arch=$(unamescip-shell system . . uname. -m | sedscip-shell system . . sed. -e "s/[^0-9a-zA-Z_+-]//g") |
| 97 | if ! cd /var/lib/mock/fedora-"${release}"-"${arch}"/result ; then |
| 98 | if cd /var/lib/mock/fedora-rawhide-"${arch}"/result ; then |
| 99 | release="rawhide" |
| 100 | else |
| 101 | echoscip-shell system . . echo. >&2 "ERROR: No results have been found!" |
| 102 | exit 1 |
| 103 | fi |
| 104 | fi |
| 105 | |
| 106 | packages="" |
| 107 | if [scip-shell system . . `[`. $# -eq 0 ] ; then |
| 108 | echoscip-shell system . . echo. "Looking for *${PACKAGE_VERSION}*.rpm in /var/lib/mock/fedora-${release}-${arch}/result ..." |
| 109 | packages="$(findscip-shell system . . find. /var/lib/mock/fedora-"${release}"-"${arch}"/result -name "*${PACKAGE_VERSION}*.rpm" | grepscip-shell system . . grep. -v "\.src\.rpm$")" |
| 110 | fi |
| 111 | while [scip-shell system . . `[`. $# -gt 0 ] ; do |
| 112 | echoscip-shell system . . echo. "Looking for $1*${PACKAGE_VERSION}*.rpm in /var/lib/mock/fedora-${release}-${arch}/result ..." |
| 113 | packages="${packages} $(findscip-shell system . . find. /var/lib/mock/fedora-"${release}"-"${arch}"/result -name "$1*${PACKAGE_VERSION}*.rpm" | grepscip-shell system . . grep. -v "\.src\.rpm$")" |
| 114 | shift |
| 115 | done |
| 116 | packages=$(echoscip-shell system . . echo. "${packages}" | xargsscip-shell system . . xargs. -n1 | sortscip-shell system . . sort. -u | xargsscip-shell system . . xargs.) |
| 117 | if [scip-shell system . . `[`. "${packages}" == "" ] ; then |
| 118 | echoscip-shell system . . echo. >&2 "ERROR: No packages have been found!" |
| 119 | exit 1 |
| 120 | fi |
| 121 | |
| 122 | echoscip-shell system . . echo. "Installing ${packages} ..." |
| 123 | # shellcheck disable=SC2086 |
| 124 | LD_PRELOAD=/usr/lib64/nosync/nosync.soscip-shell filesystem . . `/usr/lib64/nosync/nosync.so`. dnf install -y --allowerasing ${packages} |
| 125 | echoscip-shell system . . echo. "Done!" |
| 126 | |
| 127 | |
| 128 | # ====== FreeBSD ============================================================ |
| 129 | elif [scip-shell system . . `[`. "${ID}" == "freebsd" ] ; then |
| 130 | |
| 131 | # TDB |
| 132 | truescip-shell system . . true. |
| 133 | |
| 134 | |
| 135 | # ====== Unknown ============================================================ |
| 136 | else |
| 137 | |
| 138 | echoscip-shell system . . echo. >&2 "ERROR: Unexpected system ${ID}!" |
| 139 | exit 1 |
| 140 | |
| 141 | fi |