update to 3.0.0

This commit is contained in:
liheavy 2023-01-04 15:49:47 +08:00
parent 83af47f289
commit 079d8f1bd8
13 changed files with 246 additions and 3426 deletions

View File

@ -1,21 +0,0 @@
diff -Nur pkgship-2.2.0/packageship/application/core/pkginfo/pkg.py pkgship-2.2.0-new/packageship/application/core/pkginfo/pkg.py
--- pkgship-2.2.0/packageship/application/core/pkginfo/pkg.py 2021-08-14 22:23:58.000000000 +0800
+++ pkgship-2.2.0-new/packageship/application/core/pkginfo/pkg.py 2021-08-25 15:34:41.691761866 +0800
@@ -180,13 +180,15 @@
install_require_info = component_info.get("install_require")
required_by_bin = []
for req_info in install_require_info:
- required_by_bin.append(req_info.get("req_bin_name"))
+ if req_info.get("req_bin_name"):
+ required_by_bin.append(req_info.get("req_bin_name"))
# getting required_by_src
build_require_info = component_info.get("build_require")
required_by_src = []
for req_info in build_require_info:
- required_by_src.append(req_info.get("req_src_name"))
+ if req_info.get("req_src_name"):
+ required_by_src.append(req_info.get("req_src_name"))
component_dict = {"component": component_info.get("component"),
"required_by_bin": required_by_bin,

View File

@ -1,27 +0,0 @@
diff --git a/packageship/pkgshipd b/packageship/pkgshipd
index 9cb3dc694e39f188a1e8775b37087c16059317b9..e1e843019d459ecde4aeaa6c18feb1e9d2d4fda1 100644
--- a/packageship/pkgshipd
+++ b/packageship/pkgshipd
@@ -357,7 +357,7 @@ try:
response = redis.Redis(host='$redis_ip',
port="$redis_port")
print(response.ping())
-except redis.ConnectionError:
+except Exception:
print(False)"
python3_version=$(python3 --version)
if [[ "${python3_version}" =~ "command not found" ]]; then
diff --git a/packageship/auto_install_pkgship_requires.sh b/packageship/auto_install_pkgship_requires.sh
index 4a914034170cd11e3996c34814806e8448862a32..5ecce235dae835050960046fa28a148b7326f1c4 100644
--- a/packageship/auto_install_pkgship_requires.sh
+++ b/packageship/auto_install_pkgship_requires.sh
@@ -128,7 +128,7 @@ function main() {
elif [ "${INSTALL_SOFTWARE}" = "redis" ]; then
download_install_redis
else
- echo "Failed to parse parameters, please use 'bash auto_install_es.sh elasticsearch/redis' "
+ echo "Failed to parse parameters, please use '/bin/bash auto_install_pkgship_requires.sh elasticsearch/redis' "
exit 1
fi
}

View File

@ -1,848 +0,0 @@
diff --git a/packageship/application/initialize/binary.json b/packageship/application/initialize/binary.json
index ebaa681a890a370745fc8a1282b8519fa1d3c734..a3abb5afd41085a83839ef3b2231f7efc4f9658f 100644
--- a/packageship/application/initialize/binary.json
+++ b/packageship/application/initialize/binary.json
@@ -135,18 +135,6 @@
"ignore_above": 256,
"index": false
},
- "relation": {
- "properties": {
- "bin_name": {
- "type": "keyword",
- "ignore_above": 256
- },
- "src_name": {
- "type": "keyword",
- "ignore_above": 256
- }
- }
- },
"release": {
"type": "keyword",
"ignore_above": 256
diff --git a/packageship/application/initialize/integration.py b/packageship/application/initialize/integration.py
index f7cd38f6258c3a0f0e05a2d2fea8317e269e2833..788b2f79edcab39a08e4d1094c48027db145c986 100644
--- a/packageship/application/initialize/integration.py
+++ b/packageship/application/initialize/integration.py
@@ -201,20 +201,21 @@ class InitializeService:
"""
sources = []
- for src_pack_name, src_pack in self._src_pack.items():
+ for _, src_pack in self._src_pack.items():
es_json = ESJson()
es_json.update(src_pack)
es_json["requires"] = self._build_requires(
src_pack['pkgKey'])
try:
- for bin_pack in self._bin_pack['sources'].pop(src_pack_name):
+ location_href = src_pack["location_href"].split('/')[-1]
+ for bin_pack in self._bin_pack['sources'].get(location_href):
_subpacks = dict(
name=bin_pack["name"], version=bin_pack["version"])
try:
es_json["subpacks"].append(_subpacks)
except TypeError:
es_json["subpacks"] = [_subpacks]
- except KeyError:
+ except TypeError:
es_json["subpacks"] = None
sources.append(self._es_json("-source", es_json))
helpers.bulk(self._session.client, sources)
@@ -227,6 +228,10 @@ class InitializeService:
binarys = []
be_depends = []
for _, bin_pack in self._bin_pack["packages"].items():
+ bin_pack["src_name"] = self._src_location[bin_pack["src_name"]]["name"]
+ if isinstance(bin_pack["src_name"], ESJson):
+ bin_pack["src_name"] = None
+
be_depends.append(self._be_depend(bin_pack))
es_json = ESJson()
es_json.update(bin_pack)
@@ -275,7 +280,9 @@ class InitializeService:
try:
for require in self._bin_requires.get(provide["name"]):
_bin_pack = self._bin_pack["pkg_key"][require["pkgKey"]]
- _src_pack = self._src_pack[_bin_pack["src_name"]]
+ _src_pack = self._src_location[_bin_pack["src_name"]]
+ if not _src_pack:
+ _src_pack = self._src_pack[_bin_pack["src_name"]]
component_json["install_require"].append({
"req_bin_name": _bin_pack["name"],
"req_bin_version": _bin_pack["version"],
@@ -373,7 +380,7 @@ class InitializeService:
return {
"_index": str(self._repo["dbname"] + index).lower(),
"_type": _type,
- "_source": source
+ "_source": dict(source)
}
def _relation(self, key):
@@ -407,7 +414,6 @@ class InitializeService:
except (KeyError, TypeError):
return build_requires
for src_require in requires:
- src_require["relation"] = self._relation(src_require['name'])
src_require["requires_type"] = "build"
build_requires.append(src_require)
return build_requires
@@ -422,7 +428,6 @@ class InitializeService:
install_requires = list()
try:
for bin_require in self._bin_requires.get(bin_pack['pkgKey']):
- bin_require["relation"] = self._relation(bin_require['name'])
bin_require["requires_type"] = "install"
install_requires.append(bin_require)
@@ -465,6 +470,14 @@ class InitializeService:
self._data.src_pkgkeys[src_pack["pkgKey"]] = src_pack
return self._data.src_pkgkeys
+ @property
+ def _src_location(self):
+ if not self._data.src_location:
+ for _, package in self._src_pack.items():
+ key = package["location_href"].split('/')[-1]
+ self._data["src_location"][key] = package
+ return self._data.src_location
+
@property
def _src_requires(self):
"""
@@ -549,22 +562,16 @@ class InitializeService:
"""
def combination_binary(row_data):
- try:
- src_package_name = None
- _pkgs = row_data.get('rpm_sourcerpm').split(
- '-' + row_data.get('version'))
- if len(_pkgs) != 1:
- src_package_name = ''.join(_pkgs[0:-1])
- except AttributeError:
- src_package_name = None
- row_data["src_name"] = src_package_name
+
+ rpm_sourcerpm = row_data.get('rpm_sourcerpm')
+ row_data["src_name"] = rpm_sourcerpm
self._data[table]['packages'][row_data[key]] = row_data
self._data[table]["pkg_key"][row_data["pkgKey"]] = row_data
- if src_package_name:
- if isinstance(self._data[table]["sources"][src_package_name], ESJson):
- self._data[table]["sources"][src_package_name] = [row_data]
+ if rpm_sourcerpm:
+ if isinstance(self._data[table]["sources"][rpm_sourcerpm], ESJson):
+ self._data[table]["sources"][rpm_sourcerpm] = [row_data]
else:
- self._data[table]["sources"][src_package_name].append(
+ self._data[table]["sources"][rpm_sourcerpm].append(
row_data)
def others(row_data, dict_key):
diff --git a/packageship/application/initialize/source.json b/packageship/application/initialize/source.json
index 5ee3544dd897b0469eee9c109c934221f6e3ba0c..12049bfd110baf885a06ead363ff4609f05ed21c 100644
--- a/packageship/application/initialize/source.json
+++ b/packageship/application/initialize/source.json
@@ -26,18 +26,6 @@
"type": "keyword",
"ignore_above": 256
},
- "relation": {
- "properties": {
- "bin_name": {
- "type": "keyword",
- "ignore_above": 256
- },
- "src_name": {
- "type": "keyword",
- "ignore_above": 256
- }
- }
- },
"release": {
"type": "keyword",
"ignore_above": 256
diff --git a/test/cli/init_command/comparison_relation_case/relationship/binary.json b/test/cli/init_command/comparison_relation_case/relationship/binary.json
index 5e202ba4819ad842d8ba5b344ebbf15f851da563..09a87898e08e787b571cfc35122cb0eca4f5251c 100644
--- a/test/cli/init_command/comparison_relation_case/relationship/binary.json
+++ b/test/cli/init_command/comparison_relation_case/relationship/binary.json
@@ -1,230 +1,212 @@
{
- "pkgKey": 35,
- "pkgId": "df487e3623660d477f556899fce77ac650322c4362d82e047c6efc013e07ae5b",
- "name": "Judy",
- "arch": "aarch64",
- "version": "1.0.5",
- "epoch": "0",
- "release": "19.oe1",
- "summary": "C library array",
- "description": "The package provides the most advanced core technology, the main\nadvantages are scalability, high performance and memory efficiency.",
- "url": "http://sourceforge.net/projects/judy/",
- "time_file": 1601219934,
- "time_build": 1601219910,
- "rpm_license": "LGPLv2+",
- "rpm_vendor": "http://openeuler.org",
- "rpm_group": "Unspecified",
- "rpm_buildhost": "obs-worker-0016",
- "rpm_sourcerpm": "Judy-1.0.5-19.oe1.src.rpm",
- "rpm_header_start": 5096,
- "rpm_header_end": 8772,
- "rpm_packager": "http://openeuler.org",
- "size_package": 114276,
- "size_installed": 356971,
- "size_archive": 358048,
- "location_href": "Packages/Judy-1.0.5-19.oe1.aarch64.rpm",
- "location_base": null,
- "checksum_type": "sha256",
- "src_name": "Judy",
- "provides": [
- {
- "name": "Judy",
- "flags": "EQ",
- "epoch": "0",
- "version": "1.0.5",
- "release": "19.oe1",
- "pkgKey": 35
- },
- {
- "name": "Judy(aarch-64)",
- "flags": "EQ",
- "epoch": "0",
- "version": "1.0.5",
- "release": "19.oe1",
- "pkgKey": 35
- },
- {
- "name": "libJudy.so.1()(64bit)",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35
- }
- ],
- "files": [
- {
- "name": "/etc/ima/digest_lists/0-metadata_list-compact-Judy-1.0.5-19.oe1.aarch64",
- "type": "file",
- "pkgKey": 35
- },
- {
- "name": "/etc/ima/digest_lists.tlv/0-metadata_list-compact_tlv-Judy-1.0.5-19.oe1.aarch64",
- "type": "file",
- "pkgKey": 35
- }
- ],
- "filelists": [
- {
- "pkgKey": 35,
- "dirname": "/usr/share/licenses",
- "filenames": "Judy",
- "filetypes": "d"
- },
- {
- "pkgKey": 35,
- "dirname": "/usr/share/licenses/Judy",
- "filenames": "COPYING",
- "filetypes": "f"
- },
- {
- "pkgKey": 35,
- "dirname": "/etc/ima/digest_lists.tlv",
- "filenames": "0-metadata_list-compact_tlv-Judy-1.0.5-19.oe1.aarch64",
- "filetypes": "f"
- },
- {
- "pkgKey": 35,
- "dirname": "/usr/lib64",
- "filenames": "libJudy.so.1/libJudy.so.1.0.3",
- "filetypes": "ff"
- },
- {
- "pkgKey": 35,
- "dirname": "/etc/ima/digest_lists",
- "filenames": "0-metadata_list-compact-Judy-1.0.5-19.oe1.aarch64",
- "filetypes": "f"
- }
- ],
- "src_version": "1.0.5",
- "requires": [
- {
- "name": "coreutils",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 14,
- "pre": "FALSE",
- "relation": [{ "bin_name": "coreutils", "src_name": "coreutils" }],
- "requires_type": "build"
- },
- {
- "name": "gawk",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 14,
- "pre": "FALSE",
- "relation": [{ "bin_name": "gawk", "src_name": "gawk" }],
- "requires_type": "build"
- },
- {
- "name": "gcc",
- "flags": "GE",
- "epoch": "0",
- "version": "4.1",
- "release": null,
- "pkgKey": 14,
- "pre": "FALSE",
- "relation": [{ "bin_name": "gcc", "src_name": "gcc" }],
- "requires_type": "build"
- },
- {
- "name": "make",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 14,
- "pre": "FALSE",
- "relation": [{ "bin_name": "make", "src_name": "make" }],
- "requires_type": "build"
- },
- {
- "name": "sed",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 14,
- "pre": "FALSE",
- "relation": [{ "bin_name": "sed", "src_name": "sed" }],
- "requires_type": "build"
- },
- {
- "name": "/bin/sh",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "TRUE",
- "relation": [
- { "bin_name": "bash", "src_name": "bash" },
- { "bin_name": "coreutils", "src_name": "coreutils" }
- ],
- "requires_type": "install"
- },
- {
- "name": "/bin/sh",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "FALSE",
- "relation": [
- { "bin_name": "bash", "src_name": "bash" },
- { "bin_name": "coreutils", "src_name": "coreutils" }
- ],
- "requires_type": "install"
- },
- {
- "name": "ld-linux-aarch64.so.1()(64bit)",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "FALSE",
- "relation": [{ "bin_name": "glibc", "src_name": "glibc" }],
- "requires_type": "install"
- },
- {
- "name": "ld-linux-aarch64.so.1(GLIBC_2.17)(64bit)",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "FALSE",
- "relation": [{ "bin_name": "glibc", "src_name": "glibc" }],
- "requires_type": "install"
- },
- {
- "name": "rtld(GNU_HASH)",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "FALSE",
- "relation": [{ "bin_name": "glibc", "src_name": "glibc" }],
- "requires_type": "install"
- },
- {
- "name": "libc.so.6(GLIBC_2.17)(64bit)",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 35,
- "pre": "FALSE",
- "relation": [{ "bin_name": "glibc", "src_name": "glibc" }],
- "requires_type": "install"
- }
- ]
- }
-
\ No newline at end of file
+ "pkgKey": 35,
+ "pkgId": "df487e3623660d477f556899fce77ac650322c4362d82e047c6efc013e07ae5b",
+ "name": "Judy",
+ "arch": "aarch64",
+ "version": "1.0.5",
+ "epoch": "0",
+ "release": "19.oe1",
+ "summary": "C library array",
+ "description": "The package provides the most advanced core technology, the main\nadvantages are scalability, high performance and memory efficiency.",
+ "url": "http://sourceforge.net/projects/judy/",
+ "time_file": 1601219934,
+ "time_build": 1601219910,
+ "rpm_license": "LGPLv2+",
+ "rpm_vendor": "http://openeuler.org",
+ "rpm_group": "Unspecified",
+ "rpm_buildhost": "obs-worker-0016",
+ "rpm_sourcerpm": "Judy-1.0.5-19.oe1.src.rpm",
+ "rpm_header_start": 5096,
+ "rpm_header_end": 8772,
+ "rpm_packager": "http://openeuler.org",
+ "size_package": 114276,
+ "size_installed": 356971,
+ "size_archive": 358048,
+ "location_href": "Packages/Judy-1.0.5-19.oe1.aarch64.rpm",
+ "location_base": null,
+ "checksum_type": "sha256",
+ "src_name": "Judy",
+ "provides": [
+ {
+ "name": "Judy",
+ "flags": "EQ",
+ "epoch": "0",
+ "version": "1.0.5",
+ "release": "19.oe1",
+ "pkgKey": 35
+ },
+ {
+ "name": "Judy(aarch-64)",
+ "flags": "EQ",
+ "epoch": "0",
+ "version": "1.0.5",
+ "release": "19.oe1",
+ "pkgKey": 35
+ },
+ {
+ "name": "libJudy.so.1()(64bit)",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35
+ }
+ ],
+ "files": [
+ {
+ "name": "/etc/ima/digest_lists/0-metadata_list-compact-Judy-1.0.5-19.oe1.aarch64",
+ "type": "file",
+ "pkgKey": 35
+ },
+ {
+ "name": "/etc/ima/digest_lists.tlv/0-metadata_list-compact_tlv-Judy-1.0.5-19.oe1.aarch64",
+ "type": "file",
+ "pkgKey": 35
+ }
+ ],
+ "filelists": [
+ {
+ "pkgKey": 35,
+ "dirname": "/usr/share/licenses",
+ "filenames": "Judy",
+ "filetypes": "d"
+ },
+ {
+ "pkgKey": 35,
+ "dirname": "/usr/share/licenses/Judy",
+ "filenames": "COPYING",
+ "filetypes": "f"
+ },
+ {
+ "pkgKey": 35,
+ "dirname": "/etc/ima/digest_lists.tlv",
+ "filenames": "0-metadata_list-compact_tlv-Judy-1.0.5-19.oe1.aarch64",
+ "filetypes": "f"
+ },
+ {
+ "pkgKey": 35,
+ "dirname": "/usr/lib64",
+ "filenames": "libJudy.so.1/libJudy.so.1.0.3",
+ "filetypes": "ff"
+ },
+ {
+ "pkgKey": 35,
+ "dirname": "/etc/ima/digest_lists",
+ "filenames": "0-metadata_list-compact-Judy-1.0.5-19.oe1.aarch64",
+ "filetypes": "f"
+ }
+ ],
+ "src_version": "1.0.5",
+ "requires": [
+ {
+ "name": "coreutils",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 14,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "gawk",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 14,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "gcc",
+ "flags": "GE",
+ "epoch": "0",
+ "version": "4.1",
+ "release": null,
+ "pkgKey": 14,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "make",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 14,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "sed",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 14,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "/bin/sh",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "TRUE",
+ "requires_type": "install"
+ },
+ {
+ "name": "/bin/sh",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "FALSE",
+ "requires_type": "install"
+ },
+ {
+ "name": "ld-linux-aarch64.so.1()(64bit)",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "FALSE",
+ "requires_type": "install"
+ },
+ {
+ "name": "ld-linux-aarch64.so.1(GLIBC_2.17)(64bit)",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "FALSE",
+ "requires_type": "install"
+ },
+ {
+ "name": "rtld(GNU_HASH)",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "FALSE",
+ "requires_type": "install"
+ },
+ {
+ "name": "libc.so.6(GLIBC_2.17)(64bit)",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 35,
+ "pre": "FALSE",
+ "requires_type": "install"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/cli/init_command/comparison_relation_case/relationship/source.json b/test/cli/init_command/comparison_relation_case/relationship/source.json
index 664add83ce8467e7d40d0f0f36676579e68775c6..e09f3cb33648a139e8f0a81ff831a55c83f1270b 100644
--- a/test/cli/init_command/comparison_relation_case/relationship/source.json
+++ b/test/cli/init_command/comparison_relation_case/relationship/source.json
@@ -1,72 +1,74 @@
{
- "pkgKey": 3,
- "pkgId": "a2c8963c6d5bdea8d3c9dc1bfa609db643c5a17077eff4eca21aa6e33ff9d4e5",
- "name": "CUnit",
- "arch": "src",
- "version": "2.1.3",
- "epoch": "0",
- "release": "21.oe1",
- "summary": "A Unit Testing Framework for C",
- "description": "CUnit is a lightweight system for writing, administering, and running unit tests in C\nIt provides C programmers a basic testing functionality with a flexible variety of user\ninterfaces.\n\nCUnit is built as a static library which is linked with the user's testing code. It\nuses a simple framework for building test structures, and provides a rich set of\nassertions for testing common data types. In addition, several different interfaces are\nprovided for running tests and reporting results.",
- "url": "http://cunit.sourceforge.net/",
- "time_file": 1601215538,
- "time_build": 1601215498,
- "rpm_license": "LGPLv2+",
- "rpm_vendor": "http://openeuler.org",
- "rpm_group": "Unspecified",
- "rpm_buildhost": "obs-worker-009",
- "rpm_sourcerpm": "",
- "rpm_header_start": 5096,
- "rpm_header_end": 7552,
- "rpm_packager": "http://openeuler.org",
- "size_package": 523353,
- "size_installed": 516791,
- "size_archive": 517172,
- "location_href": "Packages/CUnit-2.1.3-21.oe1.src.rpm",
- "location_base": null,
- "checksum_type": "sha256",
- "requires": [
- {
- "name": "automake",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 3,
- "pre": "FALSE",
- "relation": [{ "bin_name": "automake", "src_name": "automake" }],
- "requires_type": "build"
- },
- {
- "name": "git",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 3,
- "pre": "FALSE",
- "relation": [
- { "bin_name": "git", "src_name": "git" },
- { "bin_name": "git", "src_name": "git" }
- ],
- "requires_type": "build"
- },
- {
- "name": "libtool",
- "flags": null,
- "epoch": null,
- "version": null,
- "release": null,
- "pkgKey": 3,
- "pre": "FALSE",
- "relation": [{ "bin_name": "libtool", "src_name": "libtool" }],
- "requires_type": "build"
- }
- ],
- "subpacks": [
- { "name": "CUnit", "version": "2.1.3" },
- { "name": "CUnit-devel", "version": "2.1.3" },
- { "name": "CUnit-help", "version": "2.1.3" }
- ]
- }
-
\ No newline at end of file
+ "pkgKey": 3,
+ "pkgId": "a2c8963c6d5bdea8d3c9dc1bfa609db643c5a17077eff4eca21aa6e33ff9d4e5",
+ "name": "CUnit",
+ "arch": "src",
+ "version": "2.1.3",
+ "epoch": "0",
+ "release": "21.oe1",
+ "summary": "A Unit Testing Framework for C",
+ "description": "CUnit is a lightweight system for writing, administering, and running unit tests in C\nIt provides C programmers a basic testing functionality with a flexible variety of user\ninterfaces.\n\nCUnit is built as a static library which is linked with the user's testing code. It\nuses a simple framework for building test structures, and provides a rich set of\nassertions for testing common data types. In addition, several different interfaces are\nprovided for running tests and reporting results.",
+ "url": "http://cunit.sourceforge.net/",
+ "time_file": 1601215538,
+ "time_build": 1601215498,
+ "rpm_license": "LGPLv2+",
+ "rpm_vendor": "http://openeuler.org",
+ "rpm_group": "Unspecified",
+ "rpm_buildhost": "obs-worker-009",
+ "rpm_sourcerpm": "",
+ "rpm_header_start": 5096,
+ "rpm_header_end": 7552,
+ "rpm_packager": "http://openeuler.org",
+ "size_package": 523353,
+ "size_installed": 516791,
+ "size_archive": 517172,
+ "location_href": "Packages/CUnit-2.1.3-21.oe1.src.rpm",
+ "location_base": null,
+ "checksum_type": "sha256",
+ "requires": [
+ {
+ "name": "automake",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 3,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "git",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 3,
+ "pre": "FALSE",
+ "requires_type": "build"
+ },
+ {
+ "name": "libtool",
+ "flags": null,
+ "epoch": null,
+ "version": null,
+ "release": null,
+ "pkgKey": 3,
+ "pre": "FALSE",
+ "requires_type": "build"
+ }
+ ],
+ "subpacks": [
+ {
+ "name": "CUnit",
+ "version": "2.1.3"
+ },
+ {
+ "name": "CUnit-devel",
+ "version": "2.1.3"
+ },
+ {
+ "name": "CUnit-help",
+ "version": "2.1.3"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/cli/init_command/comparison_relation_case/test_relationship.py b/test/cli/init_command/comparison_relation_case/test_relationship.py
index 7e389297339217f58438053e472b65030fd76fe2..147bb9823cadd0bfb3aec1dae8c62bf443a9042c 100644
--- a/test/cli/init_command/comparison_relation_case/test_relationship.py
+++ b/test/cli/init_command/comparison_relation_case/test_relationship.py
@@ -11,6 +11,7 @@
# See the Mulan PSL v2 for more details.
# ******************************************************************************/
# -*- coding:utf-8 -*-
+import json
import os
import shutil
from pathlib import Path
diff --git a/test/unpack/compress_files/gz_error.txt b/test/unpack/compress_files/gz_error.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9ea415ee96ce4459710a2c5cab997053cb5c207f
--- /dev/null
+++ b/test/unpack/compress_files/gz_error.txt
@@ -0,0 +1 @@
+gz error file
\ No newline at end of file
diff --git a/test/unpack/compress_files/tar_error.txt b/test/unpack/compress_files/tar_error.txt
new file mode 100644
index 0000000000000000000000000000000000000000..beb36750c7e906599a4765ec8debf914f4c0d035
--- /dev/null
+++ b/test/unpack/compress_files/tar_error.txt
@@ -0,0 +1 @@
+tar file error
\ No newline at end of file
diff --git a/test/unpack/compress_files/xz_error.txt b/test/unpack/compress_files/xz_error.txt
new file mode 100644
index 0000000000000000000000000000000000000000..3fd014f7e5ccf3864da047743a6af767355c4937
--- /dev/null
+++ b/test/unpack/compress_files/xz_error.txt
@@ -0,0 +1 @@
+xz file error
\ No newline at end of file
diff --git a/test/unpack/test_unpack.py b/test/unpack/test_unpack.py
index 64ad3381e58867c83e1c10a9f125341771e2c454..90bcae8dcba6e27375467c292e675e84a64d1e9b 100644
--- a/test/unpack/test_unpack.py
+++ b/test/unpack/test_unpack.py
@@ -34,13 +34,13 @@ class TestUnpack(TestCase):
def test_gz_unpack(self):
"""unpack gz file"""
with self.assertRaises(UnpackError):
- Unpack.dispatch(".gz", file_path=os.path.join(self.path, "bz2_error.txt"),
+ Unpack.dispatch(".gz", file_path=os.path.join(self.path, "gz_error.txt"),
save_file=os.path.join(self.path, "bz2_unpack.sqlite"))
def test_error_tar(self):
"""error tar file"""
with self.assertRaises(IOError):
- Unpack.dispatch(".tar", file_path=os.path.join(self.path, "bz2_error.txt"),
+ Unpack.dispatch(".tar", file_path=os.path.join(self.path, "tar_error.txt"),
save_file=os.path.join(self.path, "bz2_unpack.sqlite"))
def test_tar_unpack(self):
@@ -50,9 +50,14 @@ class TestUnpack(TestCase):
def test_error_zip_unpack(self):
"""unpack error zip file"""
+ file = os.path.join(self.path, "zip_error.txt")
+ with open(file, "w", encoding="utf-8") as f:
+ f.write("error zip file")
with self.assertRaises(IOError):
- Unpack.dispatch(".zip", file_path=os.path.join(self.path, "bz2_error.txt"),
+ Unpack.dispatch(".zip", file_path=file,
save_file=os.path.join(self.path, "zip_file.sqlite"))
+ if os.path.exists(file):
+ os.remove(file)
def test_zip_unpack(self):
"""unpack zip file"""
@@ -64,7 +69,7 @@ class TestUnpack(TestCase):
def test_xz_unpack(self):
"""unpack xz file"""
with self.assertRaises(UnpackError):
- Unpack.dispatch(".xz", file_path=os.path.join(self.path, "bz2_error.txt"),
+ Unpack.dispatch(".xz", file_path=os.path.join(self.path, "xz_error.txt"),
save_file=os.path.join(self.path, "xz.sqlite"))
def test_file_path_none(self):

View File

@ -1,212 +0,0 @@
diff --git a/packageship/application/apps/package/view.py b/packageship/application/apps/package/view.py
index 86072fc61f78ddcae87a53728d1490821ccc41a7..3ca7ffa261d93b8868571e9bedf13f1232e4768e 100644
--- a/packageship/application/apps/package/view.py
+++ b/packageship/application/apps/package/view.py
@@ -108,14 +108,16 @@ class SourcePackages(ParsePackageMethod):
page_num = result.get("page_num")
page_size = result.get("page_size")
query_pkg_name = [result.get("query_pkg_name")] if result.get(
- "query_pkg_name") else []
+ "query_pkg_name") else None
find_package = Package()
try:
result_all = find_package.all_src_packages(
result.get("database_name"), page_num=page_num, page_size=page_size, package_list=query_pkg_name,
command_line=result.get("command_line"))
- except (ElasticSearchQueryException, DatabaseConfigException, PackageInfoGettingError) as e:
+ except (ElasticSearchQueryException, DatabaseConfigException):
return jsonify(self.rspmsg.body('connect_db_error'))
+ except PackageInfoGettingError:
+ return jsonify(self.rspmsg.body('pack_name_not_found'))
if result_all:
return jsonify(self.parse_package(result_all, page_size))
return jsonify(self.rspmsg.body("table_name_not_exist"))
@@ -167,14 +169,16 @@ class BinaryPackages(ParsePackageMethod):
page_num = result.get("page_num")
page_size = result.get("page_size")
query_pkg_name = [result.get("query_pkg_name")] if result.get(
- "query_pkg_name") else []
+ "query_pkg_name") else None
find_package = Package()
try:
result_all = find_package.all_bin_packages(
result.get("database_name"), page_num=page_num, page_size=page_size, package_list=query_pkg_name,
command_line=result.get("command_line"))
- except (ElasticSearchQueryException, DatabaseConfigException, PackageInfoGettingError) as e:
+ except (ElasticSearchQueryException, DatabaseConfigException):
return jsonify(self.rspmsg.body('connect_db_error'))
+ except PackageInfoGettingError:
+ return jsonify(self.rspmsg.body('pack_name_not_found'))
if result_all:
return jsonify(self.parse_package(result_all, page_size))
return jsonify(self.rspmsg.body("table_name_not_exist"))
diff --git a/packageship/application/query/pkg.py b/packageship/application/query/pkg.py
index 6c4e1f253ecf0cef68ab6319a9fae1731e826a8b..67e5c2e3a2cab3107c1d1fcb1edc618ed6f2a370 100644
--- a/packageship/application/query/pkg.py
+++ b/packageship/application/query/pkg.py
@@ -82,7 +82,7 @@ class QueryPackage(object):
Raises: DatabaseConfigException ElasticSearchQueryException
"""
self.rpm_type = SOURCE_DB_TYPE
- response = self._get_rpm_info(src_list, database, page_num, page_size, command_line)
+ response = self._get_rpm_info(database, page_num, page_size, command_line, rpm_list=src_list)
return response
def get_bin_info(self, binary_list, database, page_num, page_size, command_line=False):
@@ -98,7 +98,7 @@ class QueryPackage(object):
Raises: DatabaseConfigException ElasticSearchQueryException
"""
self.rpm_type = BINARY_DB_TYPE
- response = self._get_rpm_info(binary_list, database, page_num, page_size, command_line)
+ response = self._get_rpm_info(database, page_num, page_size, command_line, rpm_list=binary_list)
return response
def _query_src_bin_rpm(self, rpm_list, query_db_type, specify_db):
@@ -150,7 +150,7 @@ class QueryPackage(object):
return rpm_info
- def _get_rpm_info(self, rpm_list, database, page_num, page_size, command_line):
+ def _get_rpm_info(self, database, page_num, page_size, command_line, rpm_list=None):
"""
General method for obtaining package details
Args:
@@ -162,10 +162,16 @@ class QueryPackage(object):
Returns: result of query package details
"""
- self.index = UNDERLINE.join((database, self.rpm_type))
response = dict(total=0, data=[])
+ # If the query list is empty, return directly; if the query list is None, it means query all packages.
+ if isinstance(rpm_list, list):
+ rpm_list = [rpm for rpm in rpm_list if rpm]
+ if not rpm_list:
+ return response
+
+ self.index = UNDERLINE.join((database, self.rpm_type))
# Used for Command Line,query all data and no Pagination
- if command_line and not rpm_list:
+ if command_line and rpm_list is None:
query_result = self._db_session.scan(index=self.index, body=QueryBody.QUERY_ALL)
total_num = self._db_session.count(index=self.index, body=QueryBody.QUERY_ALL)
response['total'] = total_num.get('count')
@@ -190,6 +196,7 @@ class QueryPackage(object):
if query_all else query_result['hits']['total']['value']
response['total'] = total_num
except KeyError:
+ response = dict(total=0, data=[])
return response
return response
@@ -211,7 +218,7 @@ class QueryPackage(object):
# Query specify rpm_list of Command line mode
query_body = self._process_query_terms(DEFAULT_PAGE_NUM, MAX_PAGE_SIZE, rpm_list)
else:
- if not rpm_list:
+ if rpm_list is None:
# Query all data and Pagination of UI mode
query_body = self._format_paging_query_all(page_num, page_size)
query_all = True
diff --git a/test/cli/depend_commands/__init__.py b/test/cli/depend_commands/__init__.py
index 1aab4d66def3400065e077e884258ab446e0f2da..13fbaa063d39e3a19c9dec58fc480fe05c35aa3b 100755
--- a/test/cli/depend_commands/__init__.py
+++ b/test/cli/depend_commands/__init__.py
@@ -130,6 +130,7 @@ class DependTestBase(ClientTest):
if not pkg_info:
continue
ret_dict_p["hits"]["hits"].append(pkg_info)
+ ret_dict_p['hits']['total']['value'] = len(pkg_lst)
@staticmethod
def make_newline_split_res(ln, lines, idx):
@@ -244,12 +245,12 @@ class DependTestBase(ClientTest):
if handle_tolong_name_in_newline(ln, source_lines, idx):
continue
source_lines.append(split_ln)
-
+
if not all(normal_query_judgment_lst):
raise ValueError(
"check Your expected str please, must be a normal query result"
)
-
+
return binary_lines, source_lines
def assert_result(self):
@@ -264,12 +265,12 @@ class DependTestBase(ClientTest):
current_bin, current_src = self._process_depend_command_value(self.print_result)
self.assertListEqual(sorted(excepted_bin), sorted(current_bin))
self.assertListEqual(sorted(excepted_src), sorted(current_src))
-
+
def assert_exc_result(self):
"""assert_exc_result
"""
- super(DependTestBase,self).assert_result()
-
+ super(DependTestBase, self).assert_result()
+
def _es_search_result(self, index: str, body: dict):
"""
Get different return values through different call parameters
@@ -281,7 +282,7 @@ class DependTestBase(ClientTest):
ret_dict(dict):Parsable es-like data for the project
"""
- ret_dict = {"hits": {"hits": []}}
+ ret_dict = {"hits": {"hits": [], "total": {"value": 0}}}
if index == "databaseinfo":
return DATA_BASE_INFO
elif "binary" in index:
diff --git a/test/cli/package_command/pkg_list/test_pkg_list.py b/test/cli/package_command/pkg_list/test_pkg_list.py
index 3c7f9930a773c9aea1eafeb6e0739a10d6c5b7db..da5300b1ca5935d116700f0d20ca8352e16bf464 100644
--- a/test/cli/package_command/pkg_list/test_pkg_list.py
+++ b/test/cli/package_command/pkg_list/test_pkg_list.py
@@ -77,8 +77,8 @@ HINT :Make sure the table is valid"""
test pkgInfoGetingError for all bin packages
"""
self.excepted_str = """
-ERROR_CONTENT :Failed to Connect the database
-HINT :Check the connection"""
+ERROR_CONTENT :The querying package does not exist in the databases
+HINT :Use the correct package name and try again"""
self.command_params = ["os-version"]
self.mock_es_search(return_value=DATA_BASE_INFO)
self.mock_es_scan(return_value=[])
diff --git a/test/cli/package_command/pkg_list/test_pkg_list_s.py b/test/cli/package_command/pkg_list/test_pkg_list_s.py
index 3044c93e7ac5b64fa1de8195c766bd10fd554e0b..45c949dcbe007e719a2004b22a83b72aa8c59986 100644
--- a/test/cli/package_command/pkg_list/test_pkg_list_s.py
+++ b/test/cli/package_command/pkg_list/test_pkg_list_s.py
@@ -77,8 +77,8 @@ HINT :Make sure the table is valid"""
test pkgInfoGettingError
"""
self.excepted_str = """
-ERROR_CONTENT :Failed to Connect the database
-HINT :Check the connection"""
+ERROR_CONTENT :The querying package does not exist in the databases
+HINT :Use the correct package name and try again"""
self.command_params = ["os-version", "-s"]
self.mock_es_search(return_value=DATA_BASE_INFO)
self.mock_es_scan(return_value=[])
diff --git a/test/test_module/test_database_query/test_database_query_package/test_query_bin_info.py b/test/test_module/test_database_query/test_database_query_package/test_query_bin_info.py
index e59e82e5768015a328ce2ceecf4d60e5a655b9b8..3254eb8b2089bc8a76ba1844d60d92938ae888d9 100644
--- a/test/test_module/test_database_query/test_database_query_package/test_query_bin_info.py
+++ b/test/test_module/test_database_query/test_database_query_package/test_query_bin_info.py
@@ -41,7 +41,7 @@ class TestQueryBinaryPkgInfo(TestCase):
"""
self.session.scan = MagicMock(return_value=self.ALL_BINARY_RPM_INFO)
self.session.count = MagicMock(return_value={"count": 5})
- query_result = self.query_package.get_bin_info(binary_list=[], database='os_version_1', page_num=1, page_size=20,
+ query_result = self.query_package.get_bin_info(binary_list=None, database='os_version_1', page_num=1, page_size=20,
command_line=True)
self.assertIsNotNone(query_result['data'])
@@ -52,7 +52,7 @@ class TestQueryBinaryPkgInfo(TestCase):
"""
self.session.query = MagicMock(return_value=self.ALL_BINARY_INFO_PAGING)
self.session.count = MagicMock(return_value={"count": 5})
- query_result = self.query_package.get_bin_info(binary_list=[], database='os_version_1', page_num=1, page_size=5,
+ query_result = self.query_package.get_bin_info(binary_list=None, database='os_version_1', page_num=1, page_size=5,
command_line=False)
self.assertEqual(len(query_result['data']), 5)

View File

@ -1,167 +0,0 @@
diff -Nur pkgship-2.2.0/packageship/application/core/compare/validate.py pkgship-2.2.1/packageship/application/core/compare/validate.py
--- pkgship-2.2.0/packageship/application/core/compare/validate.py 2021-08-16 03:27:41.000000000 +0000
+++ pkgship-2.2.1/packageship/application/core/compare/validate.py 2021-11-18 03:44:09.566149890 +0000
@@ -1,81 +1,81 @@
-#!/usr/bin/python3
-# ******************************************************************************
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
-# licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-# See the Mulan PSL v2 for more details.
-# ******************************************************************************/
-"""
-Validate args of compare command
-"""
-import os
-import shutil
-
-from packageship.application.common.constant import SUPPORT_QUERY_TYPE
-from packageship.application.query import database
-
-# Maximum number of supported databases
-MAX_SUPPORT_DB = 4
-
-
-def validate_args(depend_type, dbs, output_path):
- """
- validate args of compare command
- :param depend_type:
- :param dbs: input databases
- :param output_path:
- :return:
- """
- if not all((depend_type, dbs, output_path)):
- raise ValueError('[ERROR] Parameter error, please check the parameter and query again.')
- # verify depend type
- if depend_type not in SUPPORT_QUERY_TYPE:
- raise ValueError(f'[ERROR] Dependent type ({depend_type}) is not supported, please enter again.')
- # verify dbs
- _validate_dbs(dbs)
- # verify output_path
- if not os.path.isdir(output_path) or not _is_writable(path=output_path):
- raise ValueError(f'[ERROR] Output path ({output_path}) not exist or does not support user pkgshipuser writing.')
-
-
-def _validate_dbs(dbs):
- """
- Verify that the input database is supported
- :param dbs: input dbs
- :return: None
- """
- if len(dbs) > MAX_SUPPORT_DB:
- raise ValueError(f'[ERROR] Supports up to four databases.')
-
- if len(dbs) != len(set(dbs)):
- raise ValueError(f'[ERROR] Duplicate database entered.')
-
- support_dbs = database.get_db_priority()
- for db in dbs:
- if db not in support_dbs:
- raise ValueError(f'[ERROR] Database ({db}) is not supported, please enter again.')
- if len(dbs) == 1:
- print('[WARNING] There is only one input database, '
- 'and only dependent information files will be generated without data comparison.')
-
-
-def _is_writable(path):
- """
- Verify whether run user has write permission to the output path
- :param path: cvs save path
- :return: True False
- """
- tmp_path = os.path.join(path, 'tmp_compare')
- try:
- os.mkdir(tmp_path)
- except PermissionError:
- return False
- finally:
- if os.path.isdir(tmp_path):
- shutil.rmtree(tmp_path)
- return True
+#!/usr/bin/python3
+# ******************************************************************************
+# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
+# licensed under the Mulan PSL v2.
+# You can use this software according to the terms and conditions of the Mulan PSL v2.
+# You may obtain a copy of Mulan PSL v2 at:
+# http://license.coscl.org.cn/MulanPSL2
+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+# PURPOSE.
+# See the Mulan PSL v2 for more details.
+# ******************************************************************************/
+"""
+Validate args of compare command
+"""
+import os
+import shutil
+
+from packageship.application.common.constant import SUPPORT_QUERY_TYPE
+from packageship.application.query import database
+
+# Maximum number of supported databases
+MAX_SUPPORT_DB = 4
+
+
+def validate_args(depend_type, dbs, output_path):
+ """
+ validate args of compare command
+ :param depend_type:
+ :param dbs: input databases
+ :param output_path:
+ :return:
+ """
+ if not all((depend_type, dbs, output_path)):
+ raise ValueError('[ERROR] Parameter error, please check the parameter and query again.')
+ # verify depend type
+ if depend_type not in SUPPORT_QUERY_TYPE:
+ raise ValueError(f'[ERROR] Dependent type ({depend_type}) is not supported, please enter again.')
+ # verify dbs
+ _validate_dbs(dbs)
+ # verify output_path
+ if not os.path.isdir(output_path) or not _is_writable(path=output_path):
+ raise ValueError(f'[ERROR] Output path ({output_path}) not exist or does not support user pkgshipuser writing.')
+
+
+def _validate_dbs(dbs):
+ """
+ Verify that the input database is supported
+ :param dbs: input dbs
+ :return: None
+ """
+ if len(dbs) > MAX_SUPPORT_DB:
+ raise ValueError(f'[ERROR] Supports up to four databases.')
+
+ if len(dbs) != len(set(dbs)):
+ raise ValueError(f'[ERROR] Duplicate database entered.')
+
+ support_dbs = database.get_db_priority()
+ for db in dbs:
+ if db not in support_dbs:
+ raise ValueError(f'[ERROR] Database ({db}) is not supported, please enter again.')
+ if len(dbs) == 1:
+ print('[WARNING] There is only one input database, '
+ 'and only dependent information files will be generated without data comparison.')
+
+
+def _is_writable(path):
+ """
+ Verify whether run user has write permission to the output path
+ :param path: cvs save path
+ :return: True False
+ """
+ tmp_path = os.path.join(path, 'tmp_compare')
+ try:
+ os.mkdir(tmp_path)
+ except PermissionError:
+ return False
+ finally:
+ if os.path.isdir(tmp_path):
+ shutil.rmtree(tmp_path)
+ return True

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
diff --git a/README.md b/README.md
index eef54927c47f8b5703daa9c91590f38cadd98039..6be49b1586555cc3f09afc0d5baa6ef033ca3aea 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,8 @@ pkgship是一款管理OS软件包依赖关系提供依赖和被依赖关系
| Python | 版本 3.8及以上 |
## 安装工具
+> 说明该软件支持在docker下运行。目前在openEuler21.09版本下由于环境条件限制创建docker时请使用--privileged参数不使用--privileged参数将会导致软件启动失败后续适配后将更新该文档。
+
**1、pkgship工具安装**
工具安装可通过以下两种方式中的任意一种实现。
@@ -223,6 +225,8 @@ pkgshipd stop 停止服务
> 每次起停周期内仅支持一种方式,不允许两种操作同时使用。
>
> pkgshipd启动方式只允许在pkgshipuser用户下操作。
+>
+> docker环境下如果不支持systemctl命令请使用pkgshipd启停方式。
## 工具使用

View File

@ -1,13 +0,0 @@
diff --git a/packageship/application/initialize/integration.py b/packageship/application/initialize/integration.py
index 99668eeb51b8199b5a80daea1917cbb395e57824..6a5c00f867dfcf54c629a5a48a8c1b5b44a442b1 100644
--- a/packageship/application/initialize/integration.py
+++ b/packageship/application/initialize/integration.py
@@ -304,7 +304,7 @@ class InitializeService:
es_json["provides"] = list()
for provide in self._bin_provides.get(bin_pack["pkgKey"]):
- component_json = ESJson()
+ component_json = dict()
component_json['component'] = provide["name"]
_build(component_json, provide)
_install(component_json, provide)

View File

@ -1,123 +0,0 @@
diff --color -Nur a/packageship/application/cli/base.py b/packageship/application/cli/base.py
--- a/packageship/application/cli/base.py 2021-08-14 22:23:58.000000000 +0800
+++ b/packageship/application/cli/base.py 2022-01-09 11:17:09.842737171 +0800
@@ -30,7 +30,6 @@
else:
from packageship.application.common.constant import ResponseCode
from packageship.application.common.constant import ERROR_CON
- from packageship.libs.terminal_table import TerminalTable
class BaseCommand():
@@ -130,8 +129,7 @@
Raises:
"""
- table = TerminalTable(title)
- # table.set_style(prettytable.PLAIN_COLUMNS)
+ table = prettytable.PrettyTable(title)
table.align = 'l'
table.horizontal_char = '='
table.junction_char = '='
diff --color -Nur a/packageship/application/cli/cmd.py b/packageship/application/cli/cmd.py
--- a/packageship/application/cli/cmd.py 2021-08-14 22:23:58.000000000 +0800
+++ b/packageship/application/cli/cmd.py 2022-01-09 11:17:30.935093041 +0800
@@ -26,7 +26,6 @@
from packageship.application.common.constant import ResponseCode
from packageship.application.common.constant import ListNode
from packageship.application.common.constant import UWSIG_PATH
- from packageship.libs.terminal_table import TerminalTable
from packageship.application.common.constant import ERROR_CON
from packageship.application.cli.commands.allpkg import AllPackageCommand
from packageship.application.cli.commands.bedepend import BeDependCommand
diff --color -Nur a/packageship/libs/terminal_table.py b/packageship/libs/terminal_table.py
--- a/packageship/libs/terminal_table.py 2021-08-14 22:23:59.000000000 +0800
+++ b/packageship/libs/terminal_table.py 1970-01-01 08:00:00.000000000 +0800
@@ -1,87 +0,0 @@
-#!/usr/bin/python3
-# ******************************************************************************
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
-# licensed under the Mulan PSL v2.
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
-# You may obtain a copy of Mulan PSL v2 at:
-# http://license.coscl.org.cn/MulanPSL2
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-# PURPOSE.
-# See the Mulan PSL v2 for more details.
-# ******************************************************************************/
-"""
-Description: Simple encapsulation of pretty table
-Class: TerminalTable
-"""
-import os
-from prettytable import PrettyTable
-
-
-class TerminalTable(PrettyTable):
- """
- Description: Rewrite several methods in prettytable
- Attributes:
- bottom:Bottom display
- _vertical_char:Draw characters with vertical edges
- """
-
- def __init__(self, field_names=None, **kwargs):
- super().__init__(field_names, **kwargs)
- self.bottom = kwargs.get('bottom') or False
- self._vertical_char = kwargs.get('vertical_char') or self._unicode("")
-
- def _reduce_widths(self, columns, lpad, rpad):
- """
- Description: Handling over-width columns
- Args:
- columns:columns
- lpad:The number of spaces to the left of the column data
- rpad:The number of spaces to the right of the column data
- Returns:
-
- """
- extra_width = sum(self._widths) - columns + (lpad + rpad) * len(self._widths)
- avg_width = columns / len(self._widths)
- gt_avg = filter(lambda x: x > avg_width, self._widths)
- denominator = sum(
- [(item - avg_width) / avg_width * 1.0 for item in gt_avg])
- zoom_width = list()
- for width in self._widths:
- if width > avg_width:
- width = round(width - ((width - avg_width) / avg_width * 1.0) /
- denominator * extra_width)
- zoom_width.append(width)
- self._widths = zoom_width
- if sum(self._widths) > columns:
- _max_val = max(self._widths)
- self._widths[self._widths.index(_max_val)] = _max_val - (sum(self._widths) - columns)
-
- def _compute_widths(self, rows, options):
- """
- Description: Calculated width
- Args:
- rows:row of data, should be a list with as many elements as the table
- options:option
- Returns:
-
- """
- super()._compute_widths(rows, options)
- lpad, rpad = self._get_padding_widths(options)
- # Total number of columns
- try:
- window_width = os.get_terminal_size().columns
- except OSError as os_error:
- window_width = 100
- _columns = window_width - len(self._widths) - 1
- if _columns < sum(map(lambda x: x + lpad + rpad, self._widths)):
- coefficient = 1
- self._reduce_widths(_columns, lpad, rpad)
- else:
- coefficient = _columns / (sum(map(lambda x: x, self._widths)) * 1.0)
- self._widths = list(
- map(lambda x: round(x * coefficient - lpad - rpad), self._widths))
- if sum(map(lambda x: x + lpad + rpad, self._widths)) > _columns:
- _max_val = max(self._widths)
- self._widths[self._widths.index(_max_val)] =\
- _max_val - (sum(map(lambda x: x + lpad + rpad, self._widths)) - _columns)

View File

@ -1,36 +0,0 @@
# pkgship
#### Description
a package depend query tool
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

193
README.md
View File

@ -11,6 +11,8 @@
- [配置参数](#配置参数)
- [服务启动和停止](#服务启动和停止)
- [工具使用](#工具使用)
- [日志查看和转储](#日志查看和转储)
- [扩展工具pkgship-panel](#扩展工具pkgship-panel)
<!-- /TOC -->
@ -24,22 +26,36 @@ pkgship是一款管理OS软件包依赖关系提供依赖和被依赖关系
系统采用flask-restful开发
![avatar](./doc/design/pkgimg/packagemanagement.JPG)
![输入图片说明](https://gitee.com/openeuler/pkgship/raw/master/doc/design/pkgimg/packagemanagement.JPG)
## 软件下载
* Repo源挂载正式发布地址<https://repo.openeuler.org/>
* 源码获取地址:<https://gitee.com/openeuler/pkgship>
* rpm包版本获取地址<https://117.78.1.88/project/show/openEuler:Mainline>
* rpm包版本获取地址<https://build.openeuler.org/package/show/openEuler:22.09/pkgship>
## 运行环境
* 可用内存700M以上
* python版本 3.8及以上
* Elasticsearch 版本7.10.1
* Redis
- 硬件配置:
| 配置项 | 推荐规格 |
| -------- | ----------- |
| CPU | 8核 |
| 内存 | 32G最小4G |
| 网络带宽 | 300M |
| I/O | 375MB/sec |
- 软件配置:
| 软件名 | 版本和规格 |
| ------------- | ------------------------------------------ |
| Elasticsearch | 版本7.10.1;单机部署可用;有能力可部署集群 |
| Redis | 建议5.0.4及以上建议大小配置为内存的3/4 |
| Python | 版本 3.8及以上 |
## 安装工具
> 说明该软件支持在docker下运行。目前在openEuler21.09版本下由于环境条件限制创建docker时请使用--privileged参数不使用--privileged参数将会导致软件启动失败后续适配后将更新该文档。
**1、pkgship工具安装**
工具安装可通过以下两种方式中的任意一种实现。
@ -79,12 +95,18 @@ pkgship是一款管理OS软件包依赖关系提供依赖和被依赖关系
/bin/bash auto_install_pkgship_requires.sh elasticsearch
```
或者
> 目前由于rpm包方式安装Elasticsearch默认为无密码模式且pkgship需使用无密码设置的Elasticsearch所以建议Elasticsearch和pkgship安装在同一服务器以通过网络隔离提高安全性。后续将支持Elasticsearch设置用户名密码。
或者
```
/bin/bash auto_install_pkgship_requires.sh redis
```
**3、安装后添加用户**
在安装pkgship软件后会自动创建名为pkgshipuser的用户和名为pkgshipuser的用户组无需手动创建后续服务启动和运行时都会以该用户角色操作。
## 配置参数
1.在配置文件中对相应参数进行配置,系统的默认配置文件存放在 /etc/pkgship/packge.ini请根据实际情况进行配置更改。
@ -98,10 +120,12 @@ vim /etc/pkgship/package.ini
; 初始化数据库时导入的yaml文件存放位置该yaml中记录导入的sqlite文件位置。
init_conf_path=/etc/pkgship/conf.yaml
; 数据库端口。
; 若部署为客户端-服务端方式服务端需保证query_ip_addr为本机ip或者0.0.0.0
; 并且客户端可通过query_ip_addr加query_port访问服务端或者通过设置映射的remote_host访问服务端。
; 服务查询端口。
query_port=8090
; 数据库ip地址
; 服务查询ip
query_ip_addr=127.0.0.1
; 远程服务的地址,命令行可以直接调用远程服务来完成数据请求。
@ -146,7 +170,7 @@ redis_port=6379
redis_max_connections=10
[DATABASE-数据库]
;数据库访问地址,默认为本机地址
;数据库访问地址,建议设置为本机地址
database_host=127.0.0.1
;数据库访问端口默认为9200
@ -158,12 +182,12 @@ database_port=9200
conf.yaml 文件默认存放在 /etc/pkgship/ 路径下pkgship会通过该配置读取要建立的数据库名称以及需要导入的sqlite文件也支持配置sqlite文件所在的repo地址。conf.yaml 示例如下所示。
```yaml
dbname: openEuler-20.03 #数据库名称
src_db_file: /etc/pkgship/repo/openEuler-20.09/src #源码包所在的本地路径
bin_db_file: /etc/pkgship/repo/openEuler-20.09/bin #二进制包所在的本地路径
dbname: oe20.03 #数据库名称
src_db_file: file:///etc/pkgship/repo/openEuler-20.09/src #源码包所在的本地路径
bin_db_file: file:///etc/pkgship/repo/openEuler-20.09/bin #二进制包所在的本地路径
priority: 1 #数据库优先级
dbname: openEuler-20.09
dbname: oe20.09
src_db_file: https://repo.openeuler.org/openEuler-20.09/source #源码包所在的repo源
bin_db_file: https://repo.openeuler.org/openEuler-20.09/everything/aarch64 #二进制包所在的repo源
priority: 2
@ -173,7 +197,14 @@ priority: 2
> 如需更改存放路径请更改package.ini下的 init_conf_path 选项。
>
> 不支持直接配置sqlite文件路径。
> sqlite文件配置规格
>
> - 为节省空间不支持直接使用sqlite文件请使用包含sqlite文件的压缩包支持压缩格式为.bz .gz .tar .zip
> - sqlite压缩包命名格式为xxx.primary.sqlite.xx二进制包所在路径下还需使用filelists类型的sqlite压缩文件命名格式为xxx.filelists.sqlite.xx,一般网络地址下的sqlite压缩包都符合该格式。
> - 本地路径请使用file://前缀。
> - 本地路径和网络地址路径都要满足sqlite压缩包位于配置路径/repodata/xxx.primary.sqlite.xx
>
> dbname请使用小写字母或者数字不支持大写字母。
## 服务启动和停止
pkgship启动和停止方式有两种systemctl方式和pkgshipd方式其中systemctl方式启动可以有异常停止自启动的机制。两种方式的执行命令为
@ -194,50 +225,52 @@ pkgshipd stop 停止服务
> 每次起停周期内仅支持一种方式,不允许两种操作同时使用。
>
> pkgshipd启动方式只允许在pkgshipduser用户下操作。
> pkgshipd启动方式只允许在pkgshipuser用户下操作。
>
> docker环境下如果不支持systemctl命令请使用pkgshipd启停方式。
## 工具使用
1. 数据库初始化。
> 使用场景服务启动后为了能查询对应的数据库比如openEuler-20.09 openEuler-21.03中的包信息及包依赖关系需要将这些数据库通过createrepo生成的sqlite分为源码库和二进制库导入进服务内生成对应的包信息json体然后插入Elasticsearch对应的数据库中。数据库名为根据config.yaml中配置的dbname生成的dbname-source/binary[-filepath]为可选参数
> 使用场景服务启动后为了能查询对应的数据库比如oe20.03oe20.09中的包信息及包依赖关系需要将这些数据库通过createrepo生成的sqlite分为源码库和二进制库导入进服务内生成对应的包信息json体然后插入Elasticsearch对应的数据库中。数据库名为根据config.yaml中配置的dbname生成的dbname-source/binary。
```bash
pkgship init [-filepath path]
```
> 参数说明:
> -filepath指定初始化配置文件config.yaml的路径可以使用相对路径和绝对路径不带参数则使用默认配置初始化。
> -filepath指定初始化配置文件config.yaml的路径可以使用相对路径和绝对路径不带参数则使用默认配置初始化,可选参数
2. 单包查询。
用户可查询源码包或者二进制包(packagename)在指定数据库表database中的具体信息。
> 使用场景:用户可查询源码包或者二进制包在指定数据库中的具体信息packagename,database为必选参数,-s为可选参数
> 使用场景:用户可查询源码包或者二进制包在指定数据库中的具体信息。
```bash
pkgship pkginfo $packageName $database [-s]
```
> 参数说明:
> packagename指定要查询的软件包名。
> database指定具体的数据库名称。
> packagename指定要查询的软件包名,必传参数
> database指定具体的数据库名称,必传参数
>
> -s: 指定`-s`将查询的是`src`源码包信息;若未指定 默认查询`bin`二进制包信息
> -s: 指定`-s`将查询的是`src`源码包信息;若未指定 默认查询`bin`二进制包信息,可选参数。
3. 所有包查询。
查询数据库下包含的所有包的信息。
> 使用场景:用户可查询指定数据库下包含的所有软件包信息。其中tablename为必选参数-s为可选参数。
> 使用场景:用户可查询指定数据库下包含的所有软件包信息。
```bash
pkgship list $database [-s]
```
> 参数说明:
> database指定具体的数据库名称。
> -s: 指定`-s`将查询的是`src`源码包信息;若未指定 默认查询`bin`二进制包信息
> database指定具体的数据库名称,必传参数
> -s: 指定`-s`将查询的是`src`源码包信息;若未指定 默认查询`bin`二进制包信息,可选参数。
4. 安装依赖查询。
@ -285,7 +318,7 @@ pkgshipd stop 停止服务
> 参数说明:
>
> pkgName需要查询安装的依赖的二进制包名字,支持传多个;必传参数。
> pkgName需要查询安装的依赖的软件包名字,支持传多个;必传参数。
>
> -dbs 指定需要查询的database优先级,不传按照系统默认优先级搜索;可选参数。
>
@ -296,9 +329,9 @@ pkgshipd stop 停止服务
> -w指定-s表示引入某个二进制包的时候查询结果会显示出该二进制包对应的源码包以及该源码包生成的所有二进制包如果不指定-w参数表示引入某个二进制包的时候查询结果只显示对应的源码包可选参数。
7. 被依赖查询。
查询源码包(sourceName)在某数据库(dbName)中被哪些包所依赖。
查询软件包(pkgName)在某数据库(dbName)中被哪些包所依赖。
> 使用场景:针对软件源码包A在升级或删除的情况下会影响哪些软件包可通过该命令查询。该命令会显示源码包A生成的所有二进制包被哪些源码包比如B编译依赖被哪些二进制包比如C1安装依赖以及B生成的二进制包及C1被哪些源码包比如D编译依赖被哪些二进制包比如E1安装依赖以此类推遍历这些二进制包的被依赖。
> 使用场景针对软件包A在升级或删除的情况下会影响哪些软件包可通过该命令查询。该命令会显示源码包A(若为源码包)生成的所有二进制包(若输入为二进制包,那此处即为输入的二进制包)被哪些源码包比如B编译依赖被哪些二进制包比如C1安装依赖以及B生成的二进制包及C1被哪些源码包比如D编译依赖被哪些二进制包比如E1安装依赖以此类推遍历这些二进制包的被依赖。
```bash
pkgship bedepend dbName [$pkgName1 $pkgName2 $pkgName3] [-w] [-b] [-install/build]
@ -306,9 +339,11 @@ pkgshipd stop 停止服务
> 参数说明:
>
> dbName需要查询依赖关系的仓库不支持多个必选参数。
> dbName需要查询依赖关系的仓库不支持多个必选参数。
>
> -w :当不指定-w 时,查询结果默认不包含对应二进制包的子包;当命令后指定配置参数[-w] 时不仅会查询二进制包C1的被依赖关系还会进一步去查询C1对应的源码包C生成的其他二进制包比如C2,C3的被依赖关系可选参数。
> pkgName待查询的软件包名称支持多个必选参数。
>
> -w :当不指定-w 时,查询结果默认不包含对应源码包的子包;当命令后指定配置参数[-w] 时不仅会查询二进制包C1的被依赖关系还会进一步去查询C1对应的源码包C生成的其他二进制包比如C2,C3的被依赖关系可选参数。
>
> -b指定`-b`表示查询的包是二进制,默认查询源码包;可选参数。
>
@ -318,7 +353,7 @@ pkgshipd stop 停止服务
> 使用场景查看Elasticsearch中初始化了哪些数据库该功能会按照优先级顺序返回已经初始化的数据库列表。
`pkgship db`
`pkgship dbs`
9. 获取版本号。
@ -326,3 +361,99 @@ pkgshipd stop 停止服务
`pkgship -v`
10. 比较不同数据库的包信息的依赖关系。
查询输入数据库各自的所有源码包/二进制包信息,以及他们的一层编译依赖/安装依赖然后以第一个数据库包信息为基准对比各个数据库依赖信息的差异并记录到csv文件中。
> 使用场景:比较各个系统依赖关系的差异,分析软件包依赖关系优化点。
```shell
pkgship compare -t build/install -dbs [database1 database2..] [-o out_path]
```
> 参数说明:
>
> -t: 查询的依赖类型,目前只支持编译依赖-build和安装依赖-install。
>
> -dbs: 查询的数据库列表数据库之间用空格分隔。为了控制执行时间目前最多支持4个数据库对比时以第一个数据库的软件包作为对比基准包集合。
>
> -o: csv文件的保存路径。不填默认为/opt/pkgship/compare 需要指定时要确保执行用户pkgshipuser有写入权限。最后csv文件保存在“${out_path}/时间戳” 路径下。csv文件为各个数据库的包依赖关系信息以数据库名称命名以及所有数据库的包依赖关系对比信息compare.csv
## 日志查看和转储
**日志查看**
pkgship服务在运行时会产生两种日志业务日志和操作日志。
1、业务日志:
路径:/var/log/pkgship/log_info.log支持在conf.yaml中通过log_path字段自定义路径
功能:主要记录代码内部运行的日志,方便问题定位。
权限路径权限755日志文件权限644普通用户可以查看。
2、操作日志
路径:/var/log/pkgship-operation/uwsgi.log 支持在conf.yaml中通过daemonize字段自定义路径
功能记录使用者操作信息包括ip访问时间访问url访问结果等方便后续查阅以及记录攻击者信息。
权限路径权限700日志文件权限644只有root和pkgshipuser可以查看。
**日志转储**
1、业务日志转储
- 转储机制
使用python自带的logging内置函数的转储机制按照日志大小来备份。
> 配置项package.ini中配置每个日志的容量和备份数量
>
> ```ini
> ; Maximum capacity of each file, the unit is byte, default is 30M
> max_bytes=31457280
>
> ; Number of old logs to keep;default is 30
> backup_count=30
> ```
- 转储过程
当某次日志写入后日志文件大小超过配置的日志容量时会自动压缩转储压缩后文件名为log_info.log.x.gz x是数字数字越小为越新的备份。
当备份日志数量到达配置的备份数量之后,最早的备份日志会被删除掉,然后备份一个最新的压缩日志文件。
2、操作日志转储
- 转储机制
使用脚本进行转储按照时间转储每日转储一次共保留30天不支持自定义配置。
> 脚本位置:/etc/pkgship/uwsgi_logrotate.sh
- 转储过程
pkgship启动时转储脚本后台运行从启动时每隔1天进行转储压缩共保留30份压缩文件压缩文件名称为uwsgi.log-20201010x.zip x为压缩时的小时数。
pkgship停止后转储脚本停止不再进行转储再次启动时转储脚本重新执行。
## 扩展工具pkgship-panel
### 介绍
pkgship-panel旨在将软件包构建信息和维护信息集成到一起方便版本维护人员可以快速识别构建异常软件包并快速邮件通知相关责任人去解决保证构建工程稳定性提高IOS构建成功率。
### 架构
![输入图片说明](https://gitee.com/openeuler/pkgship/raw/master/doc/design/pkgimg/panel逻辑视图.png)
### 工具使用
由于工具数据源不可配置所以建议直接使用pkgship-panel官网地址https://pkgmanage.openeuler.org/Infomanagement

147
pkgship.spec Executable file → Normal file
View File

@ -1,44 +1,54 @@
Name: pkgship
Version: 2.2.0
Release: 9
Version: 3.0.0
Release: 1
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so on.
License: Mulan 2.0
URL: https://gitee.com/openeuler/pkgship
Source0: https://gitee.com/openeuler/pkgship-%{version}.tar.gz
Patch0001: 0001-bugfix-pkginfo.patch
Patch0002: 0002-fix-install-and-start-script-info.patch
Patch0003: 0003-bugfix-binary-name-mapping-source.patch
Patch0004: 0004-fix-depend-query.patch
Patch0005: 0005-update-validate-encoding-format.patch
Patch0006: 0006-update-copyright.patch
Patch0007: 0007-update-readme-about-docker.patch
Patch0008: 0008-fix-simplejson-question.patch
Patch0009: 0009-delete-terminal-fix-build-failed.patch
Source0: https://gitee.com/src-openeuler/pkgship-%{version}.tar.gz
BuildArch: noarch
BuildRequires: shadow python3-mock
BuildRequires: shadow python3-mock python3-lxml
BuildRequires: python3-flask-restful python3-flask python3 python3-pyyaml python3-redis
BuildRequires: python3-prettytable python3-requests python3-retrying python3-coverage
BuildRequires: python3-marshmallow python3-uWSGI python3-gevent python3-Flask-Limiter
BuildRequires: python3-elasticsearch python3-concurrent-log-handler
BuildRequires: python3-elasticsearch python3-concurrent-log-handler python3-pyrpm python3-aiohttp
Requires: shadow python3-mock
Requires: shadow python3-mock python3-lxml
Requires: python3-flask-restful python3-flask python3 python3-pyyaml python3-redis
Requires: python3-prettytable python3-requests python3-retrying python3-coverage
Requires: python3-marshmallow python3-uWSGI python3-gevent python3-Flask-Limiter
Requires: python3-elasticsearch python3-concurrent-log-handler
Requires: python3-elasticsearch python3-concurrent-log-handler python3-pyrpm python3-aiohttp
%description
Pkgship implements rpm package dependence ,maintainer, patch query and so no.
%package -n pkgship-tools
Summary: Package Validation Tool
Requires: pkgship
%description -n pkgship-tools
Packages automatically analyze dependencies, create containers,
perform compilation and installation operations, and perform simple functional verification
%package -n pkgship-panel
Summary: openEuler Data panel
BuildRequires: pkgship python3-APScheduler
Requires: pkgship python3-APScheduler
%description -n pkgship-panel
A Kanban board that can view package compilation status,
package maintenance information, and sig group information
%prep
%autosetup -n pkgship-%{version} -p1
%build
# pkgship build
pushd packageship
%py3_build
current_path=`pwd`
cd $current_path'/packageship'
## create version file
version_=%{version}
release_=%{release}
version_file=version.yaml
@ -49,76 +59,87 @@ touch $version_file
echo "create version.yaml successfully."
echo "Version: $version_" >> $version_file
echo "Release: $release_" >> $version_file
popd
# pkgship-panel build
pushd packageship_panel
%py3_build
popd
%install
# pkgship install
pushd packageship
%py3_install
popd
# pkgship-panel install
pushd packageship_panel
%py3_install
popd
# install pkgship-tools
mkdir -p %{buildroot}/opt/pkgship/tools/
cp -r pkgship-tools/* %{buildroot}/opt/pkgship/tools/
%check
# pkgship check
current_path=`pwd`
log_path=${current_path}/packageship/tmp/
sed -i '/^LOG_PATH/d' ./packageship/libs/conf/global_config.py
echo "LOG_PATH=r\"${log_path}\"" >> ./packageship/libs/conf/global_config.py
sed -i '/^LOG_PATH/d' ./packageship/packageship/libs/conf/global_config.py
echo "LOG_PATH=r\"${log_path}\"" >> ./packageship/packageship/libs/conf/global_config.py
sed -i "/owner=('pkgshipuser', 'pkgshipuser')/d" ./packageship/packageship/libs/log.py
%{__python3} test/coverage_count.py
%pre
# add user and group
user=pkgshipuser
group=pkgshipuser
# create group if not exists
egrep -w "^$group" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
groupadd $group
fi
# create user if not exists
egrep -w "^$user" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
useradd -g $group $user
fi
# create dir or file if not exists
function create_dir_file(){
if [ $3 = "d" ];then
if [ ! -d "$1" ];then
mkdir -p -m $2 $1
fi
elif [ $3 = "f" ];then
if [ -f $1 ];then
rm -rf $1
fi
touch $1
chmod $2 $1
fi
chown -R $user:$group $1
}
create_dir_file /opt/pkgship/ 750 d
create_dir_file /opt/pkgship/compare 755 d
create_dir_file /var/log/pkgship 755 d
create_dir_file /var/log/pkgship-operation 700 d
%post
%postun
groupadd $group 2>/dev/null
useradd -g $group $user 2>/dev/null
mkdir -p /opt/pkgship/ 750
chown -R $user:$group /opt/pkgship/
mkdir -p /opt/pkgship/compare 755
chown -R $user:$group /opt/pkgship/compare
mkdir -p /opt/pkgship/tools 755
chown -R $user:$group /opt/pkgship/tools
mkdir -p /var/log/pkgship 755
chown -R $user:$group /var/log/pkgship
mkdir -p /var/log/pkgship-operation 700
chown -R $user:$group /var/log/pkgship-operation
%files
%doc README.md
%attr(0755,pkgshipuser,pkgshipuser) %{python3_sitelib}/*
%attr(0755,pkgshipuser,pkgshipuser) %config %{_sysconfdir}/pkgship/*
%attr(0755,pkgshipuser,pkgshipuser) %{python3_sitelib}/packageship-*egg-info
%attr(0755,pkgshipuser,pkgshipuser) %{python3_sitelib}/packageship/*
%attr(0755,pkgshipuser,pkgshipuser) %{_bindir}/pkgshipd
%attr(0755,pkgshipuser,pkgshipuser) %{_bindir}/pkgship
%attr(0750,root,root) /etc/pkgship/auto_install_pkgship_requires.sh
%attr(0750,pkgshipuser,pkgshipuser) /etc/pkgship/uwsgi_logrotate.sh
%attr(0750,pkgshipuser,pkgshipuser) /etc/pkgship/timer_sync
%attr(0640,pkgshipuser,pkgshipuser) /etc/pkgship/package.ini
%attr(0644,pkgshipuser,pkgshipuser) /etc/pkgship/conf.yaml
%attr(0640,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship.service
%attr(0644,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship.service
# The file list of the package pkgship-tools
%files -n pkgship-tools
%attr(0755,root,root) /opt/pkgship/tools/*
# The file list of the package pkgship-panel
%files -n pkgship-panel
%attr(0755,pkgshipuser,pkgshipuser) %{python3_sitelib}/packageship_panel-*.egg-info
%attr(0755,pkgshipuser,pkgshipuser) %{python3_sitelib}/packageship_panel/*
%attr(0755,pkgshipuser,pkgshipuser) %{_bindir}/pkgship-paneld
%attr(0755,pkgshipuser,pkgshipuser) %{_bindir}/pkgship-panel
%attr(0644,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship-panel.service
%attr(0644,pkgshipuser,pkgshipuser) /etc/pkgship/timed_task.yaml
%attr(0755,pkgshipuser,pkgshipuser) /etc/pkgship/service-monitor.sh
%changelog
* Fri Feb 3 2023 liheavy <lihaiwei8@huawei.com> - 3.0.0-1
- add panel data synchronization
- Add dynamic version data update and search by multiple criteria
* Sun Jan 9 2022 Haiwei Li <lihaiwei8@huawei.com> - 2.2.0-9
- TerminalTable class Use the deprecated method of PrettyTable, resulting in compilation failure, delete the file.
@ -402,4 +423,4 @@ create_dir_file /var/log/pkgship-operation 700 d
- add macro to build cli bin when rpm install
* Sat Jun 6 2020 Feng Hu <solar.hu@foxmail.com> - 1.0-0
- init package
- init package