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