Download and Install necessary OSS RPMs on IBM AIX box


/ Published in: Bash
Save to your folder(s)

AIX does not have Package Manager like YUM for Open Source Software.
So I made a script to automatically install RPM packages on AIX box by downloading it from www.oss4aix.org site via ftp .
It is very first version, it does not have all the necessary checks, but I do not have too much time to polish it.
Actually it works. It downloads and installs all the necessary software and it dependencies ( thanks to Michael Perzl http://www.perzl.org/aix/index.php?n=FAQs.FAQs#rpm-dependency-hell ).

I saw similar thing here: http://earth2baz.net/rpmplus/
But it downloads entire Repository. I do not need that. So made my own script.

Actually it is for Korn Shell wich is deffault on AIX.


Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. # Aix71extras.sh version 0.1 beta
  3. # Copyleft (c) 2015 - Alexander Teterkin - [email protected]
  4. # http://www.gnu.org/licenses/gpl-3.0.txt
  5.  
  6. # VARS
  7.  
  8. HOST=www.oss4aix.org
  9. USER=anonymous
  10. PASS=teterkin@gmail.com
  11. DIR=rpmdb/deplists/aix71
  12. DIR2=/everything/RPMS
  13. TEMPDIR=TEMP
  14. SOFTDIR=SOFT
  15. LOG=$0.log
  16. DOWNLOADS=$TEMPDIR/downloads.deps
  17. MAJORVS="";
  18.  
  19. # Files to Install:
  20.  
  21. FILES="
  22. bash-4.3-12.aix5.1.ppc
  23. gcc-4.8.3-1.aix7.1.ppc
  24. less-466-1.aix5.1.ppc
  25. mc-4.7.0.4-2.aix5.1.ppc
  26. screen-4.2.1-1.aix5.1.ppc
  27. unzip-6.0-2.aix5.1.ppc
  28. wget-1.16-1.aix5.1.ppc
  29. bzip2-1.0.5-3.aix5.3.ppc
  30. "
  31.  
  32. # FUNCTIONS
  33.  
  34. makecmdlist() {
  35. echo "ftp -inv $HOST << EOF";
  36. echo "user $USER $PASS";
  37. echo "cd $DIR";
  38. echo "lcd $TEMPDIR";
  39. echo "$FILES" | while read LINE; do
  40. if [ "$LINE" != "" ]; then
  41. echo "get $LINE.deps";
  42. fi
  43. done
  44. echo "bye";
  45. echo "EOF";
  46. }
  47.  
  48. makecmdlist2() {
  49. echo "ftp -inv $HOST << EOF";
  50. echo "user $USER $PASS";
  51. echo "cd $DIR2";
  52. echo "lcd $SOFTDIR";
  53. echo "bin";
  54. cat $DOWNLOADS | while read LINE; do
  55. if [ "$LINE" != "" ]; then
  56. echo "get $LINE";
  57. fi
  58. done
  59. echo "bye";
  60. echo "EOF";
  61. }
  62.  
  63. makecmdlist3() {
  64. echo "ftp -inv $HOST << EOF";
  65. echo "user $USER $PASS";
  66. echo "cd $DIR2";
  67. echo "lcd $SOFTDIR";
  68. echo "bin";
  69. echo "$FILES" | while read LINE; do
  70. if [ "$LINE" != "" ]; then
  71. echo "get $LINE.rpm";
  72. fi
  73. done
  74. echo "bye";
  75. echo "EOF";
  76. }
  77.  
  78.  
  79. doline() {
  80. echo ======================
  81. }
  82.  
  83. removeduplicates() {
  84. FILELIST=`ls -1 | grep rpm`;
  85. PCKGLIST=$(echo "$FILELIST" | while read LINE; do
  86. PCKG=`echo $LINE | awk -F "[0-9]" '{ print $1 '}`;
  87. echo $PCKG;
  88. done | sort | uniq
  89. );
  90. echo $PCKGLIST
  91. echo "$PCKGLIST" | while read LINE; do
  92. HM=`echo "$FILELIST" | grep -c ^$LINE[0-9];`;
  93. if [ "$HM" -gt 1 ]; then
  94. echo "Found duplicates: $LINE ($HM):";
  95. doline;
  96. # It was sorted, but we sort again by the 3rd column
  97. SORTED=`echo "$FILELIST" | grep ^$LINE[0-9] | sort -t- +2 -n;`;
  98. echo "$SORTED";
  99. MAJORV=`echo "$SORTED" | tail -1`;
  100. MAJORVS="$MAJORVS""$MAJORV\n"
  101. doline;
  102. fi
  103. done
  104. MAJORVS=`echo "$MAJORVS"| grep -v ^$`;
  105. echo
  106. echo "Major versions:"
  107. echo "$MAJORVS";
  108. echo
  109. echo "Duplicates:";
  110. echo "$MAJORVS" | while read LINE; do
  111. PCKG=`echo $LINE | awk -F "[0-9]" '{ print $1 '}`;
  112. DUP=`echo "$FILELIST" | grep $PCKG | grep -v "$LINE";`;
  113. echo "Moving $DUP to TEMP folder...";
  114. mv $DUP TEMP && echo "Done.";
  115. done
  116. }
  117.  
  118. # MAIN
  119.  
  120. mkdir $TEMPDIR
  121. mkdir $SOFTDIR
  122. CMDS=$(makecmdlist);
  123. echo "$CMDS" > $TEMPDIR/$0.temp;
  124. sh $TEMPDIR/$0.temp
  125. cd $TEMPDIR
  126. cat *.deps | sort | uniq > ../$DOWNLOADS
  127. cd ..
  128. CMDS2=$(makecmdlist2);
  129. echo "$CMDS2" > $TEMPDIR/$0.temp2;
  130. sh $TEMPDIR/$0.temp2
  131. CMDS3=$(makecmdlist3);
  132. echo "$CMDS3" > $TEMPDIR/$0.temp3;
  133. sh $TEMPDIR/$0.temp3
  134.  
  135. cd $SOFTDIR
  136. mkdir TEMP
  137.  
  138. removeduplicates;
  139.  
  140. ls -1 | grep rpm | awk -F "[0-9]" {' print $1 '} | while read LINE; do
  141. if rpm -qa | grep "$LINE" 2>&1 > /dev/null; then
  142. echo "$LINE exists. Skipping...";
  143. else
  144. echo "Installing $LINE...";
  145. SN=`ls -1 | grep $LINE`;
  146. rpm -Uhv $SN; fi;
  147. done
  148.  
  149. cd ..

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.