configure.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. . gettext.sh
  17. #export LANG=C
  18. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  19. . /etc/rc.d/PUPSTATE
  20. . /root/.packages/DISTRO_PKGS_SPECS
  21. . /root/.packages/DISTRO_PET_REPOS
  22. . /root/.packages/PKGS_MANAGEMENT #has PKG_REPOS_ENABLED
  23. #find what repos are currently in use... 120510...
  24. CHECKBOXES_REPOS=""
  25. #for ONEREPO in `ls -1 /root/.packages/Packages-*`
  26. #120510 bugfix with ui_Ziggy. add CHECKBOX_MAIN_REPO var to gui
  27. MAIN_REPO="`ls -1 /root/.packages/Packages-* | grep "puppy\-${DISTRO_DB_SUBNAME}\-" | head -n 1 | sed 's%^/root/.packages/%%'`" #121102 121129
  28. #120515 hmmm, in some cases, Packages-puppy-${DISTRO_FILE_PREFIX}-* may not exist (ex, Racy only has Packages-puppy-wary5-official)...
  29. #121102 ...now using DISTRO_DB_SUBNAME, should always exist.
  30. [ "$MAIN_REPO" = "" ] && MAIN_REPO="`echo "$PACKAGELISTS_PET_ORDER" | tr ' ' '\n' | head -n 1`" #PACKAGELISTS_PET_ORDER is in /root/.packages/DISTRO_PET_REPOS.
  31. [ "$MAIN_REPO" = "" ] && MAIN_REPO="Packages-puppy-noarch-official" #paranoid precaution.
  32. bMAIN_PATTERN=' '"$MAIN_REPO"' '
  33. MAIN_DBNAME="`echo -n "$MAIN_REPO" | sed -e 's%Packages\-%%'`"
  34. CHECKBOX_MAIN_REPO="<checkbox><default>true</default><label>${MAIN_DBNAME}</label><variable>CHECK_${MAIN_DBNAME}</variable><visible>disabled</visible></checkbox>" #hard coded "true"
  35. DBFILESLIST="$(ls -1 /root/.packages/Packages-*)" #121129
  36. PKG_REPOS_ENABLED=" ${PKG_REPOS_ENABLED} " #121129 precaution.
  37. for ONEREPO in `echo "$DBFILESLIST" | grep -v "${MAIN_REPO}" | tr '\n' ' '` #120515 fix. 121129
  38. do
  39. BASEREPO="`basename $ONEREPO`"
  40. bPATTERN=' '"${BASEREPO}"' '
  41. DEFAULT='true'
  42. [ "`echo -n "$PKG_REPOS_ENABLED" | grep "$bPATTERN"`" = "" ] && DEFAULT='false'
  43. DBNAME="`echo -n "$BASEREPO" | sed -e 's%Packages\-%%'`"
  44. CHECKBOXES_REPOS="${CHECKBOXES_REPOS}<checkbox><default>${DEFAULT}</default><label>${DBNAME}</label><variable>CHECK_${DBNAME}</variable></checkbox>"
  45. done
  46. if [ "$(cat /tmp/pup_event_sizefreem | head -n 1 )" -gt 4000 ]; then
  47. [ -f /var/local/petget/sc_category ] && \
  48. CATEGORY_SC=$(cat /var/local/petget/sc_category) || CATEGORY_SC="false"
  49. SIZEBOX="<checkbox>
  50. <label>$(gettext 'Skip package size check when more than 4GB of storage is available')</label>
  51. <variable>CATEGORY_SC</variable>
  52. <default>${CATEGORY_SC}</default>
  53. </checkbox>"
  54. else
  55. SIZEBOX=''
  56. fi
  57. if [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ]; then
  58. [ -f /var/local/petget/sc_category ] && \
  59. CATEGORY_IM=$(cat /var/local/petget/install_mode) || CATEGORY_IM="false"
  60. IMODE="<checkbox>
  61. <label>$(gettext 'Install to tmpfs instead of the savefile, till session is saved')</label>
  62. <variable>CATEGORY_IM</variable>
  63. <default>${CATEGORY_IM}</default>
  64. </checkbox>"
  65. else
  66. IMODE=''
  67. fi
  68. # pet download folder
  69. SAVEPATH=""
  70. if [ -f /root/.packages/download_path ]; then
  71. . /root/.packages/download_path
  72. if [ -d "$DL_PATH" ];then
  73. DL_PATH="$DL_PATH"
  74. else
  75. DL_PATH=/root
  76. rm -f /root/.packages/download_path
  77. fi
  78. else
  79. DL_PATH=/root
  80. fi
  81. DBmethod="$(cat /var/local/petget/db_verbose)"
  82. if [ "$DBmethod" = "" ]; then
  83. echo true > /var/local/petget/db_verbose
  84. DBmethod=true
  85. fi
  86. if [ "$DBmethod" = "false" ]; then
  87. RXVT="rxvt -title \"$(gettext 'Updating Databases')\" -geometry 110x12+0+200 -bg gray -e "
  88. else
  89. RXVT="rxvt -bg yellow -title \"$(gettext 'Databases Update')\" -e "
  90. fi
  91. export SETUPCALLEDFROM='ppm'
  92. S='<window title="'$(gettext 'Puppy Package Manager - Configure')'" icon-name="gtk-about">
  93. <vbox space-expand="true" space-fill="true">
  94. <notebook tab-pos="2" labels="'$(gettext 'Choose repositories')'|'$(gettext 'Update database')'|'$(gettext 'Options')'" space-expand="true" space-fill="true">
  95. <vbox space-expand="true" space-fill="true">
  96. <frame '$(gettext 'Choose repositories')'>
  97. <vbox space-expand="false" space-fill="false">
  98. <hbox space-expand="true" space-fill="true">
  99. <text xalign="0" space-expand="true" space-fill="true"><label>"'$(gettext "Choose what repositories you would like to have appear in the main GUI window.")'"</label></text>
  100. <button image-position="2" tooltip-text="'$(gettext 'Adding a new repository currently requires manual editing of some text files. Click this button for further information:')'" space-expand="false" space-fill="false">
  101. '"`/usr/lib/gtkdialog/xml_button-icon help`"'
  102. <label>" '$(gettext 'Add new repo')'"</label>
  103. <action>nohup defaulthtmlviewer file:///usr/local/petget/README-add-repo.htm & </action>
  104. </button>
  105. </hbox>
  106. </vbox>
  107. <vbox space-expand="true" space-fill="true">
  108. <vbox scrollable="true" shadow-type="1">
  109. '${CHECKBOXES_REPOS}'
  110. '${CHECKBOX_MAIN_REPO}'
  111. </vbox>
  112. </vbox>
  113. </frame>
  114. </vbox>
  115. <vbox space-expand="true" space-fill="true">
  116. <frame '$(gettext 'Update database')'>
  117. <vbox space-expand="false" space-fill="false">
  118. <hbox space-expand="true" space-fill="true">
  119. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Puppy has a database file for each package repository. This downloads the latest information on what packages are in the repository')'</label></text>
  120. <button image-position="2" space-expand="false" space-fill="false">
  121. '"`/usr/lib/gtkdialog/xml_button-icon refresh`"'
  122. <label>'$(gettext 'Update now')'</label>
  123. <action>'${RXVT}' /usr/local/petget/0setup</action>
  124. <action>/usr/local/petget/configure.sh &</action>
  125. <action>exit:QUIT</action>
  126. </button>
  127. </hbox>
  128. <text space-expand="true" space-fill="true"><label>""</label></text>
  129. <hbox space-expand="true" space-fill="true">
  130. <hbox space-expand="false" space-fill="false">
  131. <vbox space-expand="true" space-fill="true">
  132. '"`/usr/lib/gtkdialog/xml_pixmap nb.svg`"'
  133. </vbox>
  134. </hbox>
  135. <text xalign="0" yalign="0" space-expand="true" space-fill="true"><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>
  136. </hbox>
  137. </vbox>
  138. <expander>
  139. <vbox space-expand="true" space-fill="true">
  140. <hbox space-expand="true" space-fill="true">
  141. <hbox space-expand="false" space-fill="false">
  142. <vbox space-expand="true" space-fill="true">
  143. '"`/usr/lib/gtkdialog/xml_pixmap info.svg`"'
  144. </vbox>
  145. </hbox>
  146. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext "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>
  147. </hbox>
  148. <hbox space-expand="true" space-fill="true">
  149. <hbox space-expand="false" space-fill="false">
  150. <vbox space-expand="true" space-fill="true">
  151. '"`/usr/lib/gtkdialog/xml_pixmap info.svg`"'
  152. </vbox>
  153. </hbox>
  154. <text xalign="0" space-expand="true" space-fill="true"><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>
  155. </hbox>
  156. </vbox>
  157. <label>'$(gettext 'More info')'</label>
  158. </expander>
  159. <text space-expand="true" space-fill="true"><label>""</label></text>
  160. </frame>
  161. </vbox>
  162. <vbox space-expand="true" space-fill="true">
  163. <frame '$(gettext 'Options')'>
  164. <checkbox>
  165. <label>'$(gettext "Show info with configuration changes as startup")'</label>
  166. <variable>CATEGORY_SI</variable>'
  167. [ "$(</var/local/petget/si_category)" = "true" ] && S=$S'<default>true</default>'
  168. S=$S'</checkbox>
  169. <checkbox>
  170. <label>'$(gettext "Enable BuildingBlock category (for advanced users only!)")'</label>
  171. <variable>CATEGORY_BB</variable>'
  172. [ "$(</var/local/petget/bb_category)" = "true" ] && S=$S'<default>true</default>'
  173. S=$S'</checkbox>
  174. <checkbox>
  175. <label>'$(gettext "Use traditional, non-auto, user interface")'</label>'
  176. [ "$(</var/local/petget/ui_choice)" = "Classic" ] && S=$S'<default>true</default>'
  177. S=$S'<action>if true echo Classic > /var/local/petget/ui_choice</action>
  178. <action>if false echo Ziggy > /var/local/petget/ui_choice</action>
  179. </checkbox>
  180. <checkbox>
  181. <label>'$(gettext "Use the tall version of the new UI (better for small screens)")'</label>'
  182. [ "$(</var/local/petget/uo_choice)" = "tall" ] && S=$S'<default>true</default>'
  183. S=$S'<action>if true echo tall > /var/local/petget/uo_choice</action>
  184. <action>if false echo wide > /var/local/petget/uo_choice</action>
  185. </checkbox>
  186. '${SIZEBOX}'
  187. <checkbox>
  188. <label>'$(gettext "Do not show the terminal with PPM actions")'</label>
  189. <variable>CATEGORY_NT</variable>'
  190. [ "$(</var/local/petget/nt_category)" = "true" ] && S=$S'<default>true</default>'
  191. S=$S'</checkbox>
  192. '${IMODE}'
  193. <checkbox>
  194. <label>'$(gettext "Always redownload packages when they preexist")'</label>
  195. <variable>CATEGORY_RD</variable>'
  196. [ "$(</var/local/petget/rd_category)" = "true" ] && S=$S'<default>true</default>'
  197. S=$S'</checkbox>
  198. <checkbox>
  199. <label>'$(gettext "Do not delete downloaded packages after installation")'</label>
  200. <variable>CATEGORY_ND</variable>'
  201. [ "$(</var/local/petget/nd_category)" = "true" ] && S=$S'<default>true</default>'
  202. S=$S'</checkbox>
  203. <checkbox tooltip-text="'$(gettext "Verbose method = the user indicates the package databases to update.
  204. +Silent method = all package databases are automatically updated.")'">
  205. <label>'$(gettext "Use verbose method during update of the package databases")'</label>
  206. <default>'$DBmethod'</default>
  207. <variable>DBmethod</variable>
  208. <action>if true echo true > /var/local/petget/db_verbose</action>
  209. <action>if false echo false > /var/local/petget/db_verbose</action>
  210. <action>/usr/local/petget/configure.sh &</action>
  211. <action>exit:QUIT</action>
  212. </checkbox>
  213. <hbox>
  214. <text width-request="100"><label>'$(gettext "Save PKGs in:")'</label></text>
  215. <entry accept="folder" width-request="200" tooltip-text="'$(gettext "To change, type a path to a folder or use the button to select a folder. Delete the present path to default back to /root")'"><default>'${DL_PATH}'</default><variable>SAVEPATH</variable></entry>
  216. <button>
  217. <input file stock="gtk-open"></input>
  218. <action type="fileselect">SAVEPATH</action>
  219. </button>
  220. </hbox>
  221. </frame>
  222. </vbox>
  223. </notebook>
  224. <vbox space-expand="false" space-fill="false">
  225. <hbox space-expand="true" space-fill="true">
  226. <text space-expand="true" space-fill="true"><label>""</label></text>
  227. <hbox space-expand="false" space-fill="false">
  228. <button>
  229. '"`/usr/lib/gtkdialog/xml_button-icon cancel`"'
  230. <label>" '$(gettext 'Cancel')' "</label>
  231. <action>EXIT:cancel</action>
  232. </button>
  233. <button>
  234. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  235. <label>" '$(gettext 'Ok')' "</label>
  236. <action>EXIT:OK</action>
  237. </button>
  238. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  239. </hbox>
  240. </hbox>
  241. </vbox>
  242. </vbox>
  243. </window>'
  244. export PPM_CONFIG="$S"
  245. #echo "$PPM_CONFIG" > /root/gtk
  246. RETPARAMS="`gtkdialog -p PPM_CONFIG`"
  247. #ex:
  248. # CHECK_puppy-2-official="false"
  249. # CHECK_puppy-3-official="true"
  250. # CHECK_puppy-4-official="true"
  251. # CHECK_puppy-woof-official="false"
  252. # CHECK_ubuntu-intrepid-main="true"
  253. # CHECK_ubuntu-intrepid-multiverse="true"
  254. # CHECK_ubuntu-intrepid-universe="true"
  255. # EXIT="OK"
  256. [ "`echo -n "$RETPARAMS" | grep 'EXIT' | grep 'OK'`" = "" ] && exit
  257. echo -n "$RETPARAMS" | grep 'CATEGORY_BB' | cut -d= -f2 | tr -d '"' > /var/local/petget/bb_category
  258. echo -n "$RETPARAMS" | grep 'CATEGORY_SC' | cut -d= -f2 | tr -d '"' > /var/local/petget/sc_category
  259. echo -n "$RETPARAMS" | grep 'CATEGORY_NT' | cut -d= -f2 | tr -d '"' > /var/local/petget/nt_category
  260. echo -n "$RETPARAMS" | grep 'CATEGORY_RD' | cut -d= -f2 | tr -d '"' > /var/local/petget/rd_category
  261. echo -n "$RETPARAMS" | grep 'CATEGORY_ND' | cut -d= -f2 | tr -d '"' > /var/local/petget/nd_category
  262. echo -n "$RETPARAMS" | grep 'CATEGORY_SI' | cut -d= -f2 | tr -d '"' > /var/local/petget/si_category
  263. # handle install mode
  264. if [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ]; then
  265. echo -n "$RETPARAMS" | grep 'CATEGORY_IM' | cut -d= -f2 | tr -d '"' > /var/local/petget/install_mode
  266. fi
  267. # handle savepath
  268. SAVEPATH="`echo -n "$RETPARAMS" | grep 'SAVEPATH' | cut -f 2 -d '"'`"
  269. if [ "$SAVEPATH" = "" ];then
  270. rm -f /root/.packages/download_path
  271. else
  272. if [ ! -d "$SAVEPATH" ]; then
  273. mkdir -p "$SAVEPATH"
  274. [ $? -eq 0 ] && echo DL_PATH=\'$SAVEPATH\' > /root/.packages/download_path
  275. elif [ -w "$SAVEPATH" ]; then
  276. echo DL_PATH=\'$SAVEPATH\' > /root/.packages/download_path
  277. else
  278. rm -f /root/.packages/download_path
  279. fi
  280. fi
  281. enabledrepos=" "
  282. #repocnt=1
  283. for ONEREPO in `echo "$DBFILESLIST" | tr '\n' ' '` #121129
  284. do
  285. REPOBASE="`basename $ONEREPO`"
  286. repoPATTERN="`echo -n "$REPOBASE" | sed -e 's%Packages\\-%%' | sed -e 's%\\-%\\\\-%g'`"
  287. if [ "`echo "$RETPARAMS" | grep "$repoPATTERN" | grep 'false'`" = "" ];then
  288. enabledrepos="${enabledrepos}${REPOBASE} "
  289. # repocnt=`expr $repocnt + 1`
  290. # [ $repocnt -gt 5 ] && break #only allow 5 active repos in PPM.
  291. fi
  292. done
  293. grep -v '^PKG_REPOS_ENABLED' /root/.packages/PKGS_MANAGEMENT > /tmp/pkgs_management_tmp2
  294. mv -f /tmp/pkgs_management_tmp2 /root/.packages/PKGS_MANAGEMENT
  295. echo "PKG_REPOS_ENABLED='${enabledrepos}'" >> /root/.packages/PKGS_MANAGEMENT
  296. for I in `grep -E "PPM_GUI|pkg_chooser|/usr/local/bin/ppm" <<< "$(ps -eo pid,command)" | awk '{print $1}' `; do kill -9 $I; done
  297. sleep 0.5
  298. /usr/local/petget/pkg_chooser.sh &
  299. ###END###