From beadfcd62796beff0c8e186b4c49c0b0eb9c26cb Mon Sep 17 00:00:00 2001 From: xq2005 Date: Sun, 7 Apr 2013 08:41:35 +0000 Subject: [PATCH] buildkit support on debian/ubuntu git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15849 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-buildkit/bin/buildkit | 67 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/xCAT-buildkit/bin/buildkit b/xCAT-buildkit/bin/buildkit index 20318323d..30e6f5d51 100755 --- a/xCAT-buildkit/bin/buildkit +++ b/xCAT-buildkit/bin/buildkit @@ -2087,7 +2087,18 @@ sub build_kitcomp_debian{ my $comp = shift; my %repo; my $debbuilddir = $::workdir."/debbuild/".$comp->{kitcompname}; + my $kcmetaname = comppkgname($comp); + #If this kitcomponent has external non-native pkgs, + #skip the meta package build + if ( defined($::NON_NATIVE_PKGS) && + defined($::NON_NATIVE_PKGS->{$comp->{kitcompname}}) && + $::NON_NATIVE_PKGS->{$comp->{kitcompname}} ) { + if ($::VERBOSE) { + print "Kit component $comp->{kitcompname} has external non-native packages. Skipping rpm build for $kcmetaname. \n"; + } + return 0; + } # find the kitrepo hash for this component foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}}) { if ($comp->{kitrepoid} eq $kr->{kitrepoid}) { @@ -2105,19 +2116,14 @@ sub build_kitcomp_debian{ #Create debian directory for this kit component if ( &gen_kitcomp_debdir($comp,\%repo) ) { return 1; } - my $kcmetaname = comppkgname($comp); - if (defined($comp->{non_native_pkgs}) ) { my $sourcedir = $::workdir."/source_packages"; - if ($comp->{non_native_pkgs} =~ /EXTERNALPKGS/) { - $::NON_NATIVE_PKGS->{$comp->{kitcompname}} = 1; - } foreach my $pkgfile (split(/,/, $comp->{non_native_pkgs})) { my $pkg_file; my ($key,$value) = split /:/,$pkgfile; if ("$key" =~ /EXTERNALPKGS/) { - next; + $pkg_file = $value; } else { $pkg_file = $key; } @@ -2425,7 +2431,13 @@ sub create_kitconf my @lines; my $li=0; $lines[$li++] = "# Kit Configuration File for $kitname generated by buildkit\n"; - my $xCAT_buildkit_version = `rpm -q --qf \"%{VERSION}-%{RELEASE}\" xCAT-buildkit`; + my $xCAT_buildkit_version = ''; + if ( $debianflag ){ + $xCAT_buildkit_version = `dpkg-query --show -f='\${Version}' xcat-buildkit`; + } + else{ + $xCAT_buildkit_version = `rpm -q --qf \"%{VERSION}-%{RELEASE}\" xCAT-buildkit`; + } $lines[$li++] = "# kit_built_by_xCAT_version: $xCAT_buildkit_version \n"; $lines[$li++] = "# kit_built_on: ".localtime()."\n"; foreach my $s ('kit','kitrepo','kitcomponent','EXTERNALPKG', 'NONNATIVEPKGS') { @@ -2620,11 +2632,6 @@ sub create_builddir print "Error copying buildkit config file $::full_buildkit_conf to build directory $::deploy_dir/build_input \n"; return 1; } - if ( system("cp -fpR $::full_buildkit_conf $::deploy_dir/build_input") ) { - # non-zero return from system call - print "Error copying buildkit config file $::full_buildkit_conf to build directory $::deploy_dir/build_input \n"; - return 1; - } } return 0; @@ -2664,24 +2671,6 @@ sub create_PARTIAL_builddir } } - # Copy the kitcomponent meta rpm spec if there is external non_native_pkgs. - if ( $debianflag ) { - foreach my $comp (keys %{$::NON_NATIVE_PKGS}) { - my $kitrepo; - foreach my $kc (@{$::bldkit_config->{kitcomponent}{entries}}) { - if ($comp eq $kc->{kitcompname}) { - $kitrepo = $kc->{kitreponame} - } - } - mkpath("$::deploy_dir/tmp/"); - my $cmd = "cp -fRP $::workdir/debbuild/$comp $::deploy_dir/tmp/$comp"; - if ( system("$cmd") ) { - print "Error copying kitcomponent meta debian build file $::workdir/debbuild/$comp to build directory $::deploy_dir \n"; - return 1; - } - } - } - # Copy over the original buildkit.conf file and input files # to help make addpkgs processing easier later mkpath("$::deploy_dir/build_input/"); @@ -3336,7 +3325,14 @@ sub NEW_kit_addpkgs $::HAVE_NON_NATIVE_PKGS = ''; $::NON_NATIVE_PKGS = {}; foreach my $kc (@{$::bldkit_config->{kitcomponent}{entries}}) { - if (&build_kitcomp($kc )) { + my $rc=0; + if ( $debianflag ){ + $rc = &build_kitcomp_debian($kc); + } + else{ + $rc = &build_kitcomp($kc); + } + if ( $rc ) { print "Error building kitcomponent metapackage for $kc->{basename} \n"; return 1; } @@ -3350,7 +3346,14 @@ sub NEW_kit_addpkgs ( $kr->{osmajorversion} eq '5') ) { $cr_opts = '-s md5'; } - if ( system("createrepo $cr_opts $repodir") ) { + my $repocmd = ""; + if ( $debianflag ){ + $repocmd = "cd $repodir;dpkg-scanpackages . > Packages"; + } + else{ + $repocmd = "createrepo $cr_opts $repodir"; + } + if ( system( $repocmd ) ) { print "Error building the repository meta-data with the createrepo command \n"; return 1; }