configure.sh 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2009, puppylinux.com
  3. #2009 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html).
  4. #called from /usr/local/petget/pkg_chooser.sh
  5. #configure package manager
  6. #110118 alternate user interfaces.
  7. #120203 BK: internationalized.
  8. #120210 01micko: Ziggy ui crashes if *all* repos unticked here (no one would do that, but it is still a bug).
  9. #120515 in some cases, Packages-puppy-${DISTRO_FILE_PREFIX}-* may not exist (ex, Racy only has Packages-puppy-wary5-official).
  10. #120529 checkbox to display app thumbnail icons.
  11. #120811 category field now supports sub-category |category;subcategory|, use as icon in ppm main window. -- always enabled.
  12. #121102 Packages-puppy-${DISTRO_FILE_PREFIX}- (or Packages-puppy-${DISTRO_COMPAT_VERSION}-) is now Packages-puppy-${DISTRO_DB_SUBNAME}-. refer /etc/DISTRO_SPECS.
  13. #121129 Update: d/l Packages-puppy-squeeze-official, which wasn't there before, upset this script.
  14. export TEXTDOMAIN=petget___configure.sh
  15. export OUTPUT_CHARSET=UTF-8
  16. #export LANG=C
  17. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  18. . /root/.packages/DISTRO_PKGS_SPECS
  19. . /root/.packages/DISTRO_PET_REPOS
  20. . /root/.packages/PKGS_MANAGEMENT #has PKG_REPOS_ENABLED
  21. #find what repos are currently in use... 120510...
  22. CHECKBOXES_REPOS=""
  23. #for ONEREPO in `ls -1 /root/.packages/Packages-*`
  24. #120510 bugfix with ui_Ziggy. add CHECKBOX_MAIN_REPO var to gui
  25. MAIN_REPO="`ls -1 /root/.packages/Packages-* | grep "puppy\-${DISTRO_DB_SUBNAME}\-" | head -n 1 | sed 's%^/root/.packages/%%'`" #121102 121129
  26. #120515 hmmm, in some cases, Packages-puppy-${DISTRO_FILE_PREFIX}-* may not exist (ex, Racy only has Packages-puppy-wary5-official)...
  27. #121102 ...now using DISTRO_DB_SUBNAME, should always exist.
  28. [ "$MAIN_REPO" = "" ] && MAIN_REPO="`echo "$PACKAGELISTS_PET_ORDER" | tr ' ' '\n' | head -n 1`" #PACKAGELISTS_PET_ORDER is in /root/.packages/DISTRO_PET_REPOS.
  29. [ "$MAIN_REPO" = "" ] && MAIN_REPO="Packages-puppy-noarch-official" #paranoid precaution.
  30. bMAIN_PATTERN=' '"$MAIN_REPO"' '
  31. MAIN_DBNAME="`echo -n "$MAIN_REPO" | sed -e 's%Packages\-%%'`"
  32. CHECKBOX_MAIN_REPO="<checkbox><default>true</default><label>${MAIN_DBNAME}</label><variable>CHECK_${MAIN_DBNAME}</variable><visible>disabled</visible></checkbox>" #hard coded "true"
  33. DBFILESLIST="$(ls -1 /root/.packages/Packages-*)" #121129
  34. PKG_REPOS_ENABLED=" ${PKG_REPOS_ENABLED} " #121129 precaution.
  35. for ONEREPO in `echo "$DBFILESLIST" | grep -v "${MAIN_REPO}" | tr '\n' ' '` #120515 fix. 121129
  36. do
  37. BASEREPO="`basename $ONEREPO`"
  38. bPATTERN=' '"${BASEREPO}"' '
  39. DEFAULT='true'
  40. [ "`echo -n "$PKG_REPOS_ENABLED" | grep "$bPATTERN"`" = "" ] && DEFAULT='false'
  41. DBNAME="`echo -n "$BASEREPO" | sed -e 's%Packages\-%%'`"
  42. CHECKBOXES_REPOS="${CHECKBOXES_REPOS}<checkbox><default>${DEFAULT}</default><label>${DBNAME}</label><variable>CHECK_${DBNAME}</variable></checkbox>"
  43. done
  44. #110118 choose a user interface...
  45. UI="`cat /var/local/petget/ui_choice`"
  46. [ "$UI" = "" ] && UI="Classic"
  47. UI_RADIO="<radiobutton><label>${UI}</label><action>echo -n ${UI} > /var/local/petget/ui_choice</action></radiobutton>"
  48. for ONEUI in Classic Ziggy
  49. do
  50. [ "$ONEUI" = "$UI" ] && continue
  51. UI_RADIO="${UI_RADIO}<radiobutton><label>${ONEUI}</label><action>echo -n ${ONEUI} > /var/local/petget/ui_choice</action></radiobutton>"
  52. done
  53. # <text><label>Choose an alternate User Interface:</label></text>
  54. #120811 remove...
  55. ##120529 note, same code in pkg_chooser.sh, so probably this not req'd...
  56. #if [ -f /var/local/petget/flg_appicons ];then
  57. # FLG_APPICONS="`cat /var/local/petget/flg_appicons`"
  58. #else
  59. # #test if pet installed with set of 16x16 app icons...
  60. # [ "`grep 'icons_puppy_app' /root/.packages/woof-installed-packages /root/.packages/user-installed-packages`" != "" ] && FLG_APPICONS='true'
  61. #fi
  62. #[ "$FLG_APPICONS" = "" ] && FLG_APPICONS='false'
  63. #120811 removed...
  64. # <checkbox><label>$(gettext 'Show application thumbnail icons')</label><variable>CHK_APPICONS</variable><default>${FLG_APPICONS}</default></checkbox>
  65. export CONFIG_DIALOG="<window title=\"$(gettext 'Puppy Package Manager: configure')\" icon-name=\"gtk-about\">
  66. <hbox>
  67. <vbox>
  68. <frame $(gettext 'Update database')>
  69. <hbox>
  70. <text><label>$(gettext 'Puppy has a database file for each package repository. Click this button to download the latest information on what packages are in the repository:')</label></text>
  71. <button><label>$(gettext 'Update now')</label><action>rxvt -bg yellow -title 'download databases' -e /usr/local/petget/0setup</action></button>
  72. </hbox>
  73. <text><label>$(gettext "Note: some repositories are 'fixed' and do not need to be updated. An example of this is the Slackware official version 12.2 repo. An example that does change is the Slackware 'slacky' 12.2 repo which has extra packages for Slackware 12.2. Anyway, to be on the safe side, clicking the above button will update all database files.")</label></text>
  74. <text><label>$(gettext "Warning: The database information for some repositories is quite large, about 1.5MB for 'slacky' and several MB for Ubuntu/Debian. If you are on dialup, be prepared for this.")</label></text>
  75. <text><label>$(gettext 'Technical note: if you would like to see the package databases, they are at') /root/.packages/Packages-*. $(gettext 'These are in a standardised format, regardless of which distribution they were obtained from. This format is considerably smaller than that of the original distro.')</label></text>
  76. </frame>
  77. <frame $(gettext 'User Interface')>
  78. ${UI_RADIO}
  79. </frame>
  80. </vbox>
  81. <vbox>
  82. <text use-markup=\"true\"><label>\"<b>$(gettext 'Requires restart of PPM to see changes')</b>\"</label></text>
  83. <frame $(gettext 'Choose repositories')>
  84. <text><label>$(gettext 'Choose what repositories you would like to have appear in the main GUI window (tick a maximum of 5 boxes):')</label></text>
  85. ${CHECKBOXES_REPOS}
  86. ${CHECKBOX_MAIN_REPO}
  87. <hbox>
  88. <text><label>$(gettext 'Adding a new repository currently requires manual editing of some text files. Click this button for further information:')</label></text>
  89. <button><label>$(gettext 'Add repo help')</label>
  90. <action>nohup defaulthtmlviewer file:///usr/local/petget/README-add-repo.htm & </action>
  91. </button>
  92. </hbox>
  93. </frame>
  94. <hbox>
  95. <button ok></button>
  96. <button cancel></button>
  97. </hbox>
  98. </vbox>
  99. </hbox>
  100. </window>"
  101. RETPARAMS="`gtkdialog3 --program=CONFIG_DIALOG`"
  102. #ex:
  103. # CHECK_puppy-2-official="false"
  104. # CHECK_puppy-3-official="true"
  105. # CHECK_puppy-4-official="true"
  106. # CHECK_puppy-woof-official="false"
  107. # CHECK_ubuntu-intrepid-main="true"
  108. # CHECK_ubuntu-intrepid-multiverse="true"
  109. # CHECK_ubuntu-intrepid-universe="true"
  110. # EXIT="OK"
  111. [ "`echo -n "$RETPARAMS" | grep 'EXIT' | grep 'OK'`" = "" ] && exit
  112. #120811 removed...
  113. ##120529
  114. #PREVFLG="`cat /var/local/petget/flg_appicons`"
  115. #if [ "`echo -n "$RETPARAMS" | grep 'CHK_APPICONS' | grep 'true'`" != "" ];then
  116. # echo -n 'true' > /var/local/petget/flg_appicons
  117. # NEWFLG='true'
  118. #else
  119. # echo -n 'false' > /var/local/petget/flg_appicons
  120. # NEWFLG='false'
  121. #fi
  122. #if [ "$PREVFLG" != "$NEWFLG" ];then
  123. # #rm -f /tmp/petget_fltrd_repo_*
  124. # #rm -f /tmp/petget_installed_*
  125. # rm -f /tmp/installedpkgs.results.post*
  126. # rm -f /tmp/petget/filterpkgs.results.post*
  127. #fi
  128. enabledrepos=" "
  129. repocnt=1
  130. for ONEREPO in `echo "$DBFILESLIST" | tr '\n' ' '` #121129
  131. do
  132. REPOBASE="`basename $ONEREPO`"
  133. repoPATTERN="`echo -n "$REPOBASE" | sed -e 's%Packages\\-%%' | sed -e 's%\\-%\\\\-%g'`"
  134. if [ "`echo "$RETPARAMS" | grep "$repoPATTERN" | grep 'false'`" = "" ];then
  135. enabledrepos="${enabledrepos}${REPOBASE} "
  136. repocnt=`expr $repocnt + 1`
  137. [ $repocnt -gt 5 ] && break #only allow 5 active repos in PPM.
  138. fi
  139. done
  140. grep -v '^PKG_REPOS_ENABLED' /root/.packages/PKGS_MANAGEMENT > /tmp/pkgs_management_tmp2
  141. mv -f /tmp/pkgs_management_tmp2 /root/.packages/PKGS_MANAGEMENT
  142. echo "PKG_REPOS_ENABLED='${enabledrepos}'" >> /root/.packages/PKGS_MANAGEMENT
  143. ###END###