Hello community, here is the log from the commit of package build for openSUSE:Factory checked in at 2018-04-06 17:41:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/build (Old) and /work/SRC/openSUSE:Factory/.build.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "build" Fri Apr 6 17:41:04 2018 rev:114 rq:593183 version:20180329 Changes: -------- --- /work/SRC/openSUSE:Factory/build/build.changes 2018-02-14 09:17:26.918300139 +0100 +++ /work/SRC/openSUSE:Factory/.build.new/build.changes 2018-04-06 17:41:08.745698941 +0200 @@ -1,0 +2,10 @@ +Tue Apr 3 11:30:47 UTC 2018 - [email protected] + +- KIWI: Support OBS-Profiles kiwi annotation + kiwi profile filtering +- Switch to a little perl http server to get rid of the python2 dependency +- Avoid Ubuntu 18.04 uncompress failure messages +- Don't rely on AppImage's auto-detection for architecture +- build-recipe-livebuild: count ONIE images as build results + +------------------------------------------------------------------- Old: ---- obs-build-20180209.tar.gz New: ---- obs-build-20180329.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ build.spec ++++++ --- /var/tmp/diff_new_pack.99hJQo/_old 2018-04-06 17:41:16.501418827 +0200 +++ /var/tmp/diff_new_pack.99hJQo/_new 2018-04-06 17:41:16.501418827 +0200 @@ -20,9 +20,9 @@ Name: build Summary: A Script to Build SUSE Linux RPMs -License: GPL-2.0+ and GPL-2.0 +License: GPL-2.0-or-later AND GPL-2.0-only Group: Development/Tools/Building -Version: 20180209 +Version: 20180329 Release: 0 Source: obs-build-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -53,6 +53,7 @@ Recommends: perl(YAML::LibYAML) Recommends: bsdtar Recommends: qemu-linux-user +Recommends: /sbin/mkfs.ext3 %endif %if 0%{?suse_version} > 1120 || ! 0%{?suse_version} ++++++ PKGBUILD ++++++ --- /var/tmp/diff_new_pack.99hJQo/_old 2018-04-06 17:41:16.541417382 +0200 +++ /var/tmp/diff_new_pack.99hJQo/_new 2018-04-06 17:41:16.545417238 +0200 @@ -1,5 +1,5 @@ pkgname=build -pkgver=20180209 +pkgver=20180329 pkgrel=0 pkgdesc="Build packages in sandbox" arch=('i686' 'x86_64') ++++++ build.dsc ++++++ --- /var/tmp/diff_new_pack.99hJQo/_old 2018-04-06 17:41:16.581415938 +0200 +++ /var/tmp/diff_new_pack.99hJQo/_new 2018-04-06 17:41:16.585415793 +0200 @@ -1,6 +1,6 @@ Format: 1.0 Source: build -Version: 20180209 +Version: 20180329 Binary: build Maintainer: Adrian Schroeter <[email protected]> Architecture: all ++++++ debian.changelog ++++++ --- /var/tmp/diff_new_pack.99hJQo/_old 2018-04-06 17:41:16.613414782 +0200 +++ /var/tmp/diff_new_pack.99hJQo/_new 2018-04-06 17:41:16.613414782 +0200 @@ -1,4 +1,4 @@ -build (20180209) unstable; urgency=low +build (20180329) unstable; urgency=low * Update to current git trunk - add sles11sp2 build config and adapt autodetection ++++++ obs-build-20180209.tar.gz -> obs-build-20180329.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/Build/Deb.pm new/obs-build-20180329/Build/Deb.pm --- old/obs-build-20180209/Build/Deb.pm 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/Build/Deb.pm 2018-03-29 17:01:40.000000000 +0200 @@ -186,18 +186,22 @@ local (*TMP, *TMP2); open(TMP, "+>", undef) or die("could not open tmpfile\n"); syswrite TMP, $data; - sysseek(TMP, 0, 0); my $pid = open(TMP2, "-|"); die("fork: $!\n") unless defined $pid; if (!$pid) { open(STDIN, "<&TMP"); + seek(STDIN, 0, 0); # these two lines are a workaround for a perl bug mixing up FD + sysseek(STDIN, 0, 0); exec($tool); die("$tool: $!\n"); } close(TMP); $data = ''; 1 while sysread(TMP2, $data, 1024, length($data)) > 0; - close(TMP2) || die("$tool error\n"); + if (!close(TMP2)) { + warn("$tool error: $?\n"); + return undef; + } return $data; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/Build/Docker.pm new/obs-build-20180329/Build/Docker.pm --- old/obs-build-20180209/Build/Docker.pm 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/Build/Docker.pm 2018-03-29 17:01:40.000000000 +0200 @@ -39,7 +39,7 @@ if ($q ne "'" && $str =~ /\$/) { $str =~ s/\$([a-zA-Z0-9_]+|\{([^\}]+)\})/join(' ', @{$vars->{$2 || $1} || []})/ge; } - $str =~ s/([ \t\"\'\$])/sprintf("%%%02X", ord($1))/ge; + $str =~ s/([ \t\"\'\$\(\)])/sprintf("%%%02X", ord($1))/ge; return $str; } @@ -180,7 +180,7 @@ } } elsif ($cmd eq 'RUN') { $line =~ s/#.*//; # get rid of comments - for my $l (split(/(?:\||\|\||\&|\&\&|;)/, $line)) { + for my $l (split(/(?:\||\|\||\&|\&\&|;|\)|\()/, $line)) { $l =~ s/^\s+//; $l =~ s/\s+$//; @args = split(/[ \t]+/, $l); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/Build/Kiwi.pm new/obs-build-20180329/Build/Kiwi.pm --- old/obs-build-20180209/Build/Kiwi.pm 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/Build/Kiwi.pm 2018-03-29 17:01:40.000000000 +0200 @@ -55,7 +55,7 @@ } sub kiwiparse { - my ($xml, $arch, $count) = @_; + my ($xml, $arch, $count, $buildflavor) = @_; $count ||= 0; die("kiwi config inclusion depth limit reached\n") if $count++ > 10; @@ -73,8 +73,13 @@ my $schemaversion56 = versionstring('5.6'); my $obsexclusivearch; my $obsexcludearch; + my $obsprofiles; $obsexclusivearch = $1 if $xml =~ /^\s*<!--\s+OBS-ExclusiveArch:\s+(.*)\s+-->\s*$/im; $obsexcludearch = $1 if $xml =~ /^\s*<!--\s+OBS-ExcludeArch:\s+(.*)\s+-->\s*$/im; + $obsprofiles = $1 if $xml =~ /^\s*<!--\s+OBS-Profiles:\s+(.*)\s+-->\s*$/im; + if ($obsprofiles) { + $obsprofiles = [ grep {defined($_)} map {$_ eq '@BUILD_FLAVOR@' ? $buildflavor : $_} split(' ', $obsprofiles) ]; + } my $kiwi = Build::SimpleXML::parse($xml); die("not a kiwi config\n") unless $kiwi && $kiwi->{'image'}; $kiwi = $kiwi->{'image'}->[0]; @@ -85,6 +90,32 @@ if (!$ret->{'name'} && $description->{'specification'}) { $ret->{'name'} = $description->{'specification'}->[0]->{'_content'}; } + + # do obsprofiles arch filtering + if ($obsprofiles && $arch && $kiwi->{'profiles'} && $kiwi->{'profiles'}->[0]->{'profile'}) { + my %obsprofiles = map {$_ => 1} @$obsprofiles; + for my $prof (@{$kiwi->{'profiles'}[0]->{'profile'}}) { + next unless $prof->{'name'} && exists $obsprofiles{$prof->{'name'}}; + my $valid; + if ($prof->{'arch'}) { + my $ma = $arch; + $ma =~ s/i[456]86/i386/; + for my $pa (split(",", $prof->{'arch'})) { + $pa =~ s/i[456]86/i386/; + $valid = 1 if $ma eq $pa; + } + } else { + $valid = 1; + } + if ($valid) { + $obsprofiles{$prof->{'name'}} = 2; + } elsif ($obsprofiles{$prof->{'name'}} == 1) { + $obsprofiles{$prof->{'name'}} = 0; + } + } + $obsprofiles = [ grep {$obsprofiles{$_}} @$obsprofiles ]; + } + # take default version setting my $preferences = ($kiwi->{'preferences'} || []); if ($preferences->[0]->{'version'}) { @@ -92,6 +123,10 @@ } my $containerconfig; for my $pref (@{$preferences || []}) { + if ($obsprofiles && $pref->{'profiles'}) { + my %obsprofiles = map {$_ => 1} @$obsprofiles; + next unless grep {$obsprofiles{$_}} split(",", $pref->{'profiles'}); + } for my $type (@{$pref->{'type'} || []}) { next unless @{$pref->{'type'}} == 1 || !$type->{'optional'}; if (defined $type->{'image'}) { @@ -137,7 +172,7 @@ my ($bootxml, $xsrc) = $bootcallback->($1, $2); next unless $bootxml; push @extrasources, $xsrc if $xsrc; - my $bret = kiwiparse($bootxml, $arch, $count); + my $bret = kiwiparse($bootxml, $arch, $count, $buildflavor); push @bootrepos, map {"$_->{'project'}/$_->{'repository'}"} @{$bret->{'path'} || []}; push @packages, @{$bret->{'deps'} || []}; push @extrasources, @{$bret->{'extrasource'} || []}; @@ -233,6 +268,15 @@ my $patterntype; for my $packages (@{$kiwi->{'packages'}}) { next if $packages->{'type'} && $packages->{'type'} ne 'image' && $packages->{'type'} ne 'bootstrap'; + # we could skip the sections also when no profile is used, + # but don't to stay backward compatible + if ($obsprofiles && $packages->{'profiles'}) { + my %obsprofiles = map {$_ => 1} @$obsprofiles; + my @section_profiles = split(",", $packages->{'profiles'}); + + next unless grep {$obsprofiles{$_}} @section_profiles; + } + $patterntype ||= $packages->{'patternType'}; push @pkgs, @{$packages->{'package'}} if $packages->{'package'}; for my $pattern (@{$kiwi->{'namedCollection'} || []}) { @@ -349,6 +393,13 @@ $containertags = [ "$containername:latest" ] if defined($containername) && !$containertags; $ret->{'container_tags'} = $containertags if $containertags; } + if ($obsprofiles) { + if (@$obsprofiles) { + $ret->{'profiles'} = [ unify(@$obsprofiles) ]; + } else { + $ret->{'exclarch'} = []; # all profiles excluded + } + } return $ret; } @@ -363,7 +414,7 @@ $cf ||= {}; my $d; eval { - $d = kiwiparse($xml, ($cf->{'arch'} || '')); + $d = kiwiparse($xml, ($cf->{'arch'} || ''), 0, $cf->{'buildflavor'}); }; if ($@) { my $err = $@; @@ -374,11 +425,16 @@ } sub show { - my ($fn, $field, $arch) = @ARGV; + my ($fn, $field, $arch, $buildflavor) = @ARGV; local $urlmapper = sub { return $_[0] }; my $cf = {'arch' => $arch}; + $cf->{'buildflavor'} = $buildflavor if defined $buildflavor; my $d = parse($cf, $fn); die("$d->{'error'}\n") if $d->{'error'}; + if ($field eq 'profiles' && $d->{'exclarch'} && !@{$d->{'exclarch'}}) { + print "__excluded\n"; + return; + } my $x = $d->{$field}; $x = [ $x ] unless ref $x; print "@$x\n"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/Makefile new/obs-build-20180329/Makefile --- old/obs-build-20180209/Makefile 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/Makefile 2018-03-29 17:01:40.000000000 +0200 @@ -73,6 +73,7 @@ build-validate-params \ openstack-console \ startdockerd \ + dummyhttpserver \ obs-docker-support \ $(DESTDIR)$(pkglibdir) install -m755 emulator/emulator.sh $(DESTDIR)$(pkglibdir)/emulator/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/build-recipe-appimage new/obs-build-20180329/build-recipe-appimage --- old/obs-build-20180209/build-recipe-appimage 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/build-recipe-appimage 2018-03-29 17:01:40.000000000 +0200 @@ -91,7 +91,7 @@ release_option="--release $RELEASE" fi - chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && /usr/lib/appimagetool/pkg2appimage $release_option" - root \ + chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && ARCH=$ARCH /usr/lib/appimagetool/pkg2appimage $release_option" - root \ || cleanup_and_exit 1 # extract build result basenames diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/build-recipe-kiwi new/obs-build-20180329/build-recipe-kiwi --- old/obs-build-20180209/build-recipe-kiwi 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/build-recipe-kiwi 2018-03-29 17:01:40.000000000 +0200 @@ -373,7 +373,6 @@ # XXX: again? chroot "$BUILD_ROOT" chown -R abuild.abuild "$TOPDIR" chroot "$BUILD_ROOT" rm -rf "$TOPDIR/KIWIROOT" -set -x if test -x "$BUILD_ROOT/usr/bin/product-builder"; then # current implementation of product generation chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/bin/product-builder --root $TOPDIR/KIWIROOT $VERBOSE_OPTION --logfile terminal --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true @@ -392,7 +391,6 @@ chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT $VERBOSE_OPTION --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true fi fi -set +x # move created product to destination # NOTE: older kiwi versions exit also in error case with 0 @@ -486,7 +484,7 @@ } # translate kiwi8 parameters to kiwi9 -translate_kiwi_parameters() { +kiwi_translate_parameters() { local i lasti local add_repo_url=() add_repo_type=() add_repo_alias=() add_repo_priority=() local set_repo_url set_repo_type set_repo_alias set_repo_priority @@ -543,6 +541,10 @@ fi } +kiwi_query_recipe() { + perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show "$BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE" "$1" "${BUILD_ARCH%%:*}" "$BUILD_FLAVOR" +} + build_kiwi_appliance() { if test -z "$RUNNING_IN_VM" ; then # NOTE: this must be done with the outer system, because it loads @@ -551,13 +553,21 @@ test -x /etc/init.d/boot.device-mapper && \ /etc/init.d/boot.device-mapper start fi - local kiwi_profile=$(queryconfig \ - --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" \ - --archpath "$BUILD_ARCH" buildflags kiwiprofile - ) + local kiwi_profile + kiwi_profile=$(kiwi_query_recipe profiles) + if test -z "$kiwi_profile"; then + kiwi_profile=$(queryconfig \ + --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" \ + --archpath "$BUILD_ARCH" buildflags kiwiprofile + ) + fi if test -z "$kiwi_profile"; then kiwi_profile=__not__set fi + if test "$kiwi_profile" = __excluded ; then + cleanup_and_exit 1 "none of the selected profiles can be built on this architecture" + fi + local kiwi_path=/usr/bin/kiwi kiwi_legacy=false if ! test -L "$BUILD_ROOT/usr/bin/kiwi" ; then kiwi_path=/usr/sbin/kiwi @@ -565,7 +575,7 @@ fi if test "$kiwi_legacy" != true ; then - translate_kiwi_parameters + kiwi_translate_parameters fi local run_bundle=true @@ -588,11 +598,15 @@ } recipe_build_kiwi() { - imagetype=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE imagetype) - imagename=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE filename) - imageversion=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE version) - drop_repo=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE drop_repository) + imagetype=$(kiwi_query_recipe imagetype) + imagename=$(kiwi_query_recipe filename) + imageversion=$(kiwi_query_recipe version) + drop_repo=$(kiwi_query_recipe drop_repository) + if test -z "$imagetype" ; then + cleanup_and_exit 1 "no imagetype set for this architecture/profile" + fi + # prepare rpms as source and createrepo on the repositories ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos test -d $BUILD_ROOT/$TOPDIR/SOURCES/containers && ln -sf $TOPDIR/SOURCES/containers $BUILD_ROOT/containers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/build-recipe-livebuild new/obs-build-20180329/build-recipe-livebuild --- old/obs-build-20180209/build-recipe-livebuild 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/build-recipe-livebuild 2018-03-29 17:01:40.000000000 +0200 @@ -223,6 +223,9 @@ *.iso) build_results="${build_results}\n${i%%.iso}" ;; + *ONIE.bin) + build_results="${build_results}\n${i%%ONIE.bin}" + ;; *.img) build_results="${build_results}\n${i%%.img}" ;; @@ -242,12 +245,18 @@ cleanup_and_exit 1 "No live-build result found" fi - # move created products (and their metadata files) to destination + # move created products (and their metadata files) to destination and + # create sha256 hashsums local buildnum="${RELEASE:+-Build${RELEASE}}" for prefix in $(echo -e ${build_results} | sort | uniq) ; do for f in ${prefix}.* ; do mv ${f} \ $BUILD_ROOT/$TOPDIR/OTHER/${prefix##*/}${buildnum}${f#${prefix}} + # change directory to avoid having full path in hashsum file + pushd $BUILD_ROOT/$TOPDIR/OTHER >/dev/null + /usr/bin/sha256sum "${prefix##*/}${buildnum}${f#${prefix}}" > \ + "${prefix##*/}${buildnum}${f#${prefix}}".sha256 + popd >/dev/null BUILD_SUCCEEDED=true done done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/build-vm new/obs-build-20180329/build-vm --- old/obs-build-20180209/build-vm 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/build-vm 2018-03-29 17:01:40.000000000 +0200 @@ -516,6 +516,9 @@ BUILD_ROOT=/ BUILD_DIR=/.build echo "machine type: `uname -m`" + echo "Linux version: `uname -rv`" + echo "Increasing log level from now on..." + echo 4 > /proc/sysrq-trigger if test "$PERSONALITY" != 0 -a -z "$PERSONALITY_SET" ; then export PERSONALITY_SET=true echo "switching personality to $PERSONALITY..." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/dist/build.spec new/obs-build-20180329/dist/build.spec --- old/obs-build-20180209/dist/build.spec 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/dist/build.spec 2018-03-29 17:01:40.000000000 +0200 @@ -53,6 +53,7 @@ Recommends: perl(YAML::LibYAML) Recommends: bsdtar Recommends: qemu-linux-user +Recommends: /sbin/mkfs.ext3 %endif %if 0%{?suse_version} > 1120 || ! 0%{?suse_version} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/dummyhttpserver new/obs-build-20180329/dummyhttpserver --- old/obs-build-20180209/dummyhttpserver 1970-01-01 01:00:00.000000000 +0100 +++ new/obs-build-20180329/dummyhttpserver 2018-03-29 17:01:40.000000000 +0200 @@ -0,0 +1,191 @@ +#!/usr/bin/perl + +# dead-simple HTTP server +# serves current directory on localhost:80 + +use Socket; +use POSIX; +use Fcntl qw(:DEFAULT :flock); + +use strict; + +$| = 1; + +my ($build_root, $dir) = @ARGV; + +if (defined($build_root)) { + chroot($build_root) || die("chroot $build_root: $!\n"); + chdir('/') || die("chdir /: $!\n"); +} +if (defined($dir)) { + chdir($dir) || die("chdir $dir: $!\n"); +} + +my $tcpproto = getprotobyname('tcp'); +my $acceptsock; +socket($acceptsock , PF_INET, SOCK_STREAM, $tcpproto) || die "socket: $!\n"; +setsockopt($acceptsock, SOL_SOCKET, SO_REUSEADDR, pack("l",1)); +bind($acceptsock, sockaddr_in(80, inet_aton('127.0.0.1'))) || die "bind: $!\n"; +listen($acceptsock , 512) || die "listen: $!\n"; + +my $sock; +my $status; + +sub reply { + my ($str, @hdrs) = @_; + if (@hdrs && $hdrs[0] =~ /^status: ((\d+).*)/i) { + $status = $2; + $hdrs[0] = "HTTP/1.1 $1"; + $hdrs[0] =~ s/:/ /g; + } else { + $status = 200; + unshift @hdrs, "HTTP/1.1 200 OK"; + } + push @hdrs, "Cache-Control: no-cache"; + push @hdrs, "Connection: close"; + push @hdrs, "Content-Length: ".length($str) if defined($str); + my $data = join("\r\n", @hdrs)."\r\n\r\n"; + $data .= $str if defined $str; + fcntl($sock, F_SETFL,O_NONBLOCK); + my $dummy = ''; + 1 while sysread($sock, $dummy, 1024, 0); + fcntl($sock, F_SETFL,0); + my $l; + while (length($data)) { + $l = syswrite($sock, $data, length($data)); + die("write error: $!\n") unless $l; + $data = substr($data, $l); + } +} + +sub reply_error { + my ($errstr) = @_; + my $code = 400; + my $tag = 'Error'; + if ($errstr =~ /^(\d+)\s+([^\r\n]*)/) { + $code = $1; + $tag = $2; + } elsif ($errstr =~ /^([^\r\n]+)/) { + $tag = $1; + } + reply("$errstr\n", "Status: $code $tag", 'Content-Type: text/plain'); +} + +sub readrequest { + my $qu = ''; + my $request; + + while (1) { + if ($qu =~ /^(.*?)\r?\n/s) { + $request = $1; + last; + } + die($qu eq '' ? "empty query\n" : "received truncated query\n") if !sysread($sock, $qu, 1024, length($qu)); + } + my ($act, $path, $vers, undef) = split(' ', $request, 4); + die("400 No method name\n") if !$act; + if ($vers) { + die("501 Unsupported method: $act\n") if $act ne 'GET' && $act ne 'HEAD'; + # read in all headers + while ($qu !~ /^(.*?)\r?\n\r?\n(.*)$/s) { + die("501 received truncated query\n") if !sysread($sock, $qu, 1024, length($qu)); + } + $qu =~ /^(.*?)\r?\n\r?\n(.*)$/s; # redo regexp to work around perl bug + $qu = $2; + } else { + die("501 Bad method, must be GET\n") if $act ne 'GET'; + $qu = ''; + } + my $query_string = ''; + if ($path =~ /^(.*?)\?(.*)$/) { + $path = $1; + $query_string = $2; + } + $path =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge; # unescape path + die("501 invalid path\n") unless $path =~ /^\//s; # forbid relative paths + die("501 invalid path\n") if $path =~ /\0/s; + # do simple path substitutions + while (1) { + next if $path =~ s!//!/!; + next if $path =~ s!/\.(?:/|$)!/!; + next if $path =~ s!/[^/]+/..(?:/|$)!/!; + next if $path =~ s!/..(?:/|$)!/!; + last; + } + return ($path, $query_string, $qu); +} + +sub escape { + my ($d) = @_; + $d =~ s/&/&/sg; + $d =~ s/</</sg; + $d =~ s/>/>/sg; + $d =~ s/"/"/sg; + return $d; +} + +while (1) { + my $peeraddr = accept($sock, $acceptsock); + next unless $peeraddr; + my $pid = fork(); + last if defined($pid) && !$pid; + close $sock; + 1 while waitpid(-1, POSIX::WNOHANG) > 0; +} +close($acceptsock); + +my $path = '?'; +eval { + ($path) = readrequest(); + my $lpath = ".$path"; + if (-d $lpath) { + if ($path !~ /\/$/) { + my $rpath = "$path/"; + $rpath =~ s/([\000-\040<>;\"#\?&\+=%[\177-\377])/sprintf("%%%02X",ord($1))/sge; +; + reply('', 'Status: 301 Moved Permanently', "Location: $rpath"); + } else { + my %d; + my $dir; + if (opendir($dir, $lpath)) { + %d = map {$_ => 1} readdir($dir); + closedir($dir); + } + delete $d{'.'}; + delete $d{'..'}; + my $body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\"><html>\n"; + $body .= "<title>Directory listing for ".escape($path)."</title>\n"; + $body .= "<body>\n"; + $body .= "<h2>Directory listing for ".escape($path)."</h2>\n"; + $body .= "<hr>\n<ul>\n"; + $body .= "<li><a href=\"".escape($_)."\">".escape($_)."</a>\n" for sort keys %d; + $body .= "</ul>\n<hr>\n</body>\n</html>\n"; + reply($body, 'Content-type: text/html'); + } + } elsif (-e _) { + my $f; + open($f, '<', $lpath) || die("500 $lpath: $!\n"); + my @s = stat($f); + die("stat: $!\n") unless @s; + my $l = $s[7]; + reply(undef, "Content-Length: $l", 'Content-Type: application/octet-stream'); + my $data; + while (1) { + last unless $l; + my $r = sysread($f, $data, 8192); + $data = substr($data, 0, $l) if length($data) > $l; + $l -= length($data); + while (length($data)) { + my $l2 = syswrite($sock, $data, length($data)); + die("socket write: $!\n") unless $l2; + $data = substr($data, $l2); + } + } + close($f); + } else { + die("404 File not found\n"); + } +}; +reply_error($@) if $@; +close $sock; +print "[$status $path]"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/obs-docker-support new/obs-build-20180329/obs-docker-support --- old/obs-build-20180209/obs-docker-support 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/obs-docker-support 2018-03-29 17:01:40.000000000 +0200 @@ -46,7 +46,7 @@ esac done case $cmd in - in|install|rm|remove|up|update) + in|install|rm|remove|up|update|if|info) exec /usr/bin/zypper -D $LOCAL_REPOS_D "${globalopts[@]}" "$cmd" "$@" ;; ar|addrepo) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/openstack-console new/obs-build-20180329/openstack-console --- old/obs-build-20180209/openstack-console 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/openstack-console 2018-03-29 17:01:40.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python ################################################################ # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-build-20180209/startdockerd new/obs-build-20180329/startdockerd --- old/obs-build-20180209/startdockerd 2018-02-09 17:00:36.000000000 +0100 +++ new/obs-build-20180329/startdockerd 2018-03-29 17:01:40.000000000 +0200 @@ -153,7 +153,7 @@ if test -n "$WEBSERVER" ; then echo "Starting local repository server" - chroot $BUILD_ROOT bash -c "cd $WEBSERVER && python -m SimpleHTTPServer 80 &" + $BUILD_DIR/dummyhttpserver "$BUILD_ROOT" "$WEBSERVER" & WEBSERVER_PID=$! echo "$CONTAINERD_PID $DOCKERD_PID $WEBSERVER_PID" > $BUILD_ROOT/.startdockerd.pids fi
