From b35611f5ffe654a1bc0b70acd97485e5c27375ab Mon Sep 17 00:00:00 2001 From: Ru Wang Date: Sat, 23 Sep 2023 20:03:34 +0800 Subject: [PATCH 1/2] fix GitHub actions build, fix GCC warnings, rm depend on boost python module Signed-off-by: Ru Wang --- .github/workflows/TCGstorageAPI-build.yml | 17 +++++++++-------- README.md | 18 ++++++++---------- TCGstorageAPI/tcgapi.py | 19 ++++++++++--------- pysed/TcgDrive.cpp | 2 +- pysed/TcgScanner.cpp | 4 ++-- requirements.txt | 3 +-- setup.py | 6 +++--- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.github/workflows/TCGstorageAPI-build.yml b/.github/workflows/TCGstorageAPI-build.yml index b05d0af..7855db6 100644 --- a/.github/workflows/TCGstorageAPI-build.yml +++ b/.github/workflows/TCGstorageAPI-build.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - develop pull_request: branches: - master @@ -12,13 +13,13 @@ jobs: build: name: TCGstorageAPI_build # This job runs on Linux - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout git submodules - run: git submodule update --init --recursive - - name: Install dependencies + run: git submodule update --init --recursive + - name: Install dependencies run: | sudo apt-get update sudo apt install python3 @@ -30,14 +31,14 @@ jobs: run: | sudo apt-get install python3-setuptools pip3 install --no-cache-dir -r requirements.txt - - name: Link gmake to make - run: sudo ln -s /usr/bin/make /usr/bin/gmake + - name: Link libboost_python3 to libboost_python38.so + run: sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python38.so /usr/lib/libboost_python3.so - name: Build opensea run: python3 setup.py opensea - name: Build TCGstorageAPI package run: python3 setup.py build - name: Run unit tests run: | - sudo cp -R build/lib.linux-x86_64-3.6/TCGstorageAPI /home/runner/work/TCGstorageAPI/TCGstorageAPI - export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages/ + sudo cp -R build/lib.linux-x86_64-3.8/TCGstorageAPI /home/runner/work/TCGstorageAPI/TCGstorageAPI + export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/site-packages/ python3 TCGstorageAPI/tcgapi_test.py diff --git a/README.md b/README.md index 85c38b4..77dba82 100644 --- a/README.md +++ b/README.md @@ -56,23 +56,21 @@ Note that cloning **_recursively_** is **_important_** as it clones all the nece Start by updating the package index: -`sudo yum update` +`sudo yum -y update` Install python3: -`sudo yum install python3` +`sudo yum -y install python3` Install gcc and g++: -`sudo yum -y install gcc` - -`sudo yum -y install gcc-c++` +`sudo yum -y install gcc gcc-c++` Install boost: -`sudo yum install epel-release` +`sudo yum -y install epel-release` -`sudo yum install boost-python36-devel.x86_64` +`sudo yum -y install boost-python36-devel` Install gnutls: @@ -83,13 +81,13 @@ Install python3-extensions: `sudo yum -y install python3-devel` Install rpm build package - - `sudo yum install rpm-build` + + `sudo yum -y install rpm-build` Change directory to tcgstorageapi and download the package dependencies: `pip3 install -r requirements.txt` - + ##### Ubuntu 18.04 Start by updating package index diff --git a/TCGstorageAPI/tcgapi.py b/TCGstorageAPI/tcgapi.py index d1b4c8d..859c655 100644 --- a/TCGstorageAPI/tcgapi.py +++ b/TCGstorageAPI/tcgapi.py @@ -22,18 +22,19 @@ #----------------------------------------------------------------------------- import sys -import logging -from . import pysed import struct -from . import pysedSupport -import warnings -from .pysedSupport import * -from . import tcgSupport -from .tcgSupport import locking_table as locking_table -from .tcgSupport import portlocking_table as portlocking_table -from .tcgSupport import c_tls_psk_table as c_tls_psk_table import io import os +import re +import warnings + +from . import pysed +from . import pysedSupport +from .pysedSupport import baseObjectIds +from . import tcgSupport +from .tcgSupport import locking_table +from .tcgSupport import portlocking_table +from .tcgSupport import c_tls_psk_table StatusCode = pysed.StatusCode diff --git a/pysed/TcgDrive.cpp b/pysed/TcgDrive.cpp index 5c5bd95..e8ec07d 100644 --- a/pysed/TcgDrive.cpp +++ b/pysed/TcgDrive.cpp @@ -449,7 +449,7 @@ void Session::dumpPacket(const char * desc, void * buf, size_t size) { void PacketHeaders::fill(Drive * const drive, Session * const session, uint32_t dataLength) { - memset(this, 0, sizeof(PacketHeaders)); + *this = {}; subPacket.length = dataLength; dataLength += sizeof(SubPacketHeader); if (dataLength % 4) diff --git a/pysed/TcgScanner.cpp b/pysed/TcgScanner.cpp index 3646283..b23e506 100644 --- a/pysed/TcgScanner.cpp +++ b/pysed/TcgScanner.cpp @@ -242,11 +242,11 @@ const char * Results::namedString(const uint64_t name) { PyObject* v = ob.ptr(); - + if (PyBytes_Check(v)) { //cout << "Object is PyBytes type\n"; char *pbuf = PyBytes_AsString(v); - Py_ssize_t len = PyBytes_Size(v); + //Py_ssize_t len = PyBytes_Size(v); //cout << "Value is '" << pbuf << "' length " << (long) len << "\n"; return pbuf; } diff --git a/requirements.txt b/requirements.txt index 1a59c94..52e4015 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ -boost cryptography==3.3.2 passlib==1.7.4 pycparser==2.20 -pyopenssl==20.0.1 \ No newline at end of file +pyopenssl==20.0.1 diff --git a/setup.py b/setup.py index f3725a7..0b6b10f 100644 --- a/setup.py +++ b/setup.py @@ -54,9 +54,9 @@ def finalize_options(self): """Abstract method that is required to be overwritten""" def run(self): print(" => Building OpenSea Static Libraries ...") - subprocess.call(['gmake', '-C', 'opensea-transport/Make/gcc']) - subprocess.call(['gmake', '-C', 'opensea-operations/Make/gcc']) - subprocess.call(['gmake', '-C', 'opensea-common/Make/gcc']) + subprocess.call(['make', '-C', 'opensea-transport/Make/gcc']) + subprocess.call(['make', '-C', 'opensea-operations/Make/gcc']) + subprocess.call(['make', '-C', 'opensea-common/Make/gcc']) pysed = Extension('TCGstorageAPI.pysed', [ 'pysed/pysed.cpp', From d6aae007048717d411e60b4eb0e1dc64e3ae3dd0 Mon Sep 17 00:00:00 2001 From: Ru Wang Date: Sun, 24 Sep 2023 15:24:32 +0800 Subject: [PATCH 2/2] fix large LBA returned in form of string lead to Seagate/TCGstorageAPI#37 Signed-off-by: Ru Wang --- sed_cli/sed_cli.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sed_cli/sed_cli.py b/sed_cli/sed_cli.py index 7d7d07a..3107eb6 100644 --- a/sed_cli/sed_cli.py +++ b/sed_cli/sed_cli.py @@ -38,7 +38,10 @@ from keymanager import keymanager_json def auto_int(x): - return int(x, 0) + try: + return int(x, 0) + except TypeError: # x may be just an int + return int(x) def str2bool(v): if isinstance(v, bool): @@ -698,9 +701,9 @@ def printBandInfo(self, bandNumber): info, rc = self.SED.getRange(bandNumber, user, auth) if bandNumber != 0: - print('Band{} RangeStart = 0x{:x}'.format(bandNumber, info.RangeStart)) - print('Band{} RangeEnd = 0x{:x}'.format(bandNumber, info.RangeStart + info.RangeLength)) - print('Band{} RangeLength = 0x{:x}'.format(bandNumber, info.RangeLength)) + print('Band{} RangeStart = 0x{:x}'.format(bandNumber, auto_int(info.RangeStart))) + print('Band{} RangeEnd = 0x{:x}'.format(bandNumber, auto_int(info.RangeStart) + auto_int(info.RangeLength))) + print('Band{} RangeLength = 0x{:x}'.format(bandNumber, auto_int(info.RangeLength))) print('Band{} ReadLocked = {}'.format(bandNumber, ('unlocked','locked')[info.ReadLocked])) print('Band{} WriteLocked = {}'.format(bandNumber, ('unlocked','locked')[info.WriteLocked])) print('Band{} LockOnReset = {}'.format(bandNumber, info.LockOnReset))