Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
EOS-24934: package validation restored in post_install phases
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Tripathi <[email protected]>
  • Loading branch information
rahul-tripathi-git committed Sep 16, 2021
1 parent b28fb9f commit 86d86d5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
54 changes: 27 additions & 27 deletions jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,35 @@ sed -i -e "s|<INSTALL_PATH>|${INSTALL_PATH}|g" utils-post-install
echo "Creating cortx-py-utils RPM with version $VER, release $REL"

# Create the utils-pre-install
## echo "#!/bin/bash" > utils-pre-install
## echo "" >> utils-pre-install
## echo "PACKAGE_LIST=\"" >> utils-pre-install
## /bin/cat python_requirements.txt >> utils-pre-install
## if [ -f "python_requirements.ext.txt" ]; then
## /bin/cat python_requirements.ext.txt >> utils-pre-install
## fi
## echo "\"" >> utils-pre-install
## echo "rc=0
## for package in \$PACKAGE_LIST
## do
## pip3 freeze | grep \$package > /dev/null
## if [ \$? -ne 0 ]; then
## if [ \$rc -eq 0 ]; then
## echo \"===============================================\"
## fi
## echo \"Required python package \$package is missing\"
## rc=-1
## fi
## done
## if [ \$rc -ne 0 ]; then
## echo \"Please install above python packages\"
## echo \"===============================================\"
## fi
## exit \$rc " >> utils-pre-install
## /bin/chmod +x utils-pre-install
echo "#!/bin/bash" > utils-pre-install
echo "" >> utils-pre-install
echo "PACKAGE_LIST=\"" >> utils-pre-install
/bin/cat python_requirements.txt >> utils-pre-install
if [ -f "python_requirements.ext.txt" ]; then
/bin/cat python_requirements.ext.txt >> utils-pre-install
fi
echo "\"" >> utils-pre-install
echo "rc=0
for package in \$PACKAGE_LIST
do
pip3 freeze | grep \$package > /dev/null
if [ \$? -ne 0 ]; then
if [ \$rc -eq 0 ]; then
echo \"===============================================\"
fi
echo \"Required python package \$package is missing\"
rc=-1
fi
done
if [ \$rc -ne 0 ]; then
echo \"Please install above python packages\"
echo \"===============================================\"
fi
exit \$rc " >> utils-pre-install
/bin/chmod +x utils-pre-install

# Create the rpm
/bin/python3.6 setup.py bdist_rpm --release="$REL" \
/bin/python3.6 setup.py bdist_rpm --release="$REL" --pre-install utils-pre-install\
--post-install utils-post-install --post-uninstall utils-post-uninstall
if [ $? -ne 0 ]; then
echo "build failed"
Expand Down
30 changes: 15 additions & 15 deletions py-utils/src/setup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ def post_install():
## 'kafka.service'])

# Check required python packages
## utils_path = Utils._get_utils_path()
## with open(f"{utils_path}/conf/python_requirements.txt") as file:
## req_pack = []
## for package in file.readlines():
## pack = package.strip().split('==')
## req_pack.append(f"{pack[0]} ({pack[1]})")
## try:
## with open(f"{utils_path}/conf/python_requirements.ext.txt") as extfile :
## for package in extfile.readlines():
## pack = package.strip().split('==')
## req_pack.append(f"{pack[0]} ({pack[1]})")
## except Exception:
## Log.info("Not found: "+f"{utils_path}/conf/python_requirements.ext.txt")

## PkgV().validate(v_type='pip3s', args=req_pack)
utils_path = Utils._get_utils_path()
with open(f"{utils_path}/conf/python_requirements.txt") as file:
req_pack = []
for package in file.readlines():
pack = package.strip().split('==')
req_pack.append(f"{pack[0]} ({pack[1]})")
try:
with open(f"{utils_path}/conf/python_requirements.ext.txt") as extfile :
for package in extfile.readlines():
pack = package.strip().split('==')
req_pack.append(f"{pack[0]} ({pack[1]})")
except Exception:
Log.info("Not found: "+f"{utils_path}/conf/python_requirements.ext.txt")

PkgV().validate(v_type='pip3s', args=req_pack)
return 0

@staticmethod
Expand Down

0 comments on commit 86d86d5

Please sign in to comment.