Skip to content

Commit

Permalink
Add getbuildids helper to spped up pkg querying
Browse files Browse the repository at this point in the history
Makes "keeping" and "cummulating" packages much faster.
  • Loading branch information
mlschroe committed Nov 24, 2016
1 parent 2fdc73a commit 4b70d87
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ install:
computeblocklists \
extractbuild \
getbinaryid \
getbuildids \
killchroot \
queryconfig \
common_functions \
Expand Down
40 changes: 40 additions & 0 deletions getbuildids
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/perl -w

################################################################
#
# Copyright (c) 2016 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################

BEGIN {
unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
}

use Build;
use strict;

while (<STDIN>) {
chomp;
my $pkg = $_;
my $d = Build::query($pkg, 'evra' => 1, 'buildtime' => 1);
next unless $d;
my $buildid = Build::getbuildid($d);
next unless $buildid;
open(F, '>', "$pkg.buildid") || next;
print F "$buildid\n";
close(F);
}
14 changes: 13 additions & 1 deletion init_buildsystem
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,14 @@ if ! test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
echo 'done'
fi

echo -n "querying package ids..."
for PKG in $PACKAGES_TO_INSTALL ; do
test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue
test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue
echo "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"
done | "$BUILD_DIR/getbuildids"
echo 'done'

#
# get list and ids of already installed packages
#
Expand Down Expand Up @@ -948,7 +956,11 @@ for PKG in $MAIN_LIST ; do
fi
fi

PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid)
if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF.buildid" ; then
read PKGID < "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF.buildid"
else
PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid)
fi

if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
Expand Down

0 comments on commit 4b70d87

Please sign in to comment.