Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build F5 dashboard package #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions build_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

git checkout -- setup.cfg
rm -rf build dist *.egg *.egg-info
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As good practice in shell, we should not suppose the current running directory is just the directory where build_rpm.sh is.

We should use the following way to get the absolute path to build_rpm.sh.


cdir=`cd $(dirname $0); pwd`
(
cd $cdir
# you logic here. 
)

In that way, we can run build_rpm.sh anywhere, like ./build_rpm.sh works, /path/to/build_rpm.sh also can work..
I don't need to navigate to that folder to run the script..


# Build community source tarball

python setup.py sdist --formats=gztar

# Build F5 rpm spec

/bin/cp -f f5-setup.cfg setup.cfg

python setup.py bdist_rpm --spec-only \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if python setup.py run failed? we may need error handling.

--release=1 \
--provides=f5-neutron-lbaas-dashboard \
--packager="Qin Zhao <q.zhao@f5.com>" \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a common name instead of using personal?

--post-install=rpm_post_install.sh

# Repackage source tarball

cd dist
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ( ) to start a sub shell for the work.. changing directory in shell script is not convenient when we want to add more logic, we have to glance over the whole script to see where(which directory) I'm now.


VERSION=$(rpmspec -q --qf "%{version}" f5-neutron-lbaas-dashboard.spec)

OLD=neutron-lbaas-dashboard-${VERSION}
NEW=f5-neutron-lbaas-dashboard-${VERSION}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using f5-openstack-dashboard, as we talked, the installed package name.


tar -zxf ${OLD}.tar.gz

mv ${OLD} ${NEW}

cd ${NEW}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this too.
wrap the logic into ():

(
cd $cdir
echo logic..
)


/bin/cp -f f5-setup.cfg setup.cfg

mv neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py neutron_lbaas_dashboard/enabled/_1491_project_ng_loadbalancersv2_panel.py

mv neutron_lbaas_dashboard f5_neutron_lbaas_dashboard

rm -rf neutron_lbaas_dashboard.egg-info

cp -rp ../../f5_neutron_lbaas_dashboard.egg-info ./
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the benefits for using absolute path in script is when we need to debug the script with 'sh -x', it's very easy to navigate to each (called) file. Relative path is not so clear where and where.. also not convenient to debug..


sed -i "s/^neutron_lbaas_dashboard/f5_neutron_lbaas_dashboard/g" f5_neutron_lbaas_dashboard.egg-info/SOURCES.txt

sed -i "s/_1481_project_ng_loadbalancersv2_panel.py/_1491_project_ng_loadbalancersv2_panel.py" f5_neutron_lbaas_dashboard.egg-info/SOURCES.txt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about remove the empty lines and group them together..


/bin/cp -f f5_neutron_lbaas_dashboard.egg-info/PKG-INFO ./

/bin/cp -f f5_neutron_lbaas_dashboard.egg-info/SOURCES.txt ./

find f5_neutron_lbaas_dashboard -type f -exec sed -i "s/neutron_lbaas_dashboard/f5_neutron_lbaas_dashboard/g" {} \;

cd ..

tar -cf ${NEW}.tar ${NEW}
gzip ${NEW}.tar

# Build F5 rpm

cp ${NEW}.tar.gz ~/rpmbuild/SOURCES

rpmbuild -bb f5-neutron-lbaas-dashboard.spec

cp ~/rpmbuild/RPMS/noarch/${NEW}*.rpm ./

cd ..
47 changes: 47 additions & 0 deletions f5-setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[metadata]
name = f5-neutron-lbaas-dashboard
summary = F5 Horizon panels for Neutron LBaaS
description-file =
README.rst
author = F5 Networks
author-email = info@f5.com
home-page = https://github.com/F5Networks/neutron-lbaas-dashboard/
license = Apache License 2.0
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7

[files]
packages =
f5_neutron_lbaas_dashboard

[build_sphinx]
source-dir = doc/source
build-dir = doc/build
all_files = 1

[upload_sphinx]
upload-dir = doc/build/html

[pbr]
autodoc_tree_index_modules = False
autodoc_tree_excludes =
setup.py
f5_neutron_lbaas_dashboard/tests
f5_neutron_lbaas_dashboard/enabled
f5_neutron_lbaas_dashboard/locale
f5_neutron_lbaas_dashboard/static
f5_neutron_lbaas_dashboard/post_install.sh
f5_neutron_lbaas_dashboard/karma.conf.js
autodoc_index_modules = False
warnerrors = True
autodoc_exclude_modules =
f5_neutron_lbaas_dashboard.tests.*
f5_neutron_lbaas_dashboard.enabled.*
api_doc_dir = contributor/modules
3 changes: 3 additions & 0 deletions rpm_post_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkdir -p /usr/share/openstack-dashboard/openstack_dashboard/local/enabled/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report error and prompt user the installation failed (exit 1) when /usr/share/openstack-dashboard not exists(openstack-dashboard is not installed yet.).
mkdir and put f5-xxxxx there is useless, cannot run either.

cd /usr/lib/python2.7/site-packages
install -p -D -m 644 f5_neutron_lbaas_dashboard/enabled/_1491_project* /usr/share/openstack-dashboard/openstack_dashboard/local/enabled/