Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
utilities
pin
pin
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pin of Package pin
#! /bin/sh #set -x export LC_ALL=C # pin - Package InformatioN - mlasars@suse.de (c) 2001-2005 SUSE LINUX GmbH # # gives u info about a package ( rpm -qi, ql) # and greps the SuSE Archives.gz for files # # very handy when compiling or installing stuff # thanks to stefan for better sort # henne for hosting & advertising :-) # changes: # # 2001 05 27 0.02 first public :-) # 2001 07 01 0.03 added * for executeable files # 2001 07 16 0.05 filter .so files as non exe # # 2001 07 26 0.06 added support for different # versions, just copy the ARCHIVES.gz to ARC_DIR/7.2-i386 or 7.2-ppc # what u like (short names rules). # dont forget change ARC_BASE, if you want a different file as # ARCHIVES.gz as default # # 2001 07 30 0.07 changes the options, now pin <option> name # 2001 08 12 0.08 unknown option fix # 2001 08 13 0.09 more fixing # 2001 08 27 0.10 release # 2001 08 31 0.11 better sorting (thx stefan) # 2001 09 03 0.13 cp ARCHIVES.gz from CD if not available # 2001 09 07 0.14 added man page, help page # option check now before check for ARCHIVES.gz # 2001 09 11 ;-( bad bad day, peace! # 2001 09 17 0.15 cancel and no input fix, remove one cut # 2002 02 17 0.20 fixed root/user permissions bug # 2002 02 18 0.23 changed ARC_DIR to /usr/share/pin , $OUT_FILE_$$, hello phalanx # 2002 02 20 0.24 fix rm tmp file at the end # 2002 03 07 0.25 fix messages before copy files, now in right order # 2002 08 23 0.26 fix /dvd/cdrom/cdrecorder mount # 2003 02 21 0.27 corrected typos (# 23264) # new location for ARCHIVES.gz (# 22409), now /var/lib/pin/ # no sorting for main section, makes reading easier # 2003 09 01 0.28 added clear when using dialog # clean up options # -v uses now the version to search # thanks to Christian Boltz for suggestions & fixes # 2004 01 05 fixed insecure tmp file handling # 2004 09 02 changed cd/dvd mounting, thanks to David Haller # 2004 09 13 wrong mountpoint, its dvdram instead of dvd-ram # 2004 09 17 forget one dvd-ram fix # 2005 03 04 fixed cp ARCHIVES.gz on update (#63010) # 2005 05 16 several fixes by Christian Boltz (to fix the fix for #63010 ;-) # - fixed copying ARCHIVES.gz to work with 9.3 mount points (subfs/HAL) # - fixed target filenames when copying ARCHIVES.gz to ARCHIVES_$VERSION.gz # - fixed filenames when symlinking ARCHIVES_$VERSION.gz to ARCHIVES.gz # - fixed several typos ($ARK_BASE vs. $ARC_BASE, $ARC_BASE vs. $ARC_DIR) # # 2005 07 16 0.31 fixed the update issue # thx again to Christian Boltz # # 2005 08 22 0.32 fixed bug #104800 # # 2005 08 26 0.33 removed test # # 2005 09 06 0.34 updated text (bug #115333) # 2006 01 23 0.35 fixed error in cd/dvd handling (bug #144395) # 2006 08 01 0.36 fixed wrong su command (bug #188068) # 2006 08 05 throw error message if cd/dvd is not mounted (instead of trying to copy "/ARCHIVES.gz") # 2006 12 22 detect broken ARCHIVES.gz symlink (bug #227589) # 2007 04 03 0.37 --nosignature --nodigest for rpm -qa to speedup (thanks Pascal) # su & tcsh fix (bug #188068), thanks Volker # 2007 05 06 0.38 fixed fix for bug #188068, copying ARCHIVES.gz should now work with any shell # clean up tempfile if pin gets killed or Ctrl-c'ed (bug #218263) # 2008-12-14 0.39 added stty sane to cleanup trap. (bug #458980, jw) # 2018-09-21 0.40 Leap 15 does not have /etc/SuSE-Release but /etc/os-release is easier to parse anyways. VER=0.40 OUT_FILE=$(/bin/mktemp /tmp/.pin_packinfo_$$.XXXXXX) || { echo "pin: can not create temporary file" >& 2; exit 1; } ARC_DIR_OLD="/usr/share/pin/" ARC_DIR="/var/lib/pin/" # dont forget the / at end! ARC_BASE="ARCHIVES.gz" GREP_FILE_OLD=""$ARC_DIR_OLD""$ARC_BASE"" GREP_FILE=""$ARC_DIR""$ARC_BASE"" CDROM="/media/cdrom/" # dont forget the / at end! CDROM_ALT="/media/dvd/" [ -f /etc/os-release ] && { . /etc/os-release export USED_VERSION=$VERSION_ID } [ -f /etc/SuSE-release ] && USED_VERSION="`grep VERSION /etc/SuSE-release | cut -f3 -d " "`" umask 022 # u can also use gdialog or kdialog ... i prefer gdialog DIALOG="dialog" # if you want less instead of dialog output, OUT="less" OUT="less" # cleanup tempfile if pin gets killed trap "rm -f \"$OUT_FILE\"; stty sane; exit 1" 1 2 3 7 13 15 unknown_option () { cat <<__EOF__ Pin searches the installed packages (rpm -qi, -ql) and/or the ARCHIVES.gz file for the desired information. It shows also README, README.SuSE, FAQ, when available. unknown option options : pin open dialog inputbox pin string searches for string pin -v version string use another version, not the current-i386 pin -f string grepping also if package was found __EOF__ exit 1 } # check options while getopts fv: OPTION ; do case $OPTION in v) PIN_OPTION="-v" ; PIN_VERSION="$OPTARG" ;; f) PIN_FULL="-f" ;; *) unknown_option ;; esac done eval SEARCH="\$$OPTIND" copy_archives () { if [ ! -r "$ARC_DIR""ARCHIVES_""$USED_VERSION"".gz" ] ; then cat <<__EOF__ no file ARCHIVES_$USED_VERSION.gz found please insert CD1/DVD in your CD-ROM/DVD drive / bitte CD1/DVD einlegen please eject all medias from other drives / bitte entfernen Sie andere Medien aus den Laufwerken. press enter to continue - Bitte enter druecken __EOF__ read dummy echo echo "please wait / bitte warten" echo if [ ! -e $ARC_DIR ] ; then mkdir $ARC_DIR fi # take care that we still use SuSE as tag! USED_DEVICE="`hwinfo --cdrom | grep -i SuSE -B 10 | grep Device\ File: | cut -f2 -d : | cut -f2 -d " "`" if [ "$USED_DEVICE" = "" ] ; then cat <<__EOF__ no SUSE CD/DVD found, please copy ARCHIVES.gz manually to /var/lib/pin/ARCHIVES_$USED_VERSION.gz and execute "ln -s /var/lib/pin/ARCHIVES_$USED_VERSION.gz /var/lib/pin/ARCHIVES.gz" keine SUSE CD/DVD gefunden, bitte ARCHIVES.gz manuell nach /var/lib/pin/ARCHIVES_$USED_VERSION.gz kopieren und "ln -s /var/lib/pin/ARCHIVES_$USED_VERSION.gz /var/lib/pin/ARCHIVES.gz" aufrufen __EOF__ exit fi USED_DIR="`mount | grep "$USED_DEVICE" | cut -f3 -d " "`" [ -z "$USED_DIR" ] && { echo >&2; echo " ERROR: CD/DVD not mounted" >&2; exit 1; } CDROM="$USED_DIR" echo echo " copy ARCHIVES.gz to $ARC_DIR..." echo if [ -f "$CDROM/ARCHIVES.gz" ] ; then cp "$CDROM""/ARCHIVES.gz" "$ARC_DIR""ARCHIVES_""$USED_VERSION"".gz" if [ -r "$GREP_FILE" ] ; then mv "$GREP_FILE" "$ARC_DIR""ARCHIVES_old_backup.gz" fi # make link ln -s "ARCHIVES_""$USED_VERSION"".gz" "$GREP_FILE" 2>/dev/null if [ "$?" = 1 ] ; then echo echo " error, could not make link" echo " press return to delete old ARCHIVES.gz" read dummy rm "$GREP_FILE" ln -s "ARCHIVES_""$USED_VERSION"".gz" "$GREP_FILE" 2>/dev/null fi else echo echo " file not found, maybe wrong CD?" echo " please insert the first CD/DVD and restart" echo echo fi fi } if [ ! -r "$ARC_DIR""ARCHIVES_""$USED_VERSION"".gz" ] ; then # roottest if test "$(id -ru)" != "0" -a "$USER" != root -a -z "$ROOT" ; then cat <<__EOF__ *** pin found no ARCHIVES_${USED_VERSION}.gz file in $ARC_DIR pin will copy the files, please enter root password : __EOF__ su - root -s /bin/bash -- "$0" "$@" exit fi # test for old ARC files if [ -r "$GREP_FILE_OLD" ] ; then echo echo " copy the files from $ARC_DIR_OLD to $ARC_DIR ...." echo echo if [ ! -r "$ARC_DIR" ] ; then mkdir $ARC_DIR fi ARC_DIR_OLD="$ARC_DIR_OLD""*" if cp -v $ARC_DIR_OLD $ARC_DIR; then echo echo " files copied, you can remove $ARC_DIR_OLD if you want." fi if [ -r "$GREP_FILE" ] ; then cd $ARC_DIR mv $ARC_BASE ARCHIVES_old_backup.gz echo echo " moved old $ARC_BASE to ARCHIVES_old_backup.gz" echo " rename it if you still need search this version" fi fi fi # test if there is a symlink LINK_ARCHIVES="`readlink $GREP_FILE`" if [ "$LINK_ARCHIVES" != "" ] ; then # check if it is the latest version if [ -r ""$ARC_DIR""ARCHIVES_""$USED_VERSION"".gz ] ; then true else copy_archives fi fi copy_archives # try to find installed archives.gz ARC_FILES=`ls -1 "$ARC_DIR"` if [ "$PIN_OPTION" = "-v" ] ; then if [ -r ""$ARC_DIR""$PIN_VERSION"" ] ; then GREP_FILE=""$ARC_DIR""$PIN_VERSION"" else echo " $OPTARG not found!" echo # display all versions found in ARC_DIR while true ; do echo "$ARC_FILES" echo echo " please choose a version from above, just enter the name" read GREP_FILE if [ "$GREP_FILE" = "" ] ;then GREP_FILE=""$ARC_DIR""$ARC_BASE"" break else GREP_FILE=""$ARC_DIR""$GREP_FILE"" if [ -f "$GREP_FILE" ] ; then break else echo $GREP_FILE "no found ! please choose again or press return for $ARC_BASE" fi fi done fi fi if [ -r $GREP_FILE ] ; then true elif [ -r "$ARC_DIR/ARCHIVES_$USED_VERSION.gz" ] ; then # ARCHIVES.gz symlink broken, but ARCHIVES_$USED_VERSION.gz is OK echo echo " ${ARC_DIR}ARCHIVES.gz symlink is broken!" echo echo " Please execute" echo " ln -sf ${ARC_DIR}ARCHIVES_"$USED_VERSION".gz ${ARC_DIR}ARCHIVES.gz" echo exit 1 else cat <<__EOF__ $GREP_FILE not found, copy ARCHIVES.gz from SuSE CD1 (or DVD) to /var/lib/pin/ARCHIVES_$USED_VERSION.gz and execute "ln -s /var/lib/pin/ARCHIVES_$USED_VERSION.gz /var/lib/pin/ARCHIVES.gz" $GREP_FILE nicht gefunden, bitte ARCHIVES.gz manuell nach /var/lib/pin/ARCHIVES_$USED_VERSION.gz kopieren und "ln -s /var/lib/pin/ARCHIVES_$USED_VERSION.gz /var/lib/pin/ARCHIVES.gz" aufrufen __EOF__ exit fi stty_size () { LINES=$1 COLUMNS=$2 } stty_size `stty size 2>/dev/null` if [ "$SEARCH" = "" ] ; then if $DIALOG --title "pin - package infomation" \ --inputbox "please input package name or file" \ 8 40 2> $OUT_FILE then SEARCH="`cat $OUT_FILE`" DIALOG_USE="yes" clear fi fi if [ "$SEARCH" = "" ] ; then rm -f $OUT_FILE 2> /dev/null clear echo " you entered nothing or choose cancel ... bye" exit fi echo "pin $VER - package info for $SEARCH" > $OUT_FILE if [ "$PIN_OPTION" != "-v" ] ; then # check rpm -qi $SEARCH 2> /dev/null 1> /dev/null if [ $? != 0 ] ; then cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** no rpm named $SEARCH installed ------------------------------------------------------------------ __EOF__ RPM_ALL="`rpm -qa --nosignature --nodigest | grep $SEARCH`" if [ "$RPM_ALL" != "" ] ; then cat >> $OUT_FILE <<__EOF__ maybe just a typo? what about this: $RPM_ALL maybe better restart with another option? grepping anyway ... __EOF__ fi PIN_FULL="-f" else cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** rpm info ------------------------------------------------------------------ __EOF__ rpm -qi $SEARCH >> $OUT_FILE cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** rpm filelist (*=executeable) ------------------------------------------------------------------ __EOF__ rpm -ql $SEARCH | \ while read line do if [ -x $line ] && [ -f $line ] &&! [ "`echo $line | grep .so`" = "$line" ]; then echo "*" $line >> $OUT_FILE else echo " " $line >> $OUT_FILE fi done if [ -e /usr/share/doc/packages/$SEARCH ] ; then cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** /usr/share/doc/packages/$SEARCH/ ------------------------------------------------------------------ __EOF__ ls -l /usr/share/doc/packages/$SEARCH/ >> $OUT_FILE fi if [ -e /usr/share/doc/packages/$SEARCH/README.SuSE ] ; then cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** README.SuSE ------------------------------------------------------------------ __EOF__ cat /usr/share/doc/packages/$SEARCH/README.SuSE >> $OUT_FILE fi if [ -e /usr/share/doc/packages/$SEARCH/README ] ; then cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** README ------------------------------------------------------------------ __EOF__ cat /usr/share/doc/packages/$SEARCH/README >> $OUT_FILE fi if [ -e /usr/share/doc/packages/$SEARCH/FAQ ] ; then cat >> $OUT_FILE <<__EOF__ ------------------------------------------------------------------ *** FAQ ------------------------------------------------------------------ __EOF__ cat /usr/share/doc/packages/$SEARCH/FAQ >> $OUT_FILE fi fi fi if [ "$PIN_OPTION" = "-v" ] || [ "$PIN_FULL" = "-f" ] ; then cat >> $OUT_FILE <<__EOF__ grepping $GREP_FILE ... please wait ------------------------------------------------------------------ *** zgrep $SEARCH $GREP_FILE ------------------------------------------------------------------ __EOF__ ZGREP="`zgrep -i $SEARCH $GREP_FILE`" echo "$ZGREP" | grep -i "\-->" |sort >> $OUT_FILE echo >> $OUT_FILE echo "$ZGREP" >> $OUT_FILE fi if [ "$OUT" != "less" ] ; then $DIALOG --title "pin package information for $SEARCH" --textbox $OUT_FILE $LINES $COLUMNS else less $OUT_FILE if [ "$DIALOG_USE" = "yes" ] ; then clear fi fi rm -f $OUT_FILE 2> /dev/null
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor