You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.0 KiB

  1. {% calculate comment='#', unbound %}
  2. # vim: set syntax=sh
  3. # Copyright 2014-2015 Calculate Ltd. http://www.calculate-linux.org
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. CL_UPDATE_PROG="/usr/sbin/cl-core"
  12. RUN_CORE="/usr/bin/python2 ${CL_UPDATE_PROG}"
  13. CORE_METHOD="--method core_setup"
  14. [[ -d /var/lib/calculate ]] || mkdir /var/lib/calculate
  15. # setup package and create postmerge package list
  16. setup_merge_package() {
  17. rm -f /var/lib/calculate/-postmerge
  18. if ! [[ -f /var/lib/calculate/calculate-core/cache/merge-setup.list ]] ||
  19. grep ${CATEGORY}/${PN} /var/lib/calculate/calculate-core/cache/merge-setup.list &>/dev/null
  20. then
  21. if [ -f ${CL_UPDATE_PROG} ] && check_skip
  22. then
  23. if ! CTARGET=${CTARGET} GCC_CONFIG_VER=${GCC_CONFIG_VER} ${RUN_CORE} ${CORE_METHOD} --no-progress --pkg-version ${PVR} --pkg-slot ${SLOT/\/*} --pkg-category ${CATEGORY} --pkg-path "/" --pkg-name ${PN}
  24. then
  25. echo $CATEGORY $PN $PVR ${SLOT/\/*} >>/var/lib/calculate/calculate-core/setup-failed.list
  26. return 1
  27. fi
  28. fi
  29. fi
  30. rm -f /var/lib/calculate/-runlevels-$PN
  31. }
  32. # remove mark: package updating
  33. clean_update_mark() {
  34. rm -f /var/lib/calculate/-merge-$PN-*
  35. }
  36. # remove contents file which need for cl-core-setup
  37. clean_contents_mark() {
  38. rm -f /var/lib/calculate/-CONTENTS-*
  39. }
  40. # mark: package updating
  41. mark_update_package() {
  42. touch "/var/lib/calculate/-merge-$PN--${SLOT/\/*}-$PPID"
  43. }
  44. # save services runlevels
  45. save_runlevels() {
  46. find /etc/runlevels/{default,boot,sysinit,shutdown} >/var/lib/calculate/-runlevels-$PN
  47. }
  48. # dispatching unmerge or update package
  49. pkg_postrm_dispatch() {
  50. if [[ ! -f /var/lib/calculate/-merge-$PN--${SLOT/\/*}-$PPID ]]
  51. then
  52. pkg_postrm_unmerge
  53. else
  54. pkg_postrm_update
  55. fi
  56. }
  57. # restore files of packages which stashed for resolve automagic depends
  58. unstash_automagic_requires() {
  59. local automagic_dir=/var/lib/calculate/calculate-builder/automagic-requires
  60. if [[ -d $automagic_dir ]]
  61. then
  62. # -K - need to resolve lib -> lib64 symlink problem
  63. # -X - to keep file capabilities
  64. /usr/bin/rsync -aXKx ${automagic_dir}/ / && rm -rf ${automagic_dir}
  65. fi
  66. }
  67. # setup package umerging
  68. pkg_postrm_unmerge() {
  69. if ! [[ -f /var/lib/calculate/calculate-core/cache/merge-setup.list ]] ||
  70. grep ${CATEGORY}/${PN} /var/lib/calculate/calculate-core/cache/merge-setup.list &>/dev/null
  71. then
  72. [ -f ${CL_UPDATE_PROG} ] && check_skip && ${RUN_CORE} ${CORE_METHOD} --no-progress --pkg-version ${PVR} --pkg-slot ${SLOT/\/*} --pkg-category ${CATEGORY} --pkg-path / --pkg-name ${PN}
  73. fi
  74. }
  75. # save contents file for correct package updating by cl-core-setup
  76. pkg_postrm_update() {
  77. cp /var/db/pkg/${CATEGORY}/${PF}/CONTENTS /var/lib/calculate/-CONTENTS-$PN
  78. }
  79. pre_pkg_postrm() {
  80. pkg_postrm_dispatch
  81. clean_update_mark
  82. }
  83. pre_pkg_postinst() {
  84. setup_merge_package
  85. clean_contents_mark
  86. clean_update_mark
  87. unstash_automagic_requires
  88. }
  89. pre_pkg_preinst() {
  90. mark_update_package
  91. save_runlevels
  92. }