LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-10-2014, 06:59 AM   #1
LinuGeek
Member
 
Registered: Jun 2008
Posts: 126

Rep: Reputation: 0
Script Help


Hello Community,

I would like to have your inputs on the following script logic.

So we have a script which upgrades (in terms of RPMs) depending on the customised OS version.

So we have these versions in place --- 1.1.5,1.1.8,1.2.1,1.2.2

Now we have a small script written for updated from 1.1.5 to 1.1.8. So this script checks the third octet(to say) and then does the required job.
Now we have to modify this script to go for a change in 2nd and 3rd octet as well. So the script should handle the upgrade of 1.1.5 to 1.2.2.
So the logic had to be modified. So far we have used the following logic.

for (( j=`expr $installed_ver + 1`; j<=$target_ver; j++ ))
do
for k in $list_of_reqd_RPMs_to_install
do
if [ $j -lt $target_ver_nr ]; then
rpm -ivh $k

fi
done
done

Now the above script handles the upgrade from 1.1.5-> 1.1.8 but not 1.2.2.
Your inputs in this case will help.
Thanx.
 
Old 09-10-2014, 07:59 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by LinuGeek View Post
Now the above script handles the upgrade from 1.1.5-> 1.1.8 but not 1.2.2.
Your inputs in this case will help.
Thanx.
There are not three decimal places in math. I'm surprised your script works at all. You should probably rewrite your script in a slightly more robust language so that you can better process the version numbers easier. You should process the version numbers as strings and split them up to do the comparisons. That's all I have time for.

Good luck.
 
Old 09-11-2014, 01:20 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I am not sure I follow the logic (in general, not the script). Do you require intermediate items to be installed as you go from version to version?

As an example, if current is 1.1.5 and we need to upgrade to 1.2.1, do we need to firstly install all for 1.1.8 prior to installing those for 1.2.1?

If you simply need to install all from the latest version, you could do something like:
Code:
latest_v=$(sort -V <<<"$(echo -e "$installed_ver\n$target_ver")")

[[ "$latest_v" == "$installed_ver" ]] || echo "time to upgrade :)"
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 10 07-17-2012 09:36 AM
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 1 07-13-2012 01:03 AM
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 06:00 AM
[SOLVED] bash and xterm: how make apps started by and for a script persist when script terminates porphyry5 Linux - General 4 06-15-2011 01:27 PM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 08:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:47 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