All pastes #2019262 Raw Edit

Someone

public text v1 · immutable
#2019262 ·published 2010-12-14 12:03 UTC
rendered paste body
#!/bin/sh## installer of irssi build for solaris 10 on sparc platform## author: dpecka@opensuse.org# packager: bobstone@synack.fi## platform and user checkif [ "`id | perl -pe 's/uid=(\d+).*/$1/'`" -ne "0" ] || [ `uname -s` != "SunOS" ] || [ `uname -p` != "sparc" ]; then    echo you must be a root on Solaris at sparc platform, exitting ..;    exit 1;fi## some functionsusage() {    cat << 'EOF'usage: irssi-for-solaris-sparc.bin [-h] [-b dir] [-t dir] [-x] [-X] [-V file] [-P opts] [-T term] [-U]-h      : prints out this help message-b dir  : a directory where will be irssi.sh placed, default is /usr/bin-t dir  : temporary directory for unpacking files, default is /var/tmp/irssi-installer-x      : don't delete temporary files-X      : quit before installing so no changes will be made-V file : where will be stored a pkgadd/pkgrm log, default is /dev/null-P opts : additional pkgadd opts, default is "-G", refer to pkgadd(1m) manual        : you must enclose opts in "doublequotas"-T term : a $term will be used rather then xterm-color deployed by this installer-U      : uninstall, if you changed where was a irssi.sh placed, you need to add a "-b dir" optionexamples:        irssi-for-solaris-sparc.bin ## just install everything with default settings        irssi-for-solaris-sparc.bin -U -b /foo ## uninstall everything including /foo/irssi.sh        irssi-for-solaris-sparc.bin -t /foo -x -X ## only unpack data archive into /foo and exits        irssi-for-solaris-sparc.bin -b /bin -t /tmp/foo -x -V /tmp/foo/install.log ## install irssi.sh               into /bin, use /tmp/foo for temporary data, won't delete them and save a log as /tmp/foo/install.logbackground:        This installer will do generally 3 things:        - installs additional packages GNUglib, GNUirssi and GNUlibiconv compiled with prefix /opt/gnu        - places a xterm-color terminal file which doesn't suck (like Sun's xtermc) in /usr/share/lib/terminfo/x        - creates a /usr/bin/irssi.sh launcher (default path), which you will use for launching irssiauthors:        dpecka@opensuse.org - this installer        bobstone@synack.fi  - packagerEOF    exit 0;};checkfail() {    echo "$1";    exit $2;};## binary dependency check and creating variables pointing to needed binariestest -x /usr/bin/pkginfo || checkfail "missing or non-executable /usr/sbin/pkginfo binary, aborting .." 1;test -x /usr/sbin/pkgadd || checkfail "missing or non-executable /usr/sbin/pkgadd binary, aborting .." 1;test -x /usr/sbin/pkgrm || checkfail "missing or non-executable /usr/sbin/pkgrm binary, aborting .." 1;test -x /usr/sfw/bin/gtar || checkfail "missing or non-executable /usr/sfw/bin/gtar binary, aborting .." 1;test -x /usr/bin/perl || checkfail "missing or non-executable /usr/bin/perl binary, aborting .." 1;pkginfo=/usr/bin/pkginfo;pkgadd=/usr/sbin/pkgadd;pkgrm=/usr/sbin/pkgrm;gtar=/usr/sfw/bin/gtar;perl=/usr/bin/perl;## assigning other variables, some of them could be changed by passed parametersbin_path=/usr/bin;tmp_path=/var/tmp/irssi-installertmp_del=yes;pretend=no;verbose_logfile=/dev/null;pkgadd_opts="-G";term="xterm-color";uninstall=no;## parsing cli parameters and changing predefined variablesuntil test -z "$1"; do    case "$1" in        -h | --help ) usage;;        -b ) bin_path="$2"; shift;                test -w $bin_path || checkfail "$bin_path doesn't exist or you have no +w permissions there" 1;;        -t ) tmp_path=$2; shift;;        -x ) tmp_del=no;;        -X ) pretend=yes;;        -V ) verbose_logfile="$2"; shift;                test -f $verbose_logfile && checkfail "$verbose_logfile already exists, choose another one, quitting .." 1;;        -P ) pkgadd_opts="$2"; shift;;        -T ) term="$2"; shift;;        -U ) uninstall=yes;;        * ) checkfail "bad parameter: \"$1\", try -h for help" 1;;    esac    shift;done## other varspkg_deps="SUNWbcp SUNWcry SUNWcsl SUNWcslr SUNWcsr SUNWdpl SUNWlibms SUNWlibmsr SUNWopenssl-libraries SUNWperl584core";inst_order="GNUlibiconv GNUglib GNUirssi";uninst_order="GNUirssi GNUglib GNUlibiconv";## and now becomes time for a real work:## uninstalling firstif [ $uninstall = "yes" ]; then    for foo in $uninst_order; do        if $pkginfo $foo 2>/dev/null; then            printf "uninstalling $foo: ";            yes | $pkgrm $foo 2>>$verbose_logfile &            wait; echo done;        else            echo package $foo is not installed. skipping ..;        fi    done    echo    printf "removing $bin_path/irssi.sh: ";    rm "$bin_path/irssi.sh" 2>/dev/null && echo done || echo $bin_path/irssi.sh does not exist, skipping ..;    printf "removing /usr/share/lib/terminfo/x/xterm-color: ";    rm /usr/share/lib/terminfo/x/xterm-color 2>/dev/null;    echo done;    echo    echo all done;    exit 0;fi## first we need to unpack stuff:mkdir "$tmp_path" || checkfail "$tmp_path already exists or cannot be created, choose another one, quitting .." 1;printf "unpacking data in $tmp_path: ";perl -ne 'if(/^### end$/) {$print=1; next}; print if $print' "$0" | $gtar xzvf - -C "$tmp_path" >/dev/nullecho done;## check for a other packages dependenciesprintf "checking for package dependencies: ";if $pkginfo $pkg_deps >/dev/null; then    :; else    echo "\npackage dependency check failed with error message above, aborting ..";    exit 1;fiecho ok; echo;if [ $pretend = "no" ]; then    ## check if packages which will be installed are not already present, let's install them if they are not here already    test -d /opt/gnu || mkdir /opt/gnu;    for foo in $inst_order; do        if $pkginfo $foo 2>/dev/null >/dev/null; then            echo package $foo is already installed;        else            printf "installing package $foo: ";            yes | $pkgadd $pkgadd_opts -d "$tmp_path" $foo 2>>$verbose_logfile >/dev/null || checkfail "failed, see a logfile" 1;            echo done;        fi    done    ## copy xterm-color file into appropriate place    echo    printf "deploying xterm-color: ";    cp "$tmp_path/xterm-color" /usr/share/lib/terminfo/x 2>/dev/null || echo cp \"$tmp_path/xterm-color\" /usr/share/lib/terminfo/x \# failed;    echo done;    ## place on approprite place a irssi.sh launcher    printf "creating launcher as $bin_path/irssi.sh: ";    echo '#!/bin/sh' >$bin_path/irssi.sh;    echo "LD_LIBRARY_PATH=/usr/sfw/lib TERM=$term /opt/gnu/bin/irssi \$@" >>$bin_path/irssi.sh;    chmod +x $bin_path/irssi.sh;    echo done;fi## cleanupif [ $tmp_del = "yes" ]; then    printf "doing cleanup of $tmp_path: ";    rm -rf "$tmp_path";    echo done;fiechoecho all done;exit 0;### end