[fuel-plugin-builder] execution of pre_build_hook depends on current directory

Bug #1578598 reported by Vasiliy Pleshakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Medium
Georgy Kibardin

Bug Description

Detailed bug description:
fpb executes pre_build_hook from current directory. In case pre_build_hook depends on files in root directory of plugin fpb fails with error "Shell command executed with "127" exit code: lcm-plugin/pre_build_hook".
Steps to reproduce:
1. create simle plugin from examples
2. create script prebuildhook.sh in root directory of plugin with any code
3. create pre_build_hook file with next lines:
#!/bin/bash
./prebuildhook.sh
4. cd to your home dir
5. fpb --build plugin_dir
Expected results:
 fpb build plugin successfully.
Actual result:
fpb fails with next error:
"Shell command executed with "127" exit code: lcm-plugin/pre_build_hook"
Reproducibility:
always
Workaround:
do not use relative paths in pre_build_hook script. Do 'popd && cd basename $0' at start of pre_build_hook and pushd at the end.
Impact:
Description of the environment:
 Operation system: Centos 7 with fpb installed from master branch of fuel-plugins repo.
 Versions of components: latest fpb installed from master branch of fuel-plugins repo.
 Reference architecture: N/A
 Network model: N/A
 Related projects installed: N/A
Additional information:

I suggest a simple fix :

--- a/fuel_plugin_builder/actions/build.py
+++ b/fuel_plugin_builder/actions/build.py
@@ -79,7 +79,7 @@ class BaseBuildPlugin(BaseAction):

     def run_pre_build_hook(self):
         if utils.which(self.pre_build_hook_path):
- utils.exec_cmd(self.pre_build_hook_path)
+ utils.exec_cmd(self.pre_build_hook_path, self.plugin_path)

     def add_checksums_file(self):
         utils.create_checksums_file(self.build_src_dir, self.checksums_path)

Tags: area-python
Changed in fuel:
milestone: none → 10.0
assignee: nobody → Fuel Sustaining (fuel-sustaining-team)
importance: Undecided → Medium
status: New → Triaged
tags: added: area-python
Changed in fuel:
assignee: Fuel Sustaining (fuel-sustaining-team) → Georgy Kibardin (gkibardin)
Changed in fuel:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-plugins (master)

Fix proposed to branch: master
Review: https://review.openstack.org/335395

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-plugins (master)

Reviewed: https://review.openstack.org/335395
Committed: https://git.openstack.org/cgit/openstack/fuel-plugins/commit/?id=abfe5501b24d39b90cebb66e4739d196807a58d2
Submitter: Jenkins
Branch: master

commit abfe5501b24d39b90cebb66e4739d196807a58d2
Author: Georgy Kibardin <email address hidden>
Date: Wed Jun 29 12:20:05 2016 +0300

    Execute prebuild_hook in the plugin directory

    Set current working directory to the plugin directory before executing
    prebuild hook. This allows prebuild hook script to refer to other
    scripts in plugin directory using relative path.

    Change-Id: I86193b26e5bd55ea55a712e473c2bbb3b36918fd
    Closes-Bug: #1578598

Changed in fuel:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.