LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-11-2008, 11:28 AM   #1
randomsel
Member
 
Registered: Oct 2006
Location: Wilmington, DE
Distribution: Slackware 11
Posts: 201

Rep: Reputation: 30
Command-not-found in Slackware


A neat little script using MANIFEST.bz2 for finding those missing commands like Ubuntu.

Me thinks it would be nice for extending which functionality...
 
Old 02-11-2008, 12:11 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Here's what may be a more complete implementation since it will allow you to search the MANIFEST for any program, file or library:

Code:
#!/bin/sh

# This is a script to answer the question "In which Slackware package(s) does
# the file <query_filename> belong to?". Typically the user would have to
# manually consult the MANIFEST.gz file on the Slackware CD-ROM to find out
# this information. This file can be helpful for the testldddeps script, made
# by me also.
#
# Cameron R Kerr
# Last revised: 27 August 2001
# cameron.kerr@paradise.net.nz
# http://homepages.paradise.net.nz/~cameronk/
#
# Please send any improvements back to me to share with the world.

#
# Modified by Gilbert Ashley
# 3 July 2005
# Added support for bzip2 Manifests

function usage()
{
  echo -n "USAGE: `basename $0` " >&2
  echo "[-h|--help] | [-e|--exact] [-s|--show] <MANIFEST[.gz|.bz2]> <query>" >&2
  echo "Version: 19 August 2001 Author: cameron.kerr@paradise.net.nz" >&2
  exit 1
}

# Deal with program arguments

TEMP=`getopt -n \`basename $0\` --longoptions="help,exact,show" "hes" "$@"`

eval set -- "${TEMP}"

EXACT=0
SHOW=0
while true
do
  case "$1" in

    -h|--help) usage;;

    -e|--exact) EXACT=1; shift;;

    -s|--show) SHOW=1; shift;;

    --) shift; break;;

    *) echo "Internal error!"; exit 1;;

  esac  
done

MANIFEST="$1"; shift
QUERY="$1"; shift

# Lets support reading gzip'd versions of MANIFEST, since it is by default.

FILETYPE=`file "${MANIFEST}"`

if [ "`echo ${FILETYPE} | grep 'gzip compressed data'`" ]; then
  CATTER=zcat
elif [ "`echo ${FILETYPE} | grep 'bzip2 compressed data'`" ]; then
  CATTER=bzcat
elif [ "`echo ${FILETYPE} | grep 'ASCII text'`" ]; then
  CATTER=cat
else
  echo "  Sorry! invalid file format for ${MANIFEST} ." >&2
  echo "  Give the path to a valid Slackware MANIFEST" >&2
  echo "  file. Either MANIFEST.bz2, MANIFEST.gz or the" >&2
  echo "  decompressed MANIFEST file." >&2
  exit 2
fi  

# Handle the case where /usr/bin/... is given, as it is stored as usr/bin/...
# in the MANIFEST
QUERY_INTERNAL="`echo \"${QUERY}\" | sed -e 's/^\///'`"

# If the user has asked for exact matching, append a space at the end.
if [ $EXACT == 1 ]; then
  QUERY_INTERNAL="${QUERY_INTERNAL} "
fi

# If the user has asked for fully qualifed matching, prepend a space

echo "Please wait while searching..."

${CATTER} ${MANIFEST} | awk '
BEGIN {
  starting = 1
}

/^\|\|   Package:  / {
  if( starting == 1 )
    starting = 0
  else
    printf( "\n" )
  printf( "%s ", $3 )
}  

/^[-bcdlps][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT][[:space:]]/ {
  printf( "%s ", $6 )
}  

END {
  printf( "\n" )
}  
' | fgrep "${QUERY_INTERNAL}" | cut -d' ' -f1

exit 0
A possible improvement might do something about integrating multiple MANIFESTS -that is mANIFESTS from /patches or /extra might be looked at first.
I use the script as posted as part of a ROX AppDir with several slackware package-related tools integrated. Just clicking the AppDir opens pktool in an xterm. Right-clicking gives me a menu with choices to list installed packages quickly using 'ls /var/log/packages/*', search for the installed package which contains a certain file or search for a file in 'all' available slack packages (the script above). Very handy and much faster than opening an xterm and entering these often-used commands manually. You could even create menu entries for your favorite window manager which would do the same thing.

Last edited by gnashley; 02-11-2008 at 12:24 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
at: command not found! witch slackware package? Shioni Slackware 2 10-24-2006 01:26 PM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
cmp command not found in Slackware? vharishankar Slackware 5 04-05-2006 02:09 AM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration