initial addition of gentoo-helpers

This commit is contained in:
Tobias Klaus 2017-11-09 00:11:56 +01:00
commit 2229e253e1
No known key found for this signature in database
GPG key ID: E490E43F6C363F6C
7 changed files with 254 additions and 0 deletions

31
buildCurrentSymlinkedKernel.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
if [ ! -f /usr/src/linux/.config ] && [ -f /proc/config.gz ] ; then
echo "**************** building kernel ***********"
LWD="$PWD"
TIMESTAMP=$(date +%F-%H_%M_%S)
cd /usr/src/linux || exit 1
zcat /proc/config.gz > .config
make olddefconfig
mount /boot
(make -j5 CC="ccache gcc" && make install && make modules_install && make firmware_install) > "buildlog-$TIMESTAMP" || tail -n 20 "buildlog-$TIMESTAMP"
GRUBMKONFIG="$(which grub2-mkconfig)"
if [[ -z "$GRUBMKONFIG" ]] ; then
GRUBMKONFIG="$(which grub-mkconfig)"
fi
if [[ -f /boot/grub2/grub.cfg && -n "$GRUBMKONFIG" ]] ; then
"$GRUBMKONFIG" -o /boot/grub2/grub.cfg
elif [[ -f /boot/grub/grub.cfg && -n "$GRUBMKONFIG" ]] ; then
"$GRUBMKONFIG" -o /boot/grub/grub.cfg
else
echo "please update bootloader manually!"
fi
cd "${LWD}" || exit 1
fi

28
buildUpgradePackages.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
PKGDIR="/usr/portage/packages"
for atom in $(emerge -uDN --pretend --quiet world | grep ^'\[ebuild' | sed -e 's/.* \b\([a-z0-9\-]\+\/[\_A-Za-z\.0-9\-]\+\)\b.*/\1/g');
do
if [[ ! -f "$PKGDIR/$atom.tbz2" ]]
then
#build one by one. This takes more time, however it builds all possible packages.
echo "building $atom "
emerge --quiet --keep-going -B "=${atom}" >> /dev/null
if [[ $? ]]
then
SUCCESS="$atom $SUCCESS"
else
FAILURE="$atom $FAILURE"
fi
fi
done
if [[ -n "${SUCCESS}" ]]
then
echo "Successfully build: ${SUCCESS}"
fi
if [[ -n "${FAILURE}" ]]
then
echo "Build Failures: ${FAILURE}"
fi

94
gentooup.sh Executable file
View file

@ -0,0 +1,94 @@
#!/bin/bash
PORTAGE_OPTIONS=("--keep-going" "--autounmask-write" "--binpkg-respect-use=y" "--binpkg-changed-deps=y" "--verbose-conflicts")
PORTAGE_UPGRADE_OPTIONS=("-vuNDk")
PORTAGE_ASK="-a"
SYNC_COMMAND="emaint sync -a"
int_handler() {
exit 0
}
trap int_handler INT TERM EXIT
STARTDATE="$(date -Iseconds)"
if [[ -x /etc/cron.daily/porticron ]] ; then
echo "porticron"
PORTAGE_ASK=""
fi
if [[ ${1} == "--no-sync" || ${2} == "--no-sync" ]] ; then
echo "not syncing"
SYNC_COMMAND=""
fi
if [[ ${1} == "--full" || ${2} == "--full" ]] ; then
echo "Do a full upgrade including build dependencies"
PORTAGE_UPGRADE_OPTIONS+=("--with-bdeps=y")
fi
#any parameter prevents syncing
if [[ ! -z ${SYNC_COMMAND} ]] ; then
${SYNC_COMMAND}
eix-update >& /dev/null &
fi
echo "emerge options: ${PORTAGE_OPTIONS[*]}"
emerge $PORTAGE_ASK "${PORTAGE_UPGRADE_OPTIONS[@]}" "${PORTAGE_OPTIONS[@]}" world
echo "emerge return value: $?"
dispatch-conf
echo "dispatch-conf return value: $?"
emerge "${PORTAGE_UPGRADE_OPTIONS[@]}" "${PORTAGE_OPTIONS[@]}" world
echo emerge return value: $?
dispatch-conf
echo dispatch-conf return value: $?
SETS=("@preserved-rebuild")
if eix -eI smart-live-rebuild &> /dev/null ; then
SETS+=("@smart-live-rebuild")
fi
echo "Started at $STARTDATE"
echo "***************** rebuild packages *******************"
echo "run emerge -v ${PORTAGE_OPTIONS[*]} ${SETS[*]}"
emerge -v "${PORTAGE_OPTIONS[@]}" "${SETS[@]}"
if [[ -n "$(which webappup.sh 2> /dev/null)" ]] ; then
webappup.sh
elif [[ -x "${HOME}/bin/webappup.sh" ]] ; then
"${HOME}/bin/webappup.sh"
fi
echo "**************** clean /etc/portage/ ***************"
portpeek -rq
echo "**************** clean /usr/portage/distfiles ***********"
eclean-dist -d
echo "**************** clean /usr/portage/packages ***********"
eclean-pkg
if [[ -n "$(which buildCurrentSymlinkedKernel.sh 2> /dev/null)" ]] ; then
buildCurrentSymlinkedKernel.sh
elif [[ -x "${HOME}/bin/buildCurrentSymlinkedKernel.sh" ]] ; then
"${HOME}/bin/buildCurrentSymlinkedKernel.sh"
fi
echo "***************** remove unneeded packages *******************"
echo Started at "$STARTDATE"
emerge -a "${PORTAGE_OPTIONS[@]}" --depclean
if [[ -n "$(which restart_services)" ]] ; then
restart_services -l
fi
echo "Started at $STARTDATE"
echo " Ended at $(date -Iseconds)"

