configure.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. #checkbox for BuildingBlock category
  54. [ "`cat /var/local/petget/bb_category`" = "true" ] && BB_STATE=true || BB_STATE=false
  55. # <text><label>Choose an alternate User Interface:</label></text>
  56. export CONFIG_DIALOG="<window title=\"$(gettext 'Puppy Package Manager: configure')\" icon-name=\"gtk-about\">
  57. <hbox>
  58. <vbox>
  59. <frame $(gettext 'Update database')>
  60. <hbox>
  61. <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>
  62. <button><label>$(gettext 'Update now')</label><action>rxvt -bg yellow -title 'download databases' -e /usr/local/petget/0setup</action></button>
  63. </hbox>
  64. <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>
  65. <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>
  66. <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>
  67. </frame>
  68. <frame $(gettext 'User Interface')>
  69. ${UI_RADIO}
  70. </frame>
  71. <checkbox>
  72. <label>$(gettext 'Enable BuildingBlock category (for advanced users only!)')</label>
  73. <variable>varBB_STATE</variable>
  74. <default>${BB_STATE}</default>
  75. <action>echo -n \${varBB_STATE} > /var/local/petget/bb_category</action>
  76. </checkbox>
  77. </vbox>
  78. <vbox>
  79. <text use-markup=\"true\"><label>\"<b>$(gettext 'Requires restart of PPM to see changes')</b>\"</label></text>
  80. <frame $(gettext 'Choose repositories')>
  81. <text><label>$(gettext 'Choose what repositories you would like to have appear in the main GUI window:')</label></text>
  82. ${CHECKBOXES_REPOS}
  83. ${CHECKBOX_MAIN_REPO}
  84. <hbox>
  85. <text><label>$(gettext 'Adding a new repository currently requires manual editing of some text files. Click this button for further information:')</label></text>
  86. <button><label>$(gettext 'Add repo help')</label>
  87. <action>nohup defaulthtmlviewer file:///usr/local/petget/README-add-repo.htm & </action>
  88. </button>
  89. </hbox>
  90. </frame>
  91. <hbox>
  92. <button ok></button>
  93. <button cancel></button>
  94. </hbox>
  95. </vbox>
  96. </hbox>
  97. </window>"
  98. RETPARAMS="`gtkdialog3 --program=CONFIG_DIALOG`"
  99. #ex:
  100. # CHECK_puppy-2-official="false"
  101. # CHECK_puppy-3-official="true"
  102. # CHECK_puppy-4-official="true"
  103. # CHECK_puppy-woof-official="false"
  104. # CHECK_ubuntu-intrepid-main="true"
  105. # CHECK_ubuntu-intrepid-multiverse="true"
  106. # CHECK_ubuntu-intrepid-universe="true"
  107. # EXIT="OK"
  108. [ "`echo -n "$RETPARAMS" | grep 'EXIT' | grep 'OK'`" = "" ] && exit
  109. enabledrepos=" "
  110. repocnt=1
  111. for ONEREPO in `echo "$DBFILESLIST" | tr '\n' ' '` #121129
  112. do
  113. REPOBASE="`basename $ONEREPO`"
  114. repoPATTERN="`echo -n "$REPOBASE" | sed -e 's%Packages\\-%%' | sed -e 's%\\-%\\\\-%g'`"
  115. if [ "`echo "$RETPARAMS" | grep "$repoPATTERN" | grep 'false'`" = "" ];then
  116. enabledrepos="${enabledrepos}${REPOBASE} "
  117. repocnt=`expr $repocnt + 1`
  118. #[ $repocnt -gt 5 ] && break #only allow 5 active repos in PPM. # SFR: no limit
  119. fi
  120. done
  121. grep -v '^PKG_REPOS_ENABLED' /root/.packages/PKGS_MANAGEMENT > /tmp/pkgs_management_tmp2
  122. mv -f /tmp/pkgs_management_tmp2 /root/.packages/PKGS_MANAGEMENT
  123. echo "PKG_REPOS_ENABLED='${enabledrepos}'" >> /root/.packages/PKGS_MANAGEMENT
  124. ###END###