installpkg.sh 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  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/downloadpkgs.sh and petget.
  5. #passed param is the path and name of the downloaded package.
  6. #/tmp/petget_missing_dbentries-Packages-* has database entries for the set of pkgs being downloaded.
  7. #w456 warning: petget may write to /tmp/petget_missing_dbentries-Packages-alien with missing fields.
  8. #w478, w482 fix for pkg menu categories.
  9. #w482 detect zero-byte pet.specs, fix typo.
  10. #100110 add support for T2 .tar.bz2 binary packages.
  11. #100426 aufs can now write direct to save layer.
  12. #100616 add support for .txz slackware pkgs.
  13. # 20aug10 shinobar: excute pinstall.sh under original LANG environment
  14. # 6sep10 shinobar: warning to install on /mnt/home # 16sep10 remove test code
  15. # 17sep10 shinobar; fix typo was double '|' at reading DESCRIPTION
  16. # 22sep10 shinobar clean up probable old files for precaution
  17. # 22sep10 shinobar: bugfix was not working clean out whiteout files
  18. #110503 change ownership of some files if non-root.
  19. #110523 support for rpm pkgs.
  20. #110705 fix rpm install.
  21. #110817 rcrsn51: fix find syntax, looking for icons. 110821 improve.
  22. #111013 shinobar: aufs direct-write to layer not working, bypass for now.
  23. #111013 revert above. it works for me, except if file already on top -- that is another problem, needs to be addressed.
  24. #111207 improve search for menu icon.
  25. #111229 /usr/local/petget/removepreview.sh when uninstalling a pkg, may have copied a file from sfs-layer to top, check.
  26. #120102 install may have overwritten a symlink-to-dir.
  27. #120107 rerwin: need quotes around some paths in case of space chars. remove '--unlink-first' from tar (was introduced 120102, don't think necessary).
  28. #120126 noryb009: fix typo.
  29. #120219 was not properly internationalized (there was no TEXTDOMAIN).
  30. #120523 may need to run gio-query-modules and/or glib-compile-schemas. (refer also rc.update and 3builddistro)
  31. #120628 fix Categories= assignment in .desktop files. see also 2createpackages in woof.
  32. #120818 Categories management improved. pkg db now has category[;subcategory] (see 0setup), xdg enhanced (see /etc/xdg and /usr/share/desktop-directories), and generic icons for all subcategories (see /usr/local/lib/X11/mini-icons).
  33. #120901 .desktop files, get rid of param on end of Exec, ex: Exec=gimp-2.8 %U
  34. #120907 post-install hacks.
  35. #120926 apply translation for .desktop file if langpack installed.
  36. #121015 01micko: alternative code to delete %-param off end of Exec line in .desktop file.
  37. #121109 fixing Categories field in .desktop may fail, as DB_category field may not match that in .desktop file, so leave out that $tPATTERN match in $PUPHIERARCHY.
  38. #121109 menu category was not reported correctly in post-install window.
  39. #121119 change in layout of /etc/xdg/menus/hierarchy caused regex pattern bug.
  40. #121119 if only one .desktop file, first check if a match in /usr/local/petget/categories.dat.
  41. #121120 bugfix of 121119.
  42. #121123 having a problem with multiarch symlinks in full-installation, getting replaced by a directory.
  43. #121206 default icon needs .xpm extension. note puppy uses older xdg-utilities, Icon field needs image ext.
  44. #121217 still getting reports multiarch symlinks getting overwritten.
  45. #130112 some deb's have a post-install script (ex: some python debs).
  46. #130112 multiarch symlinks now optional. see also 2createpackages, 3builddistro.
  47. #130114 revert 130112 "multiarch symlinks now optional".
  48. #130126 'categories.dat' format changed.
  49. #130219 grep, ignore case.
  50. #130305 rerwin: ensure tmp directory has all permissions after package expansion.
  51. #130314 install arch linux pkgs. run arch linux pkg post-install script.
  52. #131122 support xz compressed pets (see dir2pet, pet2tgz), changed file test
  53. export TEXTDOMAIN=petget___installpkg.sh
  54. export OUTPUT_CHARSET=UTF-8
  55. APPDIR=$(dirname $0)
  56. [ -f "$APPDIR/i18n_head" ] && source "$APPDIR/i18n_head"
  57. LANG_USER=$LANG
  58. export LANG=C
  59. . /etc/rc.d/PUPSTATE #this has PUPMODE and SAVE_LAYER.
  60. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  61. . /etc/xdg/menus/hierarchy #w478 has PUPHIERARCHY variable.
  62. [ "$PUPMODE" = "2" ] && [ ! -d /audit ] && mkdir -p /audit
  63. DLPKG="$1"
  64. DLPKG_BASE="`basename $DLPKG`" #ex: scite-1.77-i686-2as.tgz
  65. DLPKG_PATH="`dirname $DLPKG`" #ex: /root
  66. # 6sep10 shinobar: installing files under /mnt is danger
  67. install_path_check() {
  68. FILELIST="/root/.packages/${DLPKG_NAME}.files"
  69. [ -s "$FILELIST" ] || return 0 #120126 noryb009: typo
  70. grep -q '^/mnt' "$FILELIST" || return 0
  71. MNTDIRS=$(cat "$FILELIST" | grep '^/mnt/.*/$' | cut -d'/' -f1-3 | tail -n 1)
  72. LANG=$LANG_USER
  73. MSG1=$(gettext "This package will install files under")
  74. MSG2=$(gettext "It can be dangerous to install files under '/mnt' because it depends on the profile of installation.")
  75. MSG3=""
  76. if grep -q '^/mnt/home' "$FILELIST"; then
  77. if [ $PUPMODE -eq 5 ]; then
  78. MSG3=$(gettext "You are running Puppy without 'pupsave', and '/mnt/home' does not exist. In this case, you can use the RAM for this space, but strongly recommended to shutdown now to create 'pupsave' BEFORE installing these packages.")
  79. MSG3="$MSG3\\n$(gettext "NOTE: You can install this package for a tentative use, then do NOT make 'pupsave' with this package installed.")"
  80. fi
  81. DIRECTSAVEPATH=""
  82. fi
  83. # dialog
  84. export DIALOG="<window title=\"$T_title\" icon-name=\"gtk-dialog-warning\">
  85. <vbox>
  86. <text use-markup=\"true\"><label>\"$MSG1: <b>$MNTDIRS</b>\"</label></text>
  87. <text><input>echo -en \"$MSG2 $MSG3\"</input></text>
  88. <text><label>$(gettext "Click 'Cancel' not to install(recommended). Or click 'Install' if you like to proceed.")</label></text>
  89. <hbox>
  90. <button cancel></button>
  91. <button><input file stock=\"gtk-apply\"></input><label>$(gettext 'Install')</label><action type=\"exit\">INSTALL</action></button>
  92. </hbox>
  93. </vbox>
  94. </window>"
  95. RETPARAMS=`gtkdialog3 --program=DIALOG` || echo "$DIALOG" >&2
  96. eval "$RETPARAMS"
  97. LANG=C
  98. [ "$EXIT" = "INSTALL" ] && return 0
  99. rm -f "$FILELIST"
  100. exit 1
  101. }
  102. # 22sep10 shinobar clean up probable old files for precaution
  103. rm -f /pet.specs /pinstall.sh /puninstall.sh /install/doinst.sh
  104. #get the pkg name ex: scite-1.77 ...
  105. dbPATTERN='|'"$DLPKG_BASE"'|'
  106. DLPKG_NAME="`cat /tmp/petget_missing_dbentries-Packages-* | grep "$dbPATTERN" | head -n 1 | cut -f 1 -d '|'`"
  107. #131222 do not allow duplicate installs...
  108. PTN1='^'"$DLPKG_NAME"'|'
  109. if [ "`grep "$PTN1" /root/.packages/user-installed-packages`" != "" ];then
  110. if [ ! $DISPLAY ];then
  111. echo "$(gettext 'Sorry, this package is already installed. Aborting.')"
  112. else
  113. pupmessage -bg '#ff8080' -fg black -title "$(gettext 'Package:') ${DLPKG_NAME}" "$(gettext 'Sorry, but this package is already installed. Cannot install it twice.')"
  114. fi
  115. exit 1
  116. fi
  117. #boot from flash: bypass tmpfs top layer, install direct to pup_save file...
  118. DIRECTSAVEPATH=""
  119. if [ "$PUPMODE" = "2" ]; then # from BK's quirky6.1
  120. #131220 131229 detect if not enough room in /tmp...
  121. DIRECTSAVEPATH="/tmp/petget/directsavepath"
  122. SIZEB=`stat --format=%s ${DLPKG_PATH}/${DLPKG_BASE}`
  123. SIZEK=`expr $SIZEB \/ 1024`
  124. EXPK=`expr $SIZEK \* 5` #estimated worst-case expanded size.
  125. NEEDK=$EXPK
  126. TMPK=`df -k /tmp | grep '^tmpfs' | tr -s ' ' | cut -f 4 -d ' '` #free space in /tmp
  127. if [ $EXPK -ge $TMPK ];then
  128. DIRECTSAVEPATH="/audit/directsavepath"
  129. NEEDK=`expr $NEEDK \* 2`
  130. fi
  131. if [ "$DIRECTSAVEPATH" ];then
  132. rm -rf $DIRECTSAVEPATH
  133. mkdir -p $DIRECTSAVEPATH
  134. fi
  135. # check enough space to install pkg...
  136. #as the pkg gets expanded to an intermediate dir, maybe in main f.s...
  137. PARTK=`df -k / | grep '/$' | tr -s ' ' | cut -f 4 -d ' '` #free space in partition.
  138. if [ $NEEDK -gt $PARTK ];then
  139. ABORTMSG1="$(gettext 'Package:') ${DLPKG_BASE}"
  140. ABORTMSG2="$(gettext 'Sorry, there is not enough free space in the partition to install this package')"
  141. if [ $DISPLAY ];then
  142. pupmessage -bg pink -fg black -title "${ABORTMSG1}" "${ABORTMSG2}"
  143. else
  144. echo "${ABORTMSG1}
  145. ${ABORTMSG2}"
  146. fi
  147. [ "$DLPKG_PATH" = "/root" ] && rm -f ${DLPKG_PATH}/${DLPKG_BASE}
  148. exit 1
  149. fi
  150. #111013 shinobar: this currently not working, bypass for now... 111013 revert...
  151. #if [ "ABC" = "DEF" ];then #111013
  152. elif [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ];then
  153. FLAGNODIRECT=1
  154. [ "`lsmod | grep '^unionfs' `" != "" ] && FLAGNODIRECT=0
  155. #100426 aufs can now write direct to save layer...
  156. if [ "`lsmod | grep '^aufs' `" != "" ];then
  157. #note: fsnotify now preferred not inotify, udba=notify uses whichever is enabled in module...
  158. busybox mount -t aufs -o remount,udba=notify unionfs / #remount aufs with best evaluation mode.
  159. FLAGNODIRECT=$?
  160. [ $FLAGNODIRECT -ne 0 ] && logger -s -t "installpkg.sh" "Failed to remount aufs / with udba=notify"
  161. fi
  162. if [ $FLAGNODIRECT -eq 0 ];then
  163. #note that /sbin/pup_event_frontend_d will not run snapmergepuppy if installpkg.sh or downloadpkgs.sh are running.
  164. while [ "`pidof snapmergepuppy`" != "" ];do
  165. sleep 1
  166. done
  167. DIRECTSAVEPATH="/initrd${SAVE_LAYER}" #SAVE_LAYER is in /etc/rc.d/PUPSTATE.
  168. rm -f $DIRECTSAVEPATH/pet.specs $DIRECTSAVEPATH/pinstall.sh $DIRECTSAVEPATH/puninstall.sh $DIRECTSAVEPATH/install/doinst.sh
  169. fi
  170. fi
  171. if [ $DISPLAY ];then #131222
  172. yaf-splash -bg orange -fg black -close never -fontsize large -text "$(gettext 'Please wait, processing...')" &
  173. YAFPID1=$!
  174. trap 'pupkill $YAFPID1' EXIT #140318
  175. fi
  176. cd $DLPKG_PATH
  177. case $DLPKG_BASE in
  178. *.pet)
  179. # determine compression
  180. file -b "$DLPKG_BASE" | grep -i -q "^xz" && EXT=xz || EXT=gz #131122 #140109 add -i, eg: "XZ"
  181. case $EXT in
  182. xz)OPT=-J ;;
  183. gz)OPT=-z ;;
  184. esac
  185. DLPKG_MAIN="`basename $DLPKG_BASE .pet`"
  186. pet2tgz $DLPKG_BASE
  187. [ $? -ne 0 ] && exit 1
  188. PETFILES="`tar --list ${OPT} -f ${DLPKG_MAIN}.tar.${EXT}`"
  189. #slackware pkg, got a case where passed the above test but failed here...
  190. [ $? -ne 0 ] && exit 1
  191. if [ "`echo "$PETFILES" | grep '^\\./'`" != "" ];then
  192. #ttuuxx has created some pets with './' prefix...
  193. pPATTERN="s%^\\./${DLPKG_NAME}%%"
  194. echo "$PETFILES" | sed -e "$pPATTERN" > /root/.packages/${DLPKG_NAME}.files
  195. install_path_check
  196. tar ${OPT} -x --strip=2 --directory=${DIRECTSAVEPATH}/ -f ${DLPKG_MAIN}.tar.${EXT} #120102. 120107 remove --unlink-first
  197. else
  198. #new2dir and tgz2pet creates them this way...
  199. pPATTERN="s%^${DLPKG_NAME}%%"
  200. echo "$PETFILES" | sed -e "$pPATTERN" > /root/.packages/${DLPKG_NAME}.files
  201. install_path_check
  202. tar ${OPT} -x --strip=1 --directory=${DIRECTSAVEPATH}/ -f ${DLPKG_MAIN}.tar.${EXT} #120102. 120107. 131122
  203. fi
  204. ;;
  205. *.deb)
  206. DLPKG_MAIN="`basename $DLPKG_BASE .deb`"
  207. PFILES="`dpkg-deb --contents $DLPKG_BASE | tr -s ' ' | cut -f 6 -d ' '`"
  208. [ $? -ne 0 ] && exit 1
  209. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  210. install_path_check
  211. dpkg-deb -x $DLPKG_BASE ${DIRECTSAVEPATH}/
  212. if [ $? -ne 0 ];then
  213. rm -f /root/.packages/${DLPKG_NAME}.files
  214. exit 1
  215. fi
  216. [ -d /DEBIAN ] && rm -rf /DEBIAN #130112 precaution.
  217. dpkg-deb -e $DLPKG_BASE /DEBIAN #130112 extracts deb control files to dir /DEBIAN. may have a post-install script, see below.
  218. ;;
  219. *.tgz)
  220. DLPKG_MAIN="`basename $DLPKG_BASE .tgz`" #ex: scite-1.77-i686-2as
  221. gzip --test $DLPKG_BASE > /dev/null 2>&1
  222. [ $? -ne 0 ] && exit 1
  223. PFILES="`tar --list -z -f $DLPKG_BASE`"
  224. #hmmm, got a case where passed the above test but failed here...
  225. [ $? -ne 0 ] && exit 1
  226. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  227. install_path_check
  228. tar -z -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE #120102. 120107
  229. ;;
  230. *.txz) #100616
  231. DLPKG_MAIN="`basename $DLPKG_BASE .txz`" #ex: scite-1.77-i686-2as
  232. xz --test $DLPKG_BASE > /dev/null 2>&1
  233. [ $? -ne 0 ] && exit 1
  234. PFILES="`tar --list -J -f $DLPKG_BASE`"
  235. #hmmm, got a case where passed the above test but failed here...
  236. [ $? -ne 0 ] && exit 1
  237. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  238. install_path_check
  239. tar -J -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE #120102. 120107
  240. ;;
  241. *.tar.gz)
  242. DLPKG_MAIN="`basename $DLPKG_BASE .tar.gz`" #ex: acl-2.2.47-1-i686.pkg
  243. gzip --test $DLPKG_BASE > /dev/null 2>&1
  244. [ $? -ne 0 ] && exit 1
  245. PFILES="`tar --list -z -f $DLPKG_BASE`"
  246. [ $? -ne 0 ] && exit 1
  247. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  248. install_path_check
  249. tar -z -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE #120102. 120107
  250. ;;
  251. *.tar.bz2) #100110
  252. DLPKG_MAIN="`basename $DLPKG_BASE .tar.bz2`"
  253. bzip2 --test $DLPKG_BASE > /dev/null 2>&1
  254. [ $? -ne 0 ] && exit 1
  255. PFILES="`tar --list -j -f $DLPKG_BASE`"
  256. [ $? -ne 0 ] && exit 1
  257. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  258. install_path_check
  259. tar -j -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE #120102. 120107
  260. ;;
  261. *.pkg.tar.zx) #130314 arch pkgs.
  262. DLPKG_MAIN="`basename $DLPKG_BASE .pkg.tar.xz`" #ex: acl-2.2.51-3-i686
  263. xz --test $DLPKG_BASE > /dev/null 2>&1
  264. [ $? -ne 0 ] && exit 1
  265. PFILES="`tar --list -J -f $DLPKG_BASE`"
  266. #hmmm, got a case where passed the above test but failed here...
  267. [ $? -ne 0 ] && exit 1
  268. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  269. install_path_check
  270. tar -J -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE
  271. ;;
  272. *.rpm) #110523
  273. DLPKG_MAIN="`basename $DLPKG_BASE .rpm`"
  274. busybox rpm -qp $DLPKG_BASE > /dev/null 2>&1
  275. [ $? -ne 0 ] && exit 1
  276. PFILES="`busybox rpm -qpl $DLPKG_BASE`"
  277. [ $? -ne 0 ] && exit 1
  278. echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  279. install_path_check
  280. #110705 rpm -i does not work for mageia pkgs...
  281. exploderpm -i $DLPKG_BASE
  282. ;;
  283. esac
  284. if [ "$PUPMODE" = "2" ]; then #from BK's quirky6.1
  285. mkdir /audit/${DLPKG_NAME}DEPOSED
  286. echo -n '' > /tmp/petget/FLAGFND
  287. find ${DIRECTSAVEPATH}/ -mindepth 1 | sed -e "s%${DIRECTSAVEPATH}%%" |
  288. while read AFILESPEC
  289. do
  290. if [ -f "$AFILESPEC" ];then
  291. ADIR="$(dirname "$AFILESPEC")"
  292. mkdir -p /audit/${DLPKG_NAME}DEPOSED/${ADIR}
  293. cp -a -f "$AFILESPEC" /audit/${DLPKG_NAME}DEPOSED/${ADIR}/
  294. echo -n '1' > /tmp/petget/FLAGFND
  295. fi
  296. done
  297. sync
  298. if [ -s /tmp/petget/FLAGFND ];then
  299. [ -f /audit/${DLPKG_NAME}DEPOSED.sfs ] && rm -f /audit/${DLPKG_NAME}DEPOSED.sfs #precaution, should not happen, as not allowing duplicate installs of same pkg.
  300. mksquashfs /audit/${DLPKG_NAME}DEPOSED /audit/${DLPKG_NAME}DEPOSED.sfs
  301. fi
  302. sync
  303. rm -rf /audit/${DLPKG_NAME}DEPOSED
  304. #now write temp-location to final destination...
  305. cp -a -f --remove-destination ${DIRECTSAVEPATH}/* / 2> /tmp/petget/install-cp-errlog
  306. sync
  307. #can have a problem if want to replace a folder with a symlink. for example, got this error:
  308. # cp: cannot overwrite directory '/usr/share/mplayer/skins' with non-directory
  309. #3builddistro has this fix... which is a vice-versa situation...
  310. #firstly, the vice-versa, source is a directory, target is a symlink...
  311. CNT=0
  312. while [ -s /tmp/petget/install-cp-errlog ];do
  313. echo -n '' > /tmp/petget/install-cp-errlog2
  314. echo -n '' > /tmp/petget/install-cp-errlog3
  315. cat /tmp/petget/install-cp-errlog | grep 'cannot overwrite non-directory' | grep 'with directory' | tr '[`‘’]' "'" | cut -f 2 -d "'" |
  316. while read ONEDIRSYMLINK #ex: /usr/share/mplayer/skins
  317. do
  318. if [ -h "${ONEDIRSYMLINK}" ];then #source is a directory, target is a symlink...
  319. #adding that extra trailing / does the trick...
  320. cp -a -f --remove-destination ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}"/* "${ONEDIRSYMLINK}"/ 2>> /tmp/petget/install-cp-errlog2
  321. else #source is a directory, target is a file...
  322. rm -f "${ONEDIRSYMLINK}" #delete the file!
  323. DIRPATH="$(dirname "${ONEDIRSYMLINK}")"
  324. cp -a -f ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}" "${DIRPATH}"/ 2>> /tmp/petget/install-cp-errlog2 #copy directory (and contents).
  325. fi
  326. done
  327. #secondly, which is our mplayer example, source is a symlink, target is a folder...
  328. cat /tmp/petget/install-cp-errlog | grep 'cannot overwrite directory' | grep 'with non-directory' | tr '[`‘’]' "'" | cut -f 2 -d "'" |
  329. while read ONEDIRSYMLINK #ex: /usr/share/mplayer/skins
  330. do
  331. #difficult situation, whether to impose the symlink of package, or not. if not...
  332. #cp -a -f --remove-destination ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}"/* "${ONEDIRSYMLINK}"/ 2> /tmp/petget/install-cp-errlog3
  333. #or, if we have chosen to follow link...
  334. DIRPATH="$(dirname "${ONEDIRSYMLINK}")"
  335. if [ -h ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}" ];then #source is a symlink, trying to overwrite a directory...
  336. ALINK="$(readlink ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}")"
  337. if [ "${ALINK:0:1}" = "/" ];then #test 1st char
  338. xALINK="$ALINK" #absolute
  339. else
  340. xALINK="${DIRPATH}/${ALINK}"
  341. fi
  342. if [ -d "$xALINK" ];then
  343. cp -a -f --remove-destination "${ONEDIRSYMLINK}"/* "$xALINK"/ 2>> /tmp/petget/install-cp-errlog3 #relocates target files.
  344. rm -rf "${ONEDIRSYMLINK}"
  345. cp -a -f ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}" "${DIRPATH}"/ #creates symlink only.
  346. fi
  347. else #source is a file, trying to overwrite a directory...
  348. rm -rf "${ONEDIRSYMLINK}" #deleting directory!!!
  349. cp -a -f ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}" "${DIRPATH}"/ #creates file only.
  350. fi
  351. done
  352. cat /tmp/petget/install-cp-errlog2 >> /tmp/petget/install-cp-errlog3
  353. cat /tmp/petget/install-cp-errlog3 > /tmp/petget/install-cp-errlog
  354. sync
  355. CNT=`expr $CNT + 1`
  356. [ $CNT -gt 10 ] && break #something wrong, get out.
  357. done
  358. #end 131220
  359. rm -rf ${DIRECTSAVEPATH} #131229 131230
  360. rm -f $DLPKG_BASE 2>/dev/null
  361. rm -f $DLPKG_MAIN.tar.gz 2>/dev/null
  362. #pkgname.files may need to be fixed...
  363. FIXEDFILES="`cat /root/.packages/${DLPKG_NAME}.files | grep -v '^\\./$'| grep -v '^/$' | sed -e 's%^\\.%%' -e 's%^%/%' -e 's%^//%/%'`"
  364. echo "$FIXEDFILES" > /root/.packages/${DLPKG_NAME}.files
  365. else
  366. rm -f $DLPKG_BASE 2>/dev/null
  367. rm -f $DLPKG_MAIN.tar.${EXT} 2>/dev/null #131122
  368. #pkgname.files may need to be fixed...
  369. FIXEDFILES="`cat /root/.packages/${DLPKG_NAME}.files | grep -v '^\\./$'| grep -v '^/$' | sed -e 's%^\\.%%' -e 's%^%/%' -e 's%^//%/%'`"
  370. echo "$FIXEDFILES" > /root/.packages/${DLPKG_NAME}.files
  371. #120102 install may have overwritten a symlink-to-dir...
  372. #tar defaults to not following symlinks, for both dirs and files, but i want to follow symlinks
  373. #for dirs but not for files. so, fix here... (note, dir entries in .files have / on end)
  374. cat /root/.packages/${DLPKG_NAME}.files | grep '[a-zA-Z0-9]/$' | sed -e 's%/$%%' | grep -v '^/mnt' |
  375. while read ONESPEC
  376. do
  377. if [ -d "${DIRECTSAVEPATH}${ONESPEC}" ];then
  378. if [ ! -h "${DIRECTSAVEPATH}${ONESPEC}" ];then
  379. DIRLINK=""
  380. if [ -h "/initrd${PUP_LAYER}${ONESPEC}" ];then #120107
  381. DIRLINK="`readlink -m "/initrd${PUP_LAYER}${ONESPEC}" | sed -e "s%/initrd${PUP_LAYER}%%"`" #PUP_LAYER: see /etc/rc.d/PUPSTATE. 120107
  382. xDIRLINK="`readlink "/initrd${PUP_LAYER}${ONESPEC}"`" #120107
  383. fi
  384. if [ ! "$DIRLINK" ];then
  385. if [ -h "/initrd${SAVE_LAYER}${ONESPEC}" ];then #120107
  386. DIRLINK="`readlink -m "/initrd${SAVE_LAYER}${ONESPEC}" | sed -e "s%/initrd${SAVE_LAYER}%%"`" #SAVE_LAYER: see /etc/rc.d/PUPSTATE. 120107
  387. xDIRLINK="`readlink "/initrd${SAVE_LAYER}${ONESPEC}"`" #120107
  388. fi
  389. fi
  390. if [ "$DIRLINK" ];then
  391. if [ -d "$DIRLINK" ];then
  392. if [ "$DIRLINK" != "${ONESPEC}" ];then #precaution.
  393. mkdir -p "${DIRECTSAVEPATH}${DIRLINK}" #120107
  394. cp -a -f --remove-destination ${DIRECTSAVEPATH}"${ONESPEC}"/* "${DIRECTSAVEPATH}${DIRLINK}/" #ha! fails if put double-quotes around entire expression.
  395. rm -rf "${DIRECTSAVEPATH}${ONESPEC}"
  396. if [ "$DIRECTSAVEPATH" = "" ];then
  397. ln -s "$xDIRLINK" "${ONESPEC}"
  398. else
  399. DSOPATH="`dirname "${DIRECTSAVEPATH}${ONESPEC}"`"
  400. DSOBASE="`basename "${DIRECTSAVEPATH}${ONESPEC}"`"
  401. rm -f "${DSOPATH}/.wh.${DSOBASE}" #allow underlying symlink to become visible on top.
  402. fi
  403. fi
  404. fi
  405. fi
  406. fi
  407. fi
  408. done
  409. #121217 it seems that this problem is occurring in other modes (13 reported)...
  410. #121123 having a problem with multiarch symlinks in full-installation...
  411. #it seems that the symlink is getting replaced by a directory.
  412. if [ "$DISTRO_ARCHDIR" ];then #in /etc/rc.d/DISTRO_SPECS. 130112 change test from DISTRO_ARCHDIR. 130114 revert DISTRO_ARCHDIR_SYMLINKS==yes.
  413. if [ -d /usr/lib/${DISTRO_ARCHDIR} ];then
  414. if [ ! -h /usr/lib/${DISTRO_ARCHDIR} ];then
  415. cp -a -f --remove-destination /usr/lib/${DISTRO_ARCHDIR}/* /usr/lib/
  416. sync
  417. rm -r -f /usr/lib/${DISTRO_ARCHDIR}
  418. ln -s ./ /usr/lib/${DISTRO_ARCHDIR}
  419. fi
  420. fi
  421. if [ -d /lib/${DISTRO_ARCHDIR} ];then
  422. if [ ! -h /lib/${DISTRO_ARCHDIR} ];then
  423. cp -a -f --remove-destination /lib/${DISTRO_ARCHDIR}/* /lib/
  424. sync
  425. rm -r -f /lib/${DISTRO_ARCHDIR}
  426. ln -s ./ /lib/${DISTRO_ARCHDIR}
  427. fi
  428. fi
  429. if [ -d /usr/bin/${DISTRO_ARCHDIR} ];then
  430. if [ ! -h /usr/bin/${DISTRO_ARCHDIR} ];then
  431. cp -a -f --remove-destination /usr/bin/${DISTRO_ARCHDIR}/* /usr/bin/
  432. sync
  433. rm -r -f /usr/bin/${DISTRO_ARCHDIR}
  434. ln -s ./ /usr/bin/${DISTRO_ARCHDIR}
  435. fi
  436. fi
  437. fi
  438. #flush unionfs cache, so files in pup_save layer will appear "on top"...
  439. if [ "$DIRECTSAVEPATH" != "" ];then
  440. #but first, clean out any bad whiteout files...
  441. # 22sep10 shinobar: bugfix was not working clean out whiteout files
  442. find /initrd/pup_rw -mount -type f -name .wh.\* -printf '/%P\n'|
  443. while read ONEWHITEOUT
  444. do
  445. ONEWHITEOUTFILE="`basename "$ONEWHITEOUT"`"
  446. ONEWHITEOUTPATH="`dirname "$ONEWHITEOUT"`"
  447. if [ "$ONEWHITEOUTFILE" = ".wh.__dir_opaque" ];then
  448. [ "`grep "$ONEWHITEOUTPATH" /root/.packages/${DLPKG_NAME}.files`" != "" ] && rm -f "/initrd/pup_rw/$ONEWHITEOUT"
  449. continue
  450. fi
  451. ONEPATTERN="`echo -n "$ONEWHITEOUT" | sed -e 's%/\\.wh\\.%/%'`"'/*' ;#echo "$ONEPATTERN" >&2
  452. [ "`grep -x "$ONEPATTERN" /root/.packages/${DLPKG_NAME}.files`" != "" ] && rm -f "/initrd/pup_rw/$ONEWHITEOUT"
  453. done
  454. #111229 /usr/local/petget/removepreview.sh when uninstalling a pkg, may have copied a file from sfs-layer to top, check...
  455. cat /root/.packages/${DLPKG_NAME}.files |
  456. while read ONESPEC
  457. do
  458. [ "$ONESPEC" = "" ] && continue #precaution.
  459. if [ ! -d "$ONESPEC" ];then
  460. [ -e "/initrd/pup_rw${ONESPEC}" ] && rm -f "/initrd/pup_rw${ONESPEC}"
  461. fi
  462. done
  463. #now re-evaluate all the layers...
  464. if [ "`lsmod | grep '^aufs' `" != "" ];then #100426
  465. busybox mount -t aufs -o remount,udba=reval unionfs / #remount with faster evaluation mode.
  466. [ $? -ne 0 ] && logger -s -t "installpkg.sh" "Failed to remount aufs / with udba=reval"
  467. else
  468. mount -t unionfs -o remount,incgen unionfs /
  469. fi
  470. sync
  471. fi
  472. fi
  473. #some .pet pkgs have images at '/'...
  474. mv /*24.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  475. mv /*32.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  476. mv /*32.png /usr/local/lib/X11/pixmaps/ 2>/dev/null
  477. mv /*48.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  478. mv /*48.png /usr/local/lib/X11/pixmaps/ 2>/dev/null
  479. mv /*.xpm /usr/local/lib/X11/mini-icons/ 2>/dev/null
  480. mv /*.png /usr/local/lib/X11/mini-icons/ 2>/dev/null
  481. ls -dl /tmp | grep -q '^drwxrwxrwt' || chmod 1777 /tmp #130305 rerwin.
  482. #post-install script?...
  483. if [ -f /pinstall.sh ];then #pet pkgs.
  484. chmod +x /pinstall.sh
  485. cd /
  486. LANG=$LANG_USER sh /pinstall.sh
  487. rm -f /pinstall.sh
  488. fi
  489. if [ -f /install/doinst.sh ];then #slackware pkgs.
  490. chmod +x /install/doinst.sh
  491. cd /
  492. LANG=$LANG_USER sh /install/doinst.sh
  493. rm -rf /install
  494. fi
  495. if [ -e /DEBIAN/postinst ];then #130112 deb post-install script.
  496. cd /
  497. LANG=$LANG_USER sh DEBIAN/postinst
  498. rm -rf /DEBIAN
  499. fi
  500. #130314 run arch linux pkg post-install script...
  501. if [ -f /.INSTALL ];then #arch post-install script.
  502. if [ -f /usr/local/petget/ArchRunDotInstalls ];then #precaution. see 3builddistro, script created by noryb009.
  503. #this code is taken from below...
  504. dlPATTERN='|'"`echo -n "$DLPKG_BASE" | sed -e 's%\\-%\\\\-%'`"'|'
  505. archVER="`cat /tmp/petget_missing_dbentries-Packages-* | grep "$dlPATTERN" | head -n 1 | cut -f 3 -d '|'`"
  506. if [ "$archVER" ];then #precaution.
  507. cd /
  508. mv -f .INSTALL .INSTALL1-${archVER}
  509. cp -a /usr/local/petget/ArchRunDotInstalls /ArchRunDotInstalls
  510. LANG=$LANG_USER /ArchRunDotInstalls
  511. rm -f ArchRunDotInstalls
  512. rm -f .INSTALL*
  513. fi
  514. fi
  515. fi
  516. #v424 .pet pkgs may have a post-uninstall script...
  517. if [ -f /puninstall.sh ];then
  518. mv -f /puninstall.sh /root/.packages/${DLPKG_NAME}.remove
  519. fi
  520. #w465 <pkgname>.pet.specs is in older pet pkgs, just dump it...
  521. #maybe a '$APKGNAME.pet.specs' file created by dir2pet script...
  522. rm -f /*.pet.specs 2>/dev/null
  523. #...note, this has a setting to prevent .files and entry in user-installed-packages, so install not registered.
  524. #add entry to /root/.packages/user-installed-packages...
  525. #w465 a pet pkg may have /pet.specs which has a db entry...
  526. if [ -f /pet.specs -a -s /pet.specs ];then #w482 ignore zero-byte file.
  527. DB_ENTRY="`cat /pet.specs | head -n 1`"
  528. rm -f /pet.specs
  529. else
  530. [ -f /pet.specs ] && rm -f /pet.specs #w482 remove zero-byte file.
  531. dlPATTERN='|'"`echo -n "$DLPKG_BASE" | sed -e 's%\\-%\\\\-%'`"'|'
  532. DB_ENTRY="`cat /tmp/petget_missing_dbentries-Packages-* | grep "$dlPATTERN" | head -n 1`"
  533. fi
  534. echo DLPKG_BASE=$DLPKG_BASE
  535. echo DLPKG_NAME=$DLPKG_NAME
  536. echo DB_ENTRY=$DB_ENTRY
  537. ##+++2011-12-27 KRG check if $DLPKG_BASE matches DB_ENTRY 1 so uninstallation works :Ooops:
  538. db_pkg_name=`echo "$DB_ENTRY" |cut -f 1 -d '|'`
  539. echo db_pkg_name=$db_pkg_name
  540. if [ "$db_pkg_name" != "$DLPKG_NAME" ];then
  541. echo not equal sed ing now
  542. DB_ENTRY=`echo "$DB_ENTRY" |sed "s#$db_pkg_name#$DLPKG_NAME#"`
  543. fi
  544. ##+++2011-12-27 KRG
  545. #see if a .desktop file was installed, fix category... 120628 improve...
  546. #120818 overhauled. Pkg db now has category[;subcategory] (see 0setup), xdg enhanced (see /etc/xdg and /usr/share/desktop-directories), and generic icons for all subcategories (see /usr/local/lib/X11/mini-icons).
  547. #note, similar code also in Woof 2createpackages.
  548. ONEDOT=""
  549. CATEGORY="`echo -n "$DB_ENTRY" | cut -f 5 -d '|'`" #exs: Document, Document;edit
  550. [ "$CATEGORY" = "" ] && CATEGORY='BuildingBlock' #paranoid precaution.
  551. #xCATEGORY and DEFICON will be the fallbacks if Categories entry in .desktop is invalid...
  552. xCATEGORY="`echo -n "$CATEGORY" | sed -e 's%^%X-%' -e 's%;%-%'`" #ex: X-Document-edit (refer /etc/xdg/menu/*.menu)
  553. DEFICON="`echo -n "$CATEGORY" | sed -e 's%^%mini-%' -e 's%;%-%'`"'.xpm' #ex: mini-Document-edit (refer /usr/local/lib/X11/mini-icons -- these are in jwm search path) 121206 need .xpm extention.
  554. case $CATEGORY in
  555. Calculate) CATEGORY='Business' ; xCATEGORY='X-Business' ; DEFICON='mini-Business.xpm' ;; #Calculate is old name, now Business.
  556. Develop) CATEGORY='Utility;development' ; xCATEGORY='X-Utility-development' ; DEFICON='mini-Utility-development.xpm' ;; #maybe an old pkg has this.
  557. Help) CATEGORY='Utility;help' ; xCATEGORY='X-Utility-help' ; DEFICON='mini-Help.xpm' ;; #maybe an old pkg has this.
  558. BuildingBlock) CATEGORY='Utility' ; xCATEGORY='Utility' ; DEFICON='mini-BuildingBlock.xpm' ;; #unlikely to have a .desktop file.
  559. esac
  560. topCATEGORY="`echo -n "$CATEGORY" | cut -f 1 -d ';'`"
  561. tPATTERN="^${topCATEGORY} "
  562. cPATTERN="s%^Categories=.*%Categories=${xCATEGORY}%"
  563. iPATTERN="s%^Icon=.*%Icon=${DEFICON}%"
  564. #121119 if only one .desktop file, first check if a match in /usr/local/petget/categories.dat...
  565. CATDONE='no'
  566. if [ -f /usr/local/petget/categories.dat ];then #precaution, but it will be there.
  567. NUMDESKFILE="$(grep 'share/applications/.*\.desktop$' /root/.packages/${DLPKG_NAME}.files | wc -l)"
  568. if [ "$NUMDESKFILE" = "1" ];then
  569. #to lookup categories.dat, we need to know the generic name of the package, which may be different from pkg name...
  570. #db entry format: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  571. DBNAMEONLY="$(echo -n "$DB_ENTRY" | cut -f 2 -d '|')"
  572. DBPATH="$(echo -n "$DB_ENTRY" | cut -f 7 -d '|')"
  573. DBCOMPILEDDISTRO="$(echo -n "$DB_ENTRY" | cut -f 11 -d '|')"
  574. [ ! "$DBCOMPILEDDISTRO" ] && DBCOMPILEDDISTRO='puppy' #any name will do here.
  575. case $DBCOMPILEDDISTRO in
  576. debian|ubuntu|raspbian)
  577. if [ "$DBPATH" ];then #precaution
  578. xNAMEONLY="$(basename ${DBPATH})"
  579. else
  580. xNAMEONLY="$DBNAMEONLY"
  581. fi
  582. ;;
  583. *) xNAMEONLY="$DBNAMEONLY" ;;
  584. esac
  585. xnPTN=" ${xNAMEONLY} "
  586. #130126 categories.dat format changed slightly... 130219 ignore case...
  587. CATVARIABLE="$(grep -i "$xnPTN" /usr/local/petget/categories.dat | grep '^PKGCAT' | head -n 1 | cut -f 1 -d '=' | cut -f 2,3 -d '_' | tr '_' '-')" #ex: PKGCAT_Graphic_camera=" gphoto2 gtkam "
  588. if [ "$CATVARIABLE" ];then #ex: Graphic-camera
  589. xCATEGORY="X-${CATVARIABLE}"
  590. cPATTERN="s%^Categories=.*%Categories=${xCATEGORY}%" #121120
  591. CATFOUND="yes"
  592. CATDONE='yes'
  593. fi
  594. fi
  595. fi
  596. for ONEDOT in `grep 'share/applications/.*\.desktop$' /root/.packages/${DLPKG_NAME}.files | tr '\n' ' '` #121119 exclude other strange .desktop files.
  597. do
  598. #120901 get rid of param on end of Exec, ex: Exec=gimp-2.8 %U
  599. #sed -i -e 's/\(^Exec=[^%]*\).*/\1/' -e 's/ *$//' $ONEDOT #'s/\(^Exec=[^ ]*\).*/\1/'
  600. #121015 01micko: alternative that may work better...
  601. for PARMATER in u U f F #refer: http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
  602. do
  603. sed -i "s/ %${PARMATER}//" $ONEDOT
  604. done
  605. #w478 find if category is already valid (see also 2createpackages)..
  606. if [ "$CATDONE" = "no" ];then #121119
  607. CATFOUND="no"
  608. for ONEORIGCAT in `cat $ONEDOT | grep '^Categories=' | head -n 1 | cut -f 2 -d '=' | tr ';' ' ' | rev` #search in reverse order.
  609. do
  610. ONEORIGCAT="`echo -n "$ONEORIGCAT" | rev`" #restore rev of one word.
  611. oocPATTERN=' '"$ONEORIGCAT"' '
  612. [ "`echo "$PUPHIERARCHY" | tr -s ' ' | grep "$tPATTERN" | cut -f 3 -d ' ' | tr ',' ' ' | sed -e 's%^% %' -e 's%$% %' | grep "$oocPATTERN"`" != "" ] && CATFOUND="yes"
  613. #got a problem with sylpheed, "Categories=GTK;Network;Email;News;" this displays in both Network and Internet menus...
  614. if [ "$CATFOUND" = "yes" ];then
  615. cPATTERN="s%^Categories=.*%Categories=${ONEORIGCAT}%"
  616. break
  617. fi
  618. done
  619. #121109 above may fail, as DB_category field may not match that in .desktop file, so leave out that $tPATTERN match in $PUPHIERARCHY...
  620. if [ "$CATFOUND" = "no" ];then
  621. for ONEORIGCAT in `cat $ONEDOT | grep '^Categories=' | head -n 1 | cut -f 2 -d '=' | tr ';' ' ' | rev` #search in reverse order.
  622. do
  623. ONEORIGCAT="`echo -n "$ONEORIGCAT" | rev`" #restore rev of one word.
  624. oocPATTERN=' '"$ONEORIGCAT"' '
  625. [ "`echo "$PUPHIERARCHY" | tr -s ' ' | cut -f 3 -d ' ' | tr ',' ' ' | sed -e 's%^% %' -e 's%$% %' | grep "$oocPATTERN"`" != "" ] && CATFOUND="yes"
  626. #got a problem with sylpheed, "Categories=GTK;Network;Email;News;" this displays in both Network and Internet menus...
  627. if [ "$CATFOUND" = "yes" ];then
  628. cPATTERN="s%^Categories=.*%Categories=${ONEORIGCAT}%"
  629. break
  630. fi
  631. done
  632. fi
  633. fi
  634. sed -i -e "$cPATTERN" $ONEDOT #fix Categories= entry.
  635. #w019 does the icon exist?...
  636. ICON="`grep '^Icon=' $ONEDOT | cut -f 2 -d '='`"
  637. if [ "$ICON" != "" ];then
  638. [ -e "$ICON" ] && continue #it may have a hardcoded path.
  639. ICONBASE="`basename "$ICON"`"
  640. #110706 fix icon entry in .desktop... 110821 improve...
  641. #first search where jwm looks for icons... 111207...
  642. FNDICON="`find /usr/local/lib/X11/mini-icons /usr/share/pixmaps -maxdepth 1 -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  643. if [ "$FNDICON" ];then
  644. ICONNAMEONLY="`basename $FNDICON`"
  645. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  646. sed -i -e "$iPTN" $ONEDOT
  647. continue
  648. else
  649. #look elsewhere... 111207...
  650. FNDICON="`find /usr/share/icons /usr/local/share/pixmaps -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  651. #111207 look further afield, ex parole pkg has /usr/share/parole/pixmaps/parole.png...
  652. [ ! "$FNDICON" ] && [ -d /usr/share/$ICONBASE ] && FNDICON="`find /usr/share/${ICONBASE} -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  653. #111207 getting desperate...
  654. [ ! "$FNDICON" ] && FNDICON="`find /usr/share -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  655. if [ "$FNDICON" ];then
  656. ICONNAMEONLY="`basename "$FNDICON"`"
  657. ln -snf "$FNDICON" /usr/share/pixmaps/${ICONNAMEONLY}
  658. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  659. sed -i -e "$iPTN" $ONEDOT
  660. continue
  661. fi
  662. fi
  663. #substitute a default icon...
  664. sed -i -e "$iPATTERN" $ONEDOT #note, ONEDOT is name of .desktop file.
  665. fi
  666. #120926 if a langpack installed, it will have /usr/share/applications.in (see /usr/sbin/momanager, /usr/share/doc/langpack-template/pinstall.sh).
  667. ABASEDESKTOP="`basename $ONEDOT`"
  668. ADIRDESKTOP="`dirname $ONEDOT`"
  669. if [ -f /usr/share/applications.in/${ABASEDESKTOP} ];then
  670. TARGETLANG="`echo -n $LANG_USER | cut -f 1 -d '_'`" #ex: de
  671. tlPTN="^Name\[${TARGETLANG}\]"
  672. if [ "$(grep "$tlPTN" ${ADIRDESKTOP}/${ABASEDESKTOP})" = "" ];then
  673. if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
  674. #aaargh, these accursed back-slashes! ....
  675. INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
  676. sed -i -e "s%^Name=%${INSERTALINE}\\nName=%" ${ADIRDESKTOP}/${ABASEDESKTOP}
  677. fi
  678. fi
  679. #do same for Comment field...
  680. tlPTN="^Comment\[${TARGETLANG}\]"
  681. if [ "$(grep "$tlPTN" ${ADIRDESKTOP}/${ABASEDESKTOP})" = "" ];then
  682. if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
  683. #aaargh, these accursed back-slashes! ....
  684. INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
  685. sed -i -e "s%^Comment=%${INSERTALINE}\\nComment=%" ${ADIRDESKTOP}/${ABASEDESKTOP}
  686. fi
  687. fi
  688. #well, i suppose need this too...
  689. TARGETLANG="`echo -n $LANG_USER | cut -f 1 -d '.'`" #ex: de_DE
  690. tlPTN="^Name\[${TARGETLANG}\]"
  691. if [ "$(grep "$tlPTN" ${ADIRDESKTOP}/${ABASEDESKTOP})" = "" ];then
  692. if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
  693. #aaargh, these accursed back-slashes! ....
  694. INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
  695. sed -i -e "s%^Name=%${INSERTALINE}\\nName=%" ${ADIRDESKTOP}/${ABASEDESKTOP}
  696. fi
  697. fi
  698. #do same for Comment field...
  699. tlPTN="^Comment\[${TARGETLANG}\]"
  700. if [ "$(grep "$tlPTN" ${ADIRDESKTOP}/${ABASEDESKTOP})" = "" ];then
  701. if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
  702. #aaargh, these accursed back-slashes! ....
  703. INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
  704. sed -i -e "s%^Comment=%${INSERTALINE}\\nComment=%" ${ADIRDESKTOP}/${ABASEDESKTOP}
  705. fi
  706. fi
  707. fi
  708. done
  709. #due to images at / in .pet and post-install script, .files may have some invalid entries...
  710. INSTFILES="`cat /root/.packages/${DLPKG_NAME}.files`"
  711. echo "$INSTFILES" |
  712. while read ONEFILE
  713. do
  714. if [ ! -e "$ONEFILE" ];then
  715. ofPATTERN='^'"$ONEFILE"'$'
  716. grep -v "$ofPATTERN" /root/.packages/${DLPKG_NAME}.files > /tmp/petget_instfiles
  717. mv -f /tmp/petget_instfiles /root/.packages/${DLPKG_NAME}.files
  718. fi
  719. done
  720. #w482 DB_ENTRY may be missing DB_category and DB_description fields...
  721. #pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|
  722. #optionally on the end: compileddistro|compiledrelease|repo| (fields 11,12,13)
  723. DESKTOPFILE="`grep '\.desktop$' /root/.packages/${DLPKG_NAME}.files | head -n 1`"
  724. if [ "$DESKTOPFILE" != "" ];then
  725. DB_category="`echo -n "$DB_ENTRY" | cut -f 5 -d '|'`"
  726. DB_description="`echo -n "$DB_ENTRY" | cut -f 10 -d '|'`"
  727. CATEGORY="$DB_category"
  728. DESCRIPTION="$DB_description"
  729. zCATEGORY="`cat $DESKTOPFILE | grep '^Categories=' | sed -e 's%;$%%' | cut -f 2 -d '=' | rev | cut -f 1 -d ';' | rev`" #121109
  730. if [ "$zCATEGORY" != "" ];then #121109
  731. #v424 but want the top-level menu category...
  732. catPATTERN="[ ,]${zCATEGORY},|[ ,]${zCATEGORY} |[ ,]${zCATEGORY}"'$' #121119 fix bug in pattern.
  733. CATEGORY="`echo "$PUPHIERARCHY" | cut -f 1 -d '#' | grep -E "$catPATTERN" | grep ':' | cut -f 1 -d ' ' | head -n 1`" #121119 /etc/xdg/menus/hierarchy
  734. fi
  735. if [ "$DB_description" = "" ];then
  736. DESCRIPTION="`cat $DESKTOPFILE | grep '^Comment=' | cut -f 2 -d '='`"
  737. [ "$DESCRIPTION" = "" ] && DESCRIPTION="`cat $DESKTOPFILE | grep '^Name=' | cut -f 2 -d '='`" # shinobar
  738. fi
  739. if [ "$DB_category" = "" -o "$DB_description" = "" ];then
  740. newDB_ENTRY="`echo -n "$DB_ENTRY" | cut -f 1-4 -d '|'`"
  741. newDB_ENTRY="$newDB_ENTRY"'|'"$CATEGORY"'|'
  742. newDB_ENTRY="$newDB_ENTRY""`echo -n "$DB_ENTRY" | cut -f 6-9 -d '|'`"
  743. newDB_ENTRY="$newDB_ENTRY"'|'"$DESCRIPTION"'|'
  744. newDB_ENTRY="$newDB_ENTRY""`echo -n "$DB_ENTRY" | cut -f 11-14 -d '|'`"
  745. DB_ENTRY="$newDB_ENTRY"
  746. fi
  747. fi
  748. echo "$DB_ENTRY" >> /root/.packages/user-installed-packages
  749. #110706 fix 'Exec filename %u' line...
  750. DESKTOPFILES="`grep '\.desktop$' /root/.packages/${DLPKG_NAME}.files | tr '\n' ' '`"
  751. for ONEDESKTOP in $DESKTOPFILES
  752. do
  753. sed -i -e 's/ %u$//' $ONEDESKTOP
  754. done
  755. #120907 post-install hacks...
  756. /usr/local/petget/hacks-postinstall.sh $DLPKG_MAIN
  757. #announcement of successful install...
  758. #announcement is done after all downloads, in downloadpkgs.sh...
  759. CATEGORY="`echo -n "$CATEGORY" | cut -f 1 -d ';'`"
  760. [ "$CATEGORY" = "" ] && CATEGORY="none"
  761. [ "$CATEGORY" = "BuildingBlock" ] && CATEGORY="none"
  762. echo "PACKAGE: $DLPKG_NAME CATEGORY: $CATEGORY" >> /tmp/petget-installed-pkgs-log
  763. #110503 change ownership of some files if non-root...
  764. #hmmm, i think this will only work if running this script as root...
  765. # (the entry script pkg_chooser.sh has sudo to switch to root)
  766. HOMEUSER="`grep '^tty1' /etc/inittab | tr -s ' ' | cut -f 3 -d ' '`" #root or fido.
  767. if [ "$HOMEUSER" != "root" ];then
  768. grep -E '^/var|^/root|^/etc' /root/.packages/${DLPKG_NAME}.files |
  769. while read FILELINE
  770. do
  771. busybox chown ${HOMEUSER}:users "${FILELINE}"
  772. done
  773. fi
  774. #120523 precise puppy needs this... (refer also rc.update and 3builddistro)
  775. if [ "`grep '/usr/share/glib-2.0/schemas' /root/.packages/${DLPKG_NAME}.files`" != "" ];then
  776. [ -e /usr/bin/glib-compile-schemas ] && /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
  777. fi
  778. if [ "`grep '/usr/lib/gio/modules' /root/.packages/${DLPKG_NAME}.files`" != "" ];then
  779. [ -e /usr/bin/gio-querymodules ] && /usr/bin/gio-querymodules /usr/lib/gio/modules
  780. fi
  781. ###END###