Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
![Reply](https://www.linuxquestions.org/questions/images/buttons/reply.gif) |
|
07-31-2006, 03:42 AM
|
#16
|
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
|
Ok the script's now fixed. Please optimize the script if you can.
Code:
#!/bin/bash
# freshpick.sh (c) 2006 konsolebox
# chooses the newest versions of packages from a list
# version: 1.1
# license: GPL
DEBUG=
debug() { [ "$DEBUG" ] && echo "$@"; }
error() { echo "error: $@"; exit; }
usege() {
echo "usage: freshpick.sh list"
exit
}
compareversions() {
for ((p=1; p<=10; p++)); do
a=$(echo "$1" | cut -f "$p" -d '.')
b=$(echo "$2" | cut -f "$p" -d '.')
debug "comparing $a to $b"
if [ -z "$a" ] && [ -z "$b" ]; then
debug "compareversions exit no 1"
return 1
elif [ -z "$b" ]; then
debug "compareversions exit no 2"
return 1
elif [ -z "$a" ]; then
debug "compareversions exit no 3"
return 0
fi
if [[ b -gt a ]]; then
debug "compareversions exit no 4"
return 0
elif [[ b -lt a ]]; then
debug "compareversions exit no 5"
return 1
fi
# a still equals to b so continue
done
error "versions $a and $b too long"
}
finalize() {
# you an modify this function if you like
echo "$@"
}
#### start ####
FILENAME="$1"
if [ -z "$FILENAME" ]; then
usege
elif [ ! -e "$FILENAME" ]; then
error "$FILENAME" not found
fi
# process the first line
fn=$(cat "${FILENAME}" | sort | sed -n 1p)
CURRENTPACKAGE="${fn/-*}"
NEWESTVERSION="$(echo "$fn" | sed s/".*\-\([0-9.]\+[0-9]\).*"/"\1"/)" # better than 'grep -o ..'
CURRENTSUFFIX="$(echo "$fn" | sed s/".*${NEWESTVERSION}."//)"
debug [ "$CURRENTPACKAGE" "$NEWESTVERSION" ]
# main loop
for fn in $(cat "${FILENAME}" | sort | sed -n 1\!p); do
NEWPACKAGE="${fn/-*}"
NEWVERSION="$(echo "$fn" | sed s/".*\-\([0-9.]\+[0-9]\).*"/"\1"/)"
debug [ "$NEWPACKAGE" "$NEWVERSION" ]
if [ "${NEWPACKAGE}" != "${CURRENTPACKAGE}" ]; then
finalize "${CURRENTPACKAGE}-${NEWESTVERSION}.${CURRENTSUFFIX}"
CURRENTPACKAGE="${NEWPACKAGE}"
NEWESTVERSION="${NEWVERSION}"
CURRENTSUFFIX="$(echo "$fn" | sed s/".*${NEWVERSION}."//)"
else
compareversions "${NEWESTVERSION}" "${NEWVERSION}" && \
NEWESTVERSION="${NEWVERSION}"
fi
done
finalize "${CURRENTPACKAGE}-${NEWESTVERSION}.${CURRENTSUFFIX}"
Regards,
konsolebox
|
|
|
07-31-2006, 02:30 PM
|
#17
|
Senior Member
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914
Original Poster
Rep:
|
yep, that does the trick as far as I can tell. Thanks!
|
|
|
07-31-2006, 07:58 PM
|
#18
|
Senior Member
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914
Original Poster
Rep:
|
Quote:
Originally Posted by spirit receiver
Read a line from buildorder.txt and grep pkglst.txt for the result.
|
DOH!!! Man... Don't know whats wrong with me lately. You said it in english, that's why...
while read line
do
grep "^$line" pkglst.txt
done <buildorder.txt
Thanks again guys for your help. I have the mechanics completely done now.
|
|
|
08-01-2006, 04:38 AM
|
#19
|
Member
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424
Rep:
|
And by 'feed the "while read <&3" loop with the lines of buildorder.txt' I meant to replace
Code:
exec 3< <( sed -n 's/-[[:digit:].]\+tar\.bz2$//p' $DATAFILE | sort | uniq )
with
Code:
exec 3< buildorder.txt
as this is 'fed' into the loop's read command. Sorry for the confusion.
|
|
|
08-01-2006, 02:55 PM
|
#20
|
Senior Member
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914
Original Poster
Rep:
|
I'm sorta tiring of this thread as are you guys, but I thought I'd let you know spirit reciever, your script really mutilates this list, whereas Konsolbox's script processes it correctly... There are 9 missing packages with dupicates of others via your output...
Code:
libAppleWM-1.0.0.tar.bz2
libFS-1.0.0.tar.bz2
libICE-1.0.0.tar.bz2
libICE-1.0.1.tar.bz2
libSM-1.0.0.tar.bz2
libSM-1.0.1.tar.bz2
libWindowsWM-1.0.0.tar.bz2
libX11-1.0.0.tar.bz2
libX11-1.0.1.tar.bz2
libX11-1.0.2.tar.bz2
libX11-1.0.3.tar.bz2
libXScrnSaver-1.0.1.tar.bz2
libXScrnSaver-1.1.0.tar.bz2
libXTrap-1.0.0.tar.bz2
libXau-1.0.0.tar.bz2
libXau-1.0.1.tar.bz2
libXau-1.0.2.tar.bz2
libXaw-1.0.1.tar.bz2
libXaw-1.0.2.tar.bz2
libXcomposite-0.2.2.2.tar.bz2
libXcomposite-0.3.tar.bz2
libXcursor-1.1.5.2.tar.bz2
libXcursor-1.1.6.tar.bz2
libXcursor-1.1.7.tar.bz2
libXdamage-1.0.2.2.tar.bz2
libXdamage-1.0.3.tar.bz2
libXdmcp-1.0.0.tar.bz2
libXdmcp-1.0.1.tar.bz2
libXevie-1.0.0.tar.bz2
libXevie-1.0.1.tar.bz2
libXext-1.0.0.tar.bz2
libXext-1.0.1.tar.bz2
libXfixes-3.0.1.2.tar.bz2
libXfixes-4.0.1.tar.bz2
libXfixes-4.0.tar.bz2
libXfont-1.0.0.tar.bz2
libXfont-1.1.0.tar.bz2
libXfont-1.2.0.tar.bz2
libXfontcache-1.0.1.tar.bz2
libXfontcache-1.0.2.tar.bz2
libXft-2.1.8.2.tar.bz2
libXft-2.1.9.tar.bz2
libXft-2.1.10.tar.bz2
libXi-1.0.0.tar.bz2
libXi-1.0.1.tar.bz2
libXinerama-1.0.1.tar.bz2
libXmu-1.0.0.tar.bz2
libXmu-1.0.1.tar.bz2
libXmu-1.0.2.tar.bz2
libXp-1.0.0.tar.bz2
libXpm-3.5.4.2.tar.bz2
libXpm-3.5.5.tar.bz2
libXprintAppUtil-1.0.1.tar.bz2
libXprintUtil-1.0.1.tar.bz2
libXrandr-1.1.0.2.tar.bz2
libXrandr-1.1.1.tar.bz2
libXrender-0.9.0.2.tar.bz2
libXrender-0.9.1.tar.bz2
libXres-1.0.0.tar.bz2
libXres-1.0.1.tar.bz2
libXt-1.0.0.tar.bz2
libXt-1.0.1.tar.bz2
libXt-1.0.2.tar.bz2
libXtst-1.0.1.tar.bz2
libXv-1.0.1.tar.bz2
libXvMC-1.0.1.tar.bz2
libXvMC-1.0.2.tar.bz2
libXxf86dga-1.0.0.tar.bz2
libXxf86dga-1.0.1.tar.bz2
libXxf86misc-1.0.0.tar.bz2
libXxf86misc-1.0.1.tar.bz2
libXxf86vm-1.0.0.tar.bz2
libXxf86vm-1.0.1.tar.bz2
libdmx-1.0.1.tar.bz2
libdmx-1.0.2.tar.bz2
libfontenc-1.0.1.tar.bz2
libfontenc-1.0.2.tar.bz2
liblbxutil-1.0.0.tar.bz2
liblbxutil-1.0.1.tar.bz2
liboldX-1.0.1.tar.bz2
libxkbfile-1.0.1.tar.bz2
libxkbfile-1.0.2.tar.bz2
libxkbfile-1.0.3.tar.bz2
libxkbui-1.0.1.tar.bz2
libxkbui-1.0.2.tar.bz2
xtrans-1.0.0.tar.bz2
xtrans-1.0.1.tar.bz2
Everyone starting to see why I want to autoresolve $VERSION and fetching? ![Wink](https://www.linuxquestions.org/questions/images/smilies/wink.gif) That's only one list out of 8.... Were talking hundreds of packages. Pretty annoying having to figure out what needs updating after the next Xorg release... They do use 7.0 as a static base and then 7.{1-x} will be updates only but that's still gonna take time...
|
|
|
08-01-2006, 03:46 PM
|
#21
|
Member
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424
Rep:
|
You're right, I was too sloppy with some pattern matching there, which caused problems if a package name started with another package name, as in libXpm. The next to last line should be replaced with
Code:
grep "^$REPLY-[[:digit:].]\+tar\.bz2$" $DATAFILE | grab_latest
Edit: But I couldn't find 9 missing packages, there were libXp-1.0.0.tar.bz2 and libXv-1.0.1.tar.bz2 missing, with the corrsponding duplicates of libXpm-3.5.5.tar.bz2 and libXvMC-1.0.2.tar.bz2.
Last edited by spirit receiver; 08-01-2006 at 04:12 PM.
|
|
|
08-01-2006, 04:19 PM
|
#22
|
Senior Member
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914
Original Poster
Rep:
|
you know, My reorder grep function is playing havoc with me as well . It's throwing packages that should be up top down towards the bottom and possibly listing them twice. I'm getting irritated..
Is it really worth it I ask? ![Wink](https://www.linuxquestions.org/questions/images/smilies/wink.gif) I've already spent alot time on this, not quiting now... If there's one thing I hate, it's wasted time..
Thanks for the fix on your script.
EDIT: Yea, I think I had 4 libXpm-3.5.5 and some other crap. My reorder is defenately going awry..
Last edited by jong357; 08-01-2006 at 04:28 PM.
|
|
|
08-01-2006, 10:46 PM
|
#23
|
Senior Member
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914
Original Poster
Rep:
|
Quote:
Originally Posted by spirit receiver
And by 'feed the "while read <&3" loop with the lines of buildorder.txt' I meant to replace
Code:
exec 3< <( sed -n 's/-[[:digit:].]\+tar\.bz2$//p' $DATAFILE | sort | uniq )
with
Code:
exec 3< buildorder.txt
as this is 'fed' into the loop's read command. Sorry for the confusion.
|
That does work great. Thanks for all the time you've spent helping me... I really do appreciate it. Really... ![Wink](https://www.linuxquestions.org/questions/images/smilies/wink.gif)
|
|
|
All times are GMT -5. The time now is 02:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|