2010-09-17 13:40:17 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-07-25 13:23:32 +02:00
|
|
|
/usr/sbin/env-update
|
|
|
|
. /etc/profile
|
2010-09-17 13:40:17 +02:00
|
|
|
|
|
|
|
# Setup environment vars
|
|
|
|
export ETP_NONINTERACTIVE=1
|
|
|
|
if [ -d "/usr/portage/licenses" ]; then
|
|
|
|
export ACCEPT_LICENSE="$(ls /usr/portage/licenses -1 | xargs)"
|
|
|
|
fi
|
|
|
|
|
2012-10-15 21:25:05 +02:00
|
|
|
safe_run() {
|
|
|
|
local updated=0
|
|
|
|
for ((i=0; i < 42; i++)); do
|
|
|
|
"${@}" && {
|
|
|
|
updated=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if [ ${i} -gt 6 ]; then
|
|
|
|
sleep 3600 || return 1
|
|
|
|
else
|
|
|
|
sleep 1200 || return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ "${updated}" = "0" ]; then
|
|
|
|
return 1
|
2012-10-10 00:16:29 +02:00
|
|
|
fi
|
2012-10-15 21:25:05 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
export FORCE_EAPI=2
|
|
|
|
safe_run equo update || exit 1
|
2012-09-14 08:19:14 +02:00
|
|
|
|
|
|
|
export ETP_NOINTERACTIVE=1
|
2012-10-15 21:25:05 +02:00
|
|
|
safe_run equo upgrade --fetch || exit 1
|
2010-09-17 13:40:17 +02:00
|
|
|
equo upgrade || exit 1
|
|
|
|
echo "-5" | equo conf update
|
2012-10-15 21:38:35 +02:00
|
|
|
|
|
|
|
# check if a kernel update is needed
|
2012-10-30 20:32:39 +01:00
|
|
|
kernel_target_pkg="$(equo match -q --installed virtual/linux-binary)"
|
2012-10-15 21:38:35 +02:00
|
|
|
current_kernel=$(equo match --installed "${kernel_target_pkg}" -qv)
|
|
|
|
available_kernel=$(equo match "${kernel_target_pkg}" -qv)
|
|
|
|
if [ "${current_kernel}" != "${available_kernel}" ] && \
|
|
|
|
[ -n "${available_kernel}" ] && [ -n "${current_kernel}" ]; then
|
|
|
|
echo
|
|
|
|
echo "@@ Upgrading kernel to ${available_kernel}"
|
|
|
|
echo
|
|
|
|
safe_run kernel-switcher switch "${available_kernel}" || exit 1
|
|
|
|
equo remove "${current_kernel}" || exit 1
|
|
|
|
# now delete stale files in /lib/modules
|
|
|
|
for slink in $(find /lib/modules/ -type l); do
|
|
|
|
if [ ! -e "${slink}" ]; then
|
|
|
|
echo "Removing broken symlink: ${slink}"
|
|
|
|
rm "${slink}" # ignore failure, best effort
|
|
|
|
# check if parent dir is empty, in case, remove
|
|
|
|
paren_slink=$(dirname "${slink}")
|
|
|
|
paren_children=$(find "${paren_slink}")
|
|
|
|
if [ -z "${paren_children}" ]; then
|
|
|
|
echo "${paren_slink} is empty, removing"
|
2012-10-17 15:11:56 +02:00
|
|
|
rmdir "${paren_slink}" # ignore failure, best effort
|
2012-10-15 21:38:35 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "@@ Not upgrading kernels:"
|
|
|
|
echo "Current: ${current_kernel}"
|
|
|
|
echo "Avail: ${available_kernel}"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2010-09-17 13:40:17 +02:00
|
|
|
rm -rf /var/lib/entropy/client/packages
|
|
|
|
|
2012-05-17 23:24:13 +02:00
|
|
|
# copy Portage config from sabayonlinux.org entropy repo to system
|
|
|
|
for conf in package.mask package.unmask package.keywords make.conf package.use; do
|
|
|
|
repo_path=/var/lib/entropy/client/database/*/sabayonlinux.org/standard
|
|
|
|
repo_conf=$(ls -1 ${repo_path}/*/*/${conf} | sort | tail -n 1 2>/dev/null)
|
|
|
|
if [ -n "${repo_conf}" ]; then
|
|
|
|
target_path="/etc/portage/${conf}"
|
|
|
|
if [ "${conf}" = "make.conf" ]; then
|
|
|
|
target_path="/etc/make.conf"
|
|
|
|
fi
|
|
|
|
if [ ! -d "${target_path}" ]; then # do not touch dirs
|
|
|
|
cp "${repo_conf}" "${target_path}" # ignore
|
|
|
|
fi
|
2010-09-18 12:59:29 +02:00
|
|
|
fi
|
2012-05-17 23:24:13 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# split config file
|
|
|
|
for conf in 00-sabayon.package.use; do
|
|
|
|
repo_path=/var/lib/entropy/client/database/*/sabayonlinux.org/standard
|
|
|
|
repo_conf=$(ls -1 ${repo_path}/*/*/${conf} | sort | tail -n 1 2>/dev/null)
|
|
|
|
if [ -n "${repo_conf}" ]; then
|
|
|
|
target_path="/etc/portage/${conf/00-sabayon.}/${conf}"
|
|
|
|
target_dir=$(dirname "${target_path}")
|
|
|
|
if [ -f "${target_dir}" ]; then # remove old file
|
|
|
|
rm "${target_dir}" # ignore failure
|
|
|
|
fi
|
|
|
|
if [ ! -d "${target_path}" ]; then
|
|
|
|
mkdir -p "${target_path}" # ignore failure
|
|
|
|
fi
|
|
|
|
cp "${repo_conf}" "${target_path}" # ignore
|
2010-09-18 12:59:29 +02:00
|
|
|
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-09-17 13:40:17 +02:00
|
|
|
equo query list installed -qv > /etc/sabayon-pkglist
|