当前位置:   article > 正文

rpm打包方法_rpm 打包 kill

rpm 打包 kill

bash build.sh

然后产生在RPMS/mips64el下

.目录结构如下

 

  1. #tree .
  2. .
  3. |-- BUILD
  4. |-- BUILDROOT
  5. |-- RPMS
  6. |   |-- mips64el
  7. |      `-- 123est-1.0.0-1001.mips64el.rpm
  8. |-- SOURCES
  9. |-- SPECS
  10. |   `-- 123test.spec
  11. |-- SRPMS
  12. |-- build.sh
  13. `-- test
  1. #cat build.sh
  2. function build_rpm() {
  3.     PACKDIR="$PWD/packdir"
  4.     INSTALLDIR="/opt/test123"
  5.     mkdir -p ${PACKDIR}${INSTALLDIR}
  6.     version=1.0.0
  7.     release=1001
  8.     cp test  $PACKDIR/opt/test123/test
  9.     rpmbuild -bb "`pwd`/SPECS/123test.spec" --buildroot="$PACKDIR" --define "VERSION $version" --define "RELEASE $release" --define "_topdir $PWD" --target=mips64el
  10. }
  11. build_rpm

 

  1. #cat SPECS/123test.spec
  2. Summary: 123test
  3. Name: 123test
  4. Version: %VERSION
  5. Source: $RPM_SOURCE_DIR/
  6. Release: %RELEASE
  7. Vendor: xl 123 company
  8. License: copyright to xl 123
  9. Group: Application/system
  10. %description
  11. 123 test
  12. %define install_dir /opt/123test
  13. %define main_process_name test
  14. %prep
  15. echo "note : prep [$1]"
  16. %pre
  17. echo "note : pre [$1]"
  18. %clean
  19. echo "note : clean [$1]"
  20. [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
  21. %files
  22. %defattr(755,root,root)
  23. %attr(4544,root,root) %{install_dir}/test
  24. %post
  25. echo "note : post [$1]"
  26. run() {
  27. # run app
  28. nohup $install_dir/$main_process_name >/dev/null 2>&1 &
  29. echo "========post run========="
  30. }
  31. case "$1" in
  32. 0) #uninstall
  33. echo "error : post called with uninstall argument"
  34. exit -1
  35. ;;
  36. 1|2) #install | upgrade
  37. echo "note : post called with install | upgrade argument"
  38. run
  39. exit 0
  40. ;;
  41. *)
  42. echo "error : post called with unknown argument"
  43. exit -1
  44. ;;
  45. esac
  46. %preun
  47. echo "note : preun [$1]"
  48. stoprpm() {
  49. echo "stop rpm"
  50. ps -ef | grep rpm | grep 360safe | grep '-' | awk '{print $2}' | xargs -I {} kill -9 {} > /dev/null 2>&1
  51. exit -1
  52. }
  53. check_mima() {
  54. ls -lh /proc/self/fd
  55. read -sp "0 test:" mima 0<&1
  56. echo "mimashi : $mima"
  57. ls -lh /proc/self/fd
  58. }
  59. get_general_user() {
  60. names=$(who | awk '{print $1}')
  61. for name in ${names}
  62. do
  63. if [[ ${name} != 'root' ]]; then
  64. break
  65. fi
  66. done
  67. echo ${name}
  68. }
  69. case "$1" in
  70. 0) #uninstall
  71. echo "note : preun called with uninstall argument"
  72. check_mima
  73. exit 0
  74. ;;
  75. 1|2) #install | upgrade
  76. echo "note : preun called with install | upgrade argument, do nothing"
  77. exit 0
  78. ;;
  79. *)
  80. echo "error : preun called with unknown argument"
  81. exit -1
  82. ;;
  83. esac
  84. %postun
  85. echo "note : postun [$1]"
  86. rm_driver()
  87. {
  88. dfile=$(lsmod | grep test_base)
  89. if [ x == "$dfile"x ];then
  90. echo "driver module removed"
  91. else
  92. echo "remove driver module"
  93. rmmod -f test_base
  94. echo "driver module removed"
  95. fi
  96. }
  97. remove_all() {
  98. if [ -d "/opt/123test" ]; then
  99. rm -rf /opt/123test
  100. fi
  101. if [ -f "/usr/bin/123test" ]; then
  102. rm -f /usr/bin/123test
  103. fi
  104. if [ -f "/usr/share/applications/start123.desktop" ]; then
  105. rm -f /usr/share/applications/start123.desktop
  106. fi
  107. if [ -f "/etc/xdg/autostart/autostart123.desktop" ]; then
  108. rm -f /etc/xdg/autostart/autostart123.desktop
  109. fi
  110. if [ -f "/etc/init.d/$service_name" ];then
  111. rm -f /etc/init.d/$service_name
  112. fi
  113. if [ -L "/etc/rc2.d/S10$service_name" ];then
  114. unlink /etc/rc2.d/S10$service_name
  115. fi
  116. if [ -L "/etc/rc3.d/S10$service_name" ];then
  117. unlink /etc/rc3.d/S10$service_name
  118. fi
  119. if [ -L "/etc/rc4.d/S10$service_name" ];then
  120. unlink /etc/rc4.d/S10$service_name
  121. fi
  122. if [ -L "/etc/rc5.d/S10$service_name" ];then
  123. unlink /etc/rc5.d/S10$service_name
  124. fi
  125. }
  126. case "$1" in
  127. 0) #uninstall
  128. echo "note : postun called with uninstall argument"
  129. remove_all
  130. rm_driver
  131. exit 0
  132. ;;
  133. 1|2) #install | upgrade
  134. echo "note : postun called with install | upgrade argument, do nothing"
  135. exit 0
  136. ;;
  137. *)
  138. echo "error : postun called with unknown argument"
  139. exit -1
  140. ;;
  141. esac

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/469067
推荐阅读
相关标签
  

闽ICP备14008679号