!47 增加patch,关于服务启动时创建日志文件和修改多个二进制包提供同名组件时筛选问题。
From: @lhwerico Reviewed-by: @ruebb,@solarhu Signed-off-by: @solarhu
This commit is contained in:
commit
772efbc889
25
0010-create-log-when-start.patch
Normal file
25
0010-create-log-when-start.patch
Normal file
@ -0,0 +1,25 @@
|
||||
--- a/packageship/pkgshipd
|
||||
+++ b/packageship/pkgshipd
|
||||
@@ -247,6 +247,22 @@ daemonize=$daemonize" >$OUT_PATH/${PKGSHIP_CONSTANT}.ini
|
||||
chown pkgshipuser: $OUT_PATH/${PKGSHIP_CONSTANT}.ini
|
||||
chmod 750 $OUT_PATH/${PKGSHIP_CONSTANT}.ini
|
||||
echo "[INFO] create uwsgi file ok"
|
||||
+
|
||||
+ # create log_info file
|
||||
+ echo "[INFO] start to create log_info file"
|
||||
+ log_file_path=$(get_config "log_path")
|
||||
+ log_file=${log_file_path}/"log_info.log"
|
||||
+ if [ ! -e "${log_file}" ]; then
|
||||
+ touch "${log_file}"
|
||||
+ chmod 644 "${log_file}"
|
||||
+ else
|
||||
+ log_info=$(ls -al "${log_file}")
|
||||
+ if [[ ! "${log_info}" =~ "pkgshipuser" ]]; then
|
||||
+ echo "[ERROR] The owner of the ${log_file} is incorrect,please make sure the owner is pkgshipuser"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ fi
|
||||
+ echo "[INFO] create log_info file success"
|
||||
}
|
||||
|
||||
function uwsgi_log_logrotate() {
|
||||
89
0011-fix-binary-rpm-sort.patch
Normal file
89
0011-fix-binary-rpm-sort.patch
Normal file
@ -0,0 +1,89 @@
|
||||
--- a/packageship/application/query/depend.py
|
||||
+++ b/packageship/application/query/depend.py
|
||||
@@ -18,6 +18,7 @@ from gevent import monkey
|
||||
|
||||
monkey.patch_all()
|
||||
|
||||
+from collections import Counter
|
||||
from packageship.application.common.constant import PROVIDES_NAME, FILES_NAME
|
||||
from packageship.application.query import Query
|
||||
from packageship.application.query.query_body import QueryBody
|
||||
@@ -133,28 +134,28 @@ class RequireBase(Query):
|
||||
for rpm_info in query_rpm_infos:
|
||||
if rpm_info.get('requires'):
|
||||
new_requires_list = []
|
||||
- component_bin_count_dict = dict()
|
||||
+ component_bin_list = []
|
||||
multi_binary_component_list = []
|
||||
for component_name in rpm_info.get('requires'):
|
||||
- self._convert_multi_binary_components(all_component_info_dict, component_bin_count_dict,
|
||||
+ self._convert_multi_binary_components(all_component_info_dict, component_bin_list,
|
||||
component_name,
|
||||
multi_binary_component_list, new_requires_list)
|
||||
|
||||
- self._filter_multi_binary_components(component_bin_count_dict, multi_binary_component_list,
|
||||
+ self._filter_multi_binary_components(component_bin_list, multi_binary_component_list,
|
||||
new_requires_list)
|
||||
rpm_info['requires'] = new_requires_list
|
||||
else:
|
||||
rpm_info['requires'] = []
|
||||
|
||||
@staticmethod
|
||||
- def _convert_multi_binary_components(all_component_info_dict, component_bin_count_dict, component_name,
|
||||
+ def _convert_multi_binary_components(all_component_info_dict, component_bin_list, component_name,
|
||||
multi_binary_component_list, new_requires_list):
|
||||
"""
|
||||
Add the uniquely determined binary package info to the result list
|
||||
Construct a dictionary of occurrences of binary packages and list of repeated binary packages
|
||||
Args:
|
||||
all_component_info_dict: all components dict
|
||||
- component_bin_count_dict: The number of times the binary package of the component is provided
|
||||
+ component_bin_list: The list of the binary package of the component is provided
|
||||
component_name: component name
|
||||
multi_binary_component_list: list of repeated binary packages
|
||||
new_requires_list: result list
|
||||
@@ -171,37 +172,33 @@ class RequireBase(Query):
|
||||
# If the component is provided by multiple binary packages, record first and then filter
|
||||
multi_binary_component_list.append(component_info)
|
||||
# Construct a dictionary of occurrences of binary packages
|
||||
- for component in component_info:
|
||||
- try:
|
||||
- com_bin_name_count = component_bin_count_dict[component.get('com_bin_name')]
|
||||
- component_bin_count_dict[component.get('com_bin_name')] = com_bin_name_count + 1
|
||||
- except KeyError:
|
||||
- component_bin_count_dict[component.get('com_bin_name')] = 1
|
||||
+ component_bin_list.extend([component.get('com_bin_name') for component in component_info])
|
||||
else:
|
||||
new_requires_list.append(dict(component=component_name))
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
- def _filter_multi_binary_components(component_bin_count_dict, multi_binary_component_list, new_requires_list):
|
||||
+ def _filter_multi_binary_components(component_bin_list, multi_binary_component_list, new_requires_list):
|
||||
"""
|
||||
Filter results based on component name and number of occurrences of binary packages
|
||||
Args:
|
||||
- component_bin_count_dict: The number of times the binary package of the component is provided
|
||||
+ component_bin_list: The list of the binary package of the component is provided
|
||||
multi_binary_component_list: list of repeated binary packages
|
||||
new_requires_list: result list
|
||||
|
||||
Returns: None
|
||||
|
||||
"""
|
||||
+ component_bin_counter = Counter(component_bin_list)
|
||||
for component_list in multi_binary_component_list:
|
||||
max_count = 0
|
||||
final_component_info = dict()
|
||||
# Sort by name first, then filter the results according to the number of occurrences of binary packages
|
||||
- component_list.sort(key=lambda x: x.get('component'))
|
||||
+ component_list.sort(key=lambda x: x.get('com_bin_name'))
|
||||
for component in component_list:
|
||||
- if component_bin_count_dict.get(component.get('com_bin_name')) > max_count:
|
||||
+ if component_bin_counter.get(component.get('com_bin_name')) > max_count:
|
||||
final_component_info = component
|
||||
- max_count = component_bin_count_dict.get(component.get('com_bin_name'))
|
||||
+ max_count = component_bin_counter.get(component.get('com_bin_name'))
|
||||
|
||||
new_requires_list.append(final_component_info)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: pkgship
|
||||
Version: 2.1.0
|
||||
Release: 8
|
||||
Release: 9
|
||||
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so on.
|
||||
License: Mulan 2.0
|
||||
URL: https://gitee.com/openeuler/pkgship
|
||||
@ -15,6 +15,8 @@ patch0006: 0006-add-check-service-status-when-init.patch
|
||||
patch0007: 0007-update-readme.patch
|
||||
patch0008: 0008-update-patch-import.patch
|
||||
patch0009: 0009-add-es-insert-test-cases.patch
|
||||
patch0010: 0010-create-log-when-start.patch
|
||||
patch0011: 0011-fix-binary-rpm-sort.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
@ -119,6 +121,10 @@ create_dir_file /var/log/pkgship-operation 700 d
|
||||
%attr(0640,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship.service
|
||||
|
||||
%changelog
|
||||
* Thu Apr 1 2021 Haiwei Li <lihaiwei8@huawei.com> - 2.1.0-9
|
||||
- create log file when searvice start
|
||||
- Modify the bianry rpms sorting problem
|
||||
|
||||
* Sat Mar 20 2021 Haiwei Li <lihaiwei8@huawei.com> - 2.1.0-8
|
||||
- add patchs from the previous version
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user