Leave a comment

Gentoo Scripts… as promised.

coreutils and mktemp a dangerous pairHas a bit of a Yogi Bear thing, don’t ya think?

coreutils and mktemp a dangerous pair

I tried to sleep a few nights back and my ears just wouldn’t leave me alone, so I thought lets boot my computer and see if there is anything still useful on it. So I began to look through my ~/.bin/ directory and dug up a few things. I’ll post a few of these in the next few days..

Gentoo scripts

I’m not a typical Gentooee where: while, if, and C daemons are popular but I have a couple hat tricks that did what I needed them to do.

Archive and Delete

This computer has a 5GB hard drive for which is about the bare min to run a Linux desktop with (even trickier with Portage). So often I try a program and say, “Ok, I can use that but I won’t be very often.” So this script I made to archive the package and back it up to my flash drive:

archive-wipe

#!/bin/bash
# archive-wipe - create archive of package and remove from system

PACKAGE=$1
#ARCHIVEDPACKAGECHECK=/media/disk/portage-packages/All/${PACKAGE.*}
#ARCHIVEDPACKAGENAME=${ls /media/disk/portage-packages/All | grep $PACKAGE}
# -CAT/PACAGE

if [[ -z $PACKAGE ]]; then
    echo "archive-wipe "
    exit;
fi

# Gnome volume manager will at times put the drive on disk-[1-10]
if grep "/dev/uba1.*/media/disk-.*" /etc/mtab; then
    echo " * Drive mounted incorrectly.  Exiting."
    exit; else
    echo " * Archiving $PACKAGE"
    sudo quickpkg --include-config=y "$PACKAGE" && echo " * '$PACKAGE' archived, unmerging from portage." && sudo emerge -C "$PACKAGE"
#    if [ -z ARCHIVEDPACKAGECHECK ]; then
#    if "$ARCHIVEDPACKAGEDNAME"; then
#    if ls /media/disk/portage-packages/All | grep "$PACKAGE"; then
#    if [ -z "/media/disk/portage-package/All/${PACKAGE%.*}" ]; then
#        echo " * '$ARCHIVEDPACKAGENAME' archived, unmerging from portage."
#        echo " *** "$PACKAGE" has not been archived.  Exiting"
#        exit;
#    fi
fi

ebuild2overlay

I’ve wrote before about ebuild2overlay. I find myself using this quite a bit. When a program I need/want isnt’ in Portage, someone if often good enough to have written an ebuild for in and put it in Gentoo’s Bugzilla.

I’ve made a few small updates to the script and updated the post.

For any that change of modify this script, please let me know about it. I also would enjoy hearing any thoughts.

unblock-package

This one I got from the Gentoo wiki and it altered slightly it use quickpkg so the blocker doesn’t have to be recompiled:

#!/bin/bash

BLOCKER=$1
BLOCKED=$2

if [[ -z $BLOCKED ]]; then
    echo " unblock-package  "
    echo " * Use category/package."
    exit;
fi

#sudo emerge --buildpkgonly --nodeps $BLOCKED && i
sudo quickpkg $BLOCKER && sudo emerge -C $BLOCKER && sudo emerge -K --nodeps $BLOCKED

# Possible?
# emerge --resume

gentoo-update

This is my Gentoo update world script. It asks if it should start with a pretend emerge, emerges, revdep-rebuilds, and dep-cleans. I’ve seen a better one on the forums but I was never able to find it again.

#!/bin/bash
# gentoo-update - world update and configure

TXT_YL="tput setaf 3" #
TXT_RESET="tput sgr0"

sleep 1 && echo " * Gentoo world update starting."
sleep 2 && echo " * Does the Portage tree need updated? (y/N)"

read SYNCPORTAGE

if [ "$SYNCPORTAGE" == y ]; then
    sleep 2
    echo " * Please wait and as the Portage tree is updated."
    sudo eix-sync && sudo pmaint sync
    sleep 2 && echo " * Portage tree updated."
fi

sleep 1 && echo " * Standard or tree view to display pretend information? (s/t/Neither)"

read PRETEND


if [ $PRETEND == s ]; then
    sleep 2 && echo " * Running pretend infomation."
    sleep 2 && echo " * This can take awhile, please be patient."
    emerge --update --newuse --deep -pv --color y world | less -R
    #pmerge --upgrade --deep --pretend --set world | less -R
    sleep 2 && echo " * Review the infomation, if anything needs changed now's the time to do it."
fi

if [ $PRETEND == t ]; then
    sleep 2 && echo " * Running pretend infomation."
    sleep 2 && echo " * This can take awhile, please be patient."
    sleep 2 && echo " * Review the infomation, if anything needs changed now's the time to do it."
#    emerge --update --newuse --deep --tree -pv --color y world | less -R
    emerge --update --newuse --deep --tree -pv --color y world | ansi2html > /tmp/gentoo-update-tree.html
    epiphany --new-tab /tmp/gentoo-update-tree.html
fi

sleep 1
echo " * Update Gentoo? (y/N)"
read UPDATEGENTOO

if [ "$UPDATEGENTOO" == y ];then
#    sudo pmerge --upgrade --deep --set world &&
    sudo emerge --update --newuse --deep world && sudo dispatch-conf && sudo emerge --depclean && sudo revdep-rebuild -pv; else
    exit
fi
About these ads

About Gen2ly

<3's linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 51 other followers

%d bloggers like this: