Skip to content

Commit

Permalink
Fix scripts failing to produce results with newly created user (#29)
Browse files Browse the repository at this point in the history
* Do not limit package choices in argument parser

The available packages are only discovered after running the complete build
for the first time. This prevented any packages from being built alone in the
first run, which is not desired.

* Make the path to mock binary explicit

If the binary were searched in the user PATH, the binary in /usr/sbin could be
used instead, requiring the user to have root privilege.
  • Loading branch information
Olav Philipp Henschel authored Aug 31, 2016
1 parent e6858b3 commit 36ac27e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def _parse_arguments(self):
parser.add_argument('--packages', '-p',
help='Packages to be built',
nargs='*',
choices=supported_software,
default=supported_software)
parser.add_argument('--log-file', '-l',
help='Log file',
Expand Down
17 changes: 10 additions & 7 deletions lib/mockbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CONF = config.get_config().CONF
LOG = logging.getLogger(__name__)
MOCK_CHROOT_BUILD_DIR = "/builddir/build/SOURCES"
MOCK_BIN = "/usr/bin/mock"


class Mock(build_system.PackageBuilder):
Expand All @@ -41,8 +42,9 @@ def build(self, package):
self._prepare(package)
self._build_srpm(package)
self._install_external_dependencies(package)
cmd = "mock -r %s --rebuild %s --no-clean --resultdir=%s" % (
self.mock_config, self.build_dir + "/*.rpm", self.build_dir)
cmd = "%s -r %s --rebuild %s --no-clean --resultdir=%s" % (
MOCK_BIN, self.mock_config, self.build_dir + "/*.rpm",
self.build_dir)

if package.rpmmacro:
cmd = cmd + " --macro-file=%s" % package.rpmmacro
Expand All @@ -67,8 +69,9 @@ def build(self, package):

def _build_srpm(self, package):
print("%s: Building SRPM" % package.name)
cmd = ("mock -r %s --buildsrpm --no-clean --spec %s --source %s "
"--resultdir=%s" % (self.mock_config,
cmd = ("%s -r %s --buildsrpm --no-clean --spec %s --source %s "
"--resultdir=%s" % (MOCK_BIN,
self.mock_config,
package.specfile,
self.archive,
self.build_dir))
Expand All @@ -90,7 +93,7 @@ def _prepare_archive(self, package):
self.archive = package._download_source(self.build_dir)

def _prepare_chroot(self, package):
cmd = "mock --init -r %s " % self.mock_config
cmd = "%s --init -r %s " % (MOCK_BIN, self.mock_config)

if package.build_files:
files = []
Expand All @@ -102,10 +105,10 @@ def _prepare_chroot(self, package):
utils.run_command(cmd)

def clean(self):
utils.run_command("mock --clean")
utils.run_command("%s --clean" % MOCK_BIN)

def _install_external_dependencies(self, package):
cmd = "mock -r %s " % self.mock_config
cmd = "%s -r %s " % (MOCK_BIN, self.mock_config)
if package.build_dependencies or package.dependencies:
install = " --install"
for dep in package.build_dependencies:
Expand Down

0 comments on commit 36ac27e

Please sign in to comment.