15
globalflaggieLocalUse.sh Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
for FLAG in "$@" ; do
FLAGMATCH=${FLAG/#+/}
FLAGMATCH=${FLAGMATCH/#-/}
FLAGMATCH=${FLAGMATCH/#%/}
for atom in $(eix -# --use "$FLAGMATCH") ; do
echo "$atom $FLAG"
flaggie "$atom" "$FLAG"
done
done

10
mountVirtualFS.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
NEWBASE="$1"
mount --rbind /dev "$NEWBASE/dev"
mount --rbind /sys "$NEWBASE/sys"
mount --bind /usr/portage "$NEWBASE/usr/portage/"
mount -t proc none "$NEWBASE/proc"
cp /etc/resolv.conf "$NEWBASE/etc/"

45
webappup.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/bash
if [[ -n "$(which webapp-config)" ]] ; then
echo "***************** upgrading webapps *******************"
for webapp in $(ls /var/db/webapps/ ) ; do
#we assume a clean system where only ONE app is freshly available and this one app is newer than the currently installed
available_app=$(webapp-config --list-unused-installs | grep $webapp)
if [[ -z "$available_app" ]] ; then
continue
fi
new_version=$(echo $available_app|sed -e "s/^${webapp}-\(.*\)$/\1/")
echo updates for ${webapp}!
echo new version: $new_version
for install in $(webapp-config --list-installs $webapp) ; do
host=$(echo $install | cut -d / -f 4)
webdir=$(echo $install | cut -d / -f 6-)
if [[ -z $webdir ]] ; then
webdir=""
dirflag="--dir /"
else
dirflag="--dir $webdir"
fi
infostring=$(webapp-config --host $host $dirflag --show-installed)
echo $infostring
webapp_version=$(echo $infostring | cut -d\ -f2)
webapp_test=$(echo $infostring | cut -d\ -f1)
if [[ -d /var/www/$host/htdocs/$webdir ]] ; then
COMMAND="webapp-config --secure --host $host $dirflag -U $webapp $new_version"
echo upgrade $webapp from $webapp_version to $new_version in $host/$webdir ? type yes to continue, anything else will abort
echo the command in question:
echo $COMMAND
read ANSWEAR
if [[ $ANSWEAR == "yes" ]] ; then
$COMMAND
## CONFIG_PROTECT="/var/www/$host/htdocs/$webdir/" dispatch-conf
fi
fi
done
done
fi

31
wherefrom.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
INSTALLED_SETS="$(cut -d\@ -f2 < /var/lib/portage/world_sets)"
echo installed sets: $INSTALLED_SETS
DEFAULT_LOCATION="/etc/portage/sets/"
SET_LOCATIONS="$(grep location -rh /etc/portage/repos.conf | sed -e "s/location = \(.*\)$/\1\/sets/") $DEFAULT_LOCATION"
#echo all setlocations: $SET_LOCATIONS
for location in $SET_LOCATIONS ; do
if [[ ! -d $location ]] ; then continue ; fi
for setlocation in $location/* ; do
# echo testing $setlocation
setname=$(basename $setlocation)
if echo $INSTALLED_SETS | grep -qw $setname ; then
echo installed: $setlocation
INSTALLEDSETLOCATION="${INSTALLEDSETLOCATION} ${setlocation}"
fi
done
done
INSTALLEDSETLOCATION="${INSTALLEDSETLOCATION} /var/lib/portage/world"
echo installed setfiles: $INSTALLEDSETLOCATION
echo
echo
for SET in $INSTALLEDSETLOCATION ; do
#echo looking for $1 in $SET
grep -H $1 $SET | grep -v ":#"
done