From: Marcin Krol Date: Tue, 16 Jul 2013 11:36:21 +0000 (+0000) Subject: - PLD merge... hope nothing will got broken X-Git-Url: https://git.tld-linux.org/?p=packages%2Frpm-build-tools.git;a=commitdiff_plain;h=52c6968e58d5dd2efc78b7758ad5349e41a49e20 - PLD merge... hope nothing will got broken --- diff --git a/adapter.awk b/adapter.awk index fad5240..adbe5ae 100644 --- a/adapter.awk +++ b/adapter.awk @@ -2,7 +2,7 @@ # # Adapter adapts .spec files for PLD Linux. # -# Copyright (C) 1999-2012 PLD-Team +# Copyright (C) 1999-2013 PLD-Team # Authors: # Michał Kuratczyk # Sebastian Zagrodzki @@ -12,7 +12,7 @@ # Jakub Bogusz # Elan Ruusamäe # -# See cvs log adapter{,.awk} for list of contributors +# See git log adapter{,.awk} for list of contributors # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -33,16 +33,14 @@ BEGIN { RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check" SECTIONS = "^%(" RPM_SECTIONS ")" - RCSID = "$Id$" - rev = RCSID # TODO: parse from RCSID - VERSION = "0.35/" rev + rev = "1.514" + VERSION = "0.36/" rev PREAMBLE_TAGS = "(R|BR|Summary|Name|Version|Release|Epoch|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Conflicts|Provides|ExclusiveArch|ExcludeArch|Pre[Rr]eq|(Build)?Requires|Suggests|Auto(Req|Prov))" usedigest = 0 # Enable to switch to rpm 4.4.6+ md5 digests preamble = 1 # Is it part of preamble? Default - yes - boc = 4 # Beginning of %changelog bod = 0 # Beginning of %description tw = 70 # Descriptions width @@ -60,25 +58,9 @@ BEGIN { import_rpm_macros() packages_dir = topdir - groups_file = packages_dir "/rpm.groups" + groups_file = packages_dir "/../rpm-build-tools/rpm.groups" - system("cd "packages_dir"; [ -f rpm.groups ] || cvs up rpm.groups > /dev/null") system("[ -d ../PLD-doc ] && cd ../PLD-doc && ([ -f BuildRequires.txt ] || cvs up BuildRequires.txt >/dev/null)"); - - # Temporary file for changelog section - changelog_file = mktemp("adapter.changelogXXXXXX") -} - -# There should be a comment with CVS keywords on the first line of file. -FNR == 1 { - if (!/^# \$[R]evision: .* \$, \$[D]ate: .* \$$/) { # If this line is already OK? - print "# $" "Revision:$, " "$" "Date:$" # No - if ( /^#.*([rR]evision|[dD]ate)/ ) # There was something similar, but incorrect - next - } else { - print $0 # Yes - next # It is enough for first line - } } # If the latest line matched /%files/ @@ -166,8 +148,9 @@ function b_makekey(a, b, s) { if ($2 == "_applnkdir") { next } + + # FIXME: this section will likely never match after cvs->git migration if ($2 == "date") { - date = 1 if (did_files == 0) { print "%files" print "" @@ -427,7 +410,7 @@ function b_makekey(a, b, s) { if (/CC=%{__cc} /) { sub("CC=%{__cc}", "CC=\"%{__cc}\"") } - + # use PLD Linux macros $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0); $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0); @@ -539,65 +522,6 @@ function b_makekey(a, b, s) { } } -############## -# %changelog # -############## -/^%changelog/, (!/^%changelog/ && $0 ~ SECTIONS) { - preamble = 0 - has_changelog = 1 - skip = 0 - # There should be some CVS keywords on the first line of %changelog. - if (boc == 3) { - if ($0 !~ _cvsmailfeedback) { - print "* %{date} " _cvsmailfeedback > changelog_file - } else { - skip = 1 - } - boc = 2 - } - if (boc == 2 && !skip) { - if (!/All persons listed below/) { - printf "All persons listed below can be reached at " > changelog_file - print "" _cvsmaildomain "\n" > changelog_file - } else { - skip = 1 - } - boc = 1 - } - if (boc == 1 && !skip) { - if (!/^$/) { - if (!/\$.*Log:.*\$/) { - print "$" "Log:$" > changelog_file - } - boc = 0 - } - } - # Define date macro. - if (boc == 4) { - if (date == 0) { - printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file - print " date +\"%a %b %d %Y\"`)" > changelog_file - date = 1 - } - boc = 3 - } - - sub(/[ \t]+$/, ""); - if (!/^%[a-z]+$/ || /changelog/) { - # stop changelog if "real" changelog starts - if (boc == 0 && /^\* /) { - boc = -1 - } - if (boc == -1) { - next; - } - print > changelog_file - } else { - print - } - next -} - ########### # SCRIPTS # ########### @@ -708,22 +632,31 @@ preamble == 1 { release = "0." fixedsub(".%{disttag}.at", "", $4) } + # deprecated. currently just resolves to name in $2 + if (/^%pyrequires_eq.+/) { + $1 = "Requires:"; + } + + # F<16 had requires(hint) + if (/^Requires\(hint\):/) { + $1 = "Suggests:"; + } + field = tolower($1) if (field ~ /summary:/ && !/etc\.$/ && !/Inc\.$/) { sub(/\.$/, "", $0); } - if (field ~ /group(\([^)]+\)):/) + if (field ~ /group(\([^)]+\)):/) { next - if (field ~ /group:/) { + } + + if (field == "group:") { format_preamble() group = $0; sub(/^[^ \t]*[ \t]*/, "", group); group = replace_groupnames(group); $0 = "Group:\t\t" group - if (group ~ /^X11/ && x11 == 0) # Is it X11 application? - x11 = 1 - byl_plik_z_groupmi = 0 byl_opis_grupy = 0 while ((getline linia_grup < groups_file) > 0) { @@ -743,7 +676,7 @@ preamble == 1 { did_groups = 1 } - if (field ~ /prereq:/) { + if (field == "prereq:") { sub(/Pre[Rr]eq:/, "Requires:", $1); } @@ -754,7 +687,7 @@ preamble == 1 { } # BR: tar (and others) is to common (rpm-build requires it) - if (field ~ /^buildrequires:/) { + if (field == "buildrequires:") { l = substr($0, index($0, $2)); if (l == "awk" || l == "binutils" || @@ -776,11 +709,11 @@ preamble == 1 { next } - replace_requires(); + replace_requires(field); } - if (field ~ /^requires:/ || field ~ /^requires\(/) { - replace_requires(); + if (field == "requires:" || field ~ /^requires\(/) { + replace_requires(field); } @@ -818,7 +751,13 @@ preamble == 1 { if (l == "Python Software Foundation License") { l = "PSF" } - if (l == "Apache License 2.0" || l == "Apache 2.0" || l == "Apache License Version 2.0" || l == "Apache License, Version 2.0" || l == "Apache Software License v2") { + if (l == "Apache License 2.0" || \ + l == "Apache 2.0" || \ + l == "Apache License Version 2.0" || \ + l == "Apache License, Version 2.0" || \ + l == "Apache Software License v2" || \ + l == "ASL 2.0" \ + ) { l = "Apache v2.0" } if (l == "Apache Group License" || l == "Apache Software License" || l == "Apache License") { @@ -1082,36 +1021,11 @@ END { } } - close(changelog_file) - while ((getline < changelog_file) > 0) - print - system("rm -f " changelog_file) - if (did_clean == 0) { print "" print "%clean" print "rm -rf $RPM_BUILD_ROOT" } - - if (date == 0) { - print "" - print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)" - } - - if (has_changelog == 0) { - print "%changelog" - } - - if (boc > 2) { - print "* %{date} PLD Team " - } - if (boc > 1) { - printf "All persons listed below can be reached at " - print "@pld-linux.org\n" - } - if (boc > 0) { - print "$" "Log:$" - } } # substitutes fixed strings (not regexps) @@ -1160,6 +1074,7 @@ function use_macros() } sub("%{_defaultdocdir}", "%{_docdir}"); + sub("%{_datadir}/doc", "%{_docdir}"); sub("%{_bindir}/perl", "%{__perl}"); sub("%{_bindir}/python", "%{__python}"); @@ -1171,7 +1086,7 @@ function use_macros() gsub(perl_vendorlib, "%{perl_vendorlib}") gsub(perl_vendorarch, "%{perl_vendorarch}") gsub(perl_sitelib, "%{perl_sitelib}") - + gsub(py_sitescriptdir, "%{py_sitescriptdir}") gsub(py_sitedir, "%{py_sitedir}") gsub(py_scriptdir, "%{py_scriptdir}") @@ -1179,14 +1094,23 @@ function use_macros() gsub(py3_sitescriptdir, "%{py3_sitescriptdir}") gsub(py3_sitedir, "%{py3_sitedir}") gsub(py3_scriptdir, "%{py3_scriptdir}") + gsub("%{python3_sitelib}", "%{py3_sitescriptdir}") + gsub("%{python3_version}", "%{py3_ver}") gsub(ruby_archdir, "%{ruby_archdir}") - gsub(ruby_ridir, "%{ruby_ridir}") - gsub(ruby_rubylibdir, "%{ruby_rubylibdir}") + gsub(ruby_libdir, "%{ruby_libdir}") + gsub(ruby_sitearchdir, "%{ruby_sitearchdir}") gsub(ruby_sitelibdir, "%{ruby_sitelibdir}") + gsub(ruby_sitedir, "%{ruby_sitedir}") + gsub(ruby_vendorarchdir, "%{ruby_vendorarchdir}") + gsub(ruby_vendorlibdir, "%{ruby_vendorlibdir}") + gsub(ruby_vendordir, "%{ruby_vendordir}") + gsub(ruby_rubylibdir, "%{ruby_rubylibdir}") # deprecated gsub(ruby_rdocdir, "%{ruby_rdocdir}") + gsub(ruby_ridir, "%{ruby_ridir}") + gsub("%{_unitdir}", "%{systemdunitdir}") gsub(systemdunitdir, "%{systemdunitdir}") gsub(systemdtmpfilesdir, "%{systemdtmpfilesdir}") @@ -1293,6 +1217,8 @@ function use_macros() continue; if ($c ~ sysconfdir "/apm") continue; + if ($c ~ sysconfdir "/modules-load\.d") + continue; gsub(sysconfdir, "%{_sysconfdir}", $c) } @@ -1910,11 +1836,6 @@ function import_rpm_macros( v) { exit(rc = 1); } - # get cvsaddress for changelog section - # using rpm macros as too lazy to add ~/.adapterrc parsing support. - _cvsmaildomain = ENVIRON["_cvsmaildomain"] - _cvsmailfeedback = ENVIRON["_cvsmailfeedback"] - prefix = ENVIRON["_prefix"] bindir = ENVIRON["_bindir"] sbindir = ENVIRON["_sbindir"] @@ -1953,11 +1874,16 @@ function import_rpm_macros( v) { py3_ver = ENVIRON["py3_ver"] ruby_archdir = ENVIRON["ruby_archdir"] - ruby_ridir = ENVIRON["ruby_ridir"] - ruby_rubylibdir = ENVIRON["ruby_rubylibdir"] + ruby_libdir = ENVIRON["ruby_libdir"] + ruby_sitedir = ENVIRON["ruby_sitedir"] ruby_sitearchdir = ENVIRON["ruby_sitearchdir"] ruby_sitelibdir = ENVIRON["ruby_sitelibdir"] + ruby_vendordir = ENVIRON["ruby_vendordir"] + ruby_vendorarchdir = ENVIRON["ruby_vendorarchdir"] + ruby_vendorlibdir = ENVIRON["ruby_vendorlibdir"] + ruby_rubylibdir = ENVIRON["ruby_rubylibdir"] # deprecated ruby_rdocdir = ENVIRON["ruby_rdocdir"] + ruby_ridir = ENVIRON["ruby_ridir"] php_pear_dir = ENVIRON["php_pear_dir"] php_data_dir = ENVIRON["php_data_dir"] @@ -1968,27 +1894,29 @@ function import_rpm_macros( v) { } # php virtual deps as discussed in devel-en -function replace_php_virtual_deps() { +function replace_php_virtual_deps(field) { pkg = $2 # if (pkg == "php-program") { # $0 = $1 "\t/usr/bin/php" # return # } -# if (pkg ~ /^php-[a-z]/ && pkg !~ /^php-(pear|common|cli|devel|fcgi|cgi|dirs|program|pecl-)/) { -# sub(/^php-/, "php(", pkg); -# sub(/$/, ") # verify this correctness -- it may be wanted to use specific not virtual dep", pkg); -# $2 = pkg -# } + if (field == "requires:") { + if (pkg ~ /^php-(bcmath|bz2|calendar|ctype|curl|dba|date|dom|enchant|exif|fileinfo|filter|fpm|ftp|gd|gettext|gmp|hash|iconv|imap|interbase|intl|json|ldap|mbstring|mcrypt|mssql|mysql|mysqli|odbc|openssl|pcntl|pcre|pdo|pdo-dblib|pdo-firebird|pdo-mysql|pdo-odbc|pdo-pgsql|pdo-sqlite|pgsql|phar|posix|pspell|readline|recode|session|shmop|simplexml|snmp|soap|sockets|spl|sqlite|sqlite3|sybase-ct|sysvmsg|sysvsem|sysvshm|tidy|tokenizer|wddx|xml|xmlreader|xmlrpc|xmlwriter|xsl|zip|zlib)/) { + sub(/^php-/, "php(", pkg); + sub(/$/, ")", pkg); + $2 = pkg + } + } - if (pkg ~/^php$/) { - $2 = "webserver(php)"; + if (pkg == "php" || pkg == "php-common") { + $2 = "php(core)"; if ($4 ~ /^[0-9]:/) { $4 = substr($4, 3); } } - if (pkg ~/^php4$/) { + if (pkg == "php4") { $2 = "webserver(php)"; if ($4 ~ /^[0-9]:/) { $4 = substr($4, 3); @@ -1996,6 +1924,7 @@ function replace_php_virtual_deps() { } } +# {{{ replace_groupnames(group) function replace_groupnames(group) { group = replace(group, "Amusements/Games", "Applications/Games"); group = replace(group, "Amusements/Games/Strategy/Real Time", "X11/Applications/Games/Strategy"); @@ -2035,6 +1964,7 @@ function replace_groupnames(group) { group = replace(group, "Productivity/Databases/Servers", "Applications/Databases"); group = replace(group, "Productivity/Multimedia/Other", "X11/Applications/Multimedia"); group = replace(group, "Productivity/Networking/Web/Servers", "Networking/Daemons/HTTP");; + group = replace(group, "Python/Libraries", "Libraries/Python"); group = replace(group, "Shells", "Applications/Shells"); group = replace(group, "System Environment/Base", "Base"); group = replace(group, "System Environment/Daemons", "Daemons"); @@ -2065,8 +1995,55 @@ function replace_groupnames(group) { return group; } +# }}} -function replace_requires() { +# {{{ replace_pkgconfig(pkg) +function replace_pkgconfig(pkg, cmd, path, n, i, line) { + n = split("/usr/lib64/pkgconfig /usr/lib/pkgconfig /usr/share/pkgconfig", path, / /); + for (i = 1; i <= n; i++) { + cmd = "rpm -qf --qf '%{N}' " path[i] "/" pkg ".pc"; + # Getline returns 0 on end-of-file, -1 on error, otherwise 1. + if ((cmd | getline line) <= 0) { + continue; + } + + if (line !~ /No such file or directory/) { + # @modifies global $2 + $2 = line; + return + } + } +} +# }}} + +# {{{ replace_pythonegg(pkg) +function replace_pythonegg(pkg, cmd, line) { + cmd = "rpm -q --qf '%{N}' --whatprovides 'pythonegg(" pkg ")'"; + # Getline returns 0 on end-of-file, -1 on error, otherwise 1. + if ((cmd | getline line) <= 0) { + return; + } + + if (line !~ /no package provides/) { + # @modifies global $2 + $2 = line; + return; + } +} +# }}} + +function replace_requires(field, pkg) { + # pkg-config -> package names + if (match($2, /pkgconfig\(([^)]+)\)/)) { + pkg = substr($2, RSTART + 10, RLENGTH - 11); + replace_pkgconfig(pkg); + } + + # pythonegg -> package names + if (match($2, /pythonegg\(([^)]+)\)/)) { + pkg = substr($2, RSTART + 10, RLENGTH - 11); + replace_pythonegg(pkg); + } sub(/^python-setuptools-devel$/, "python-distribute", $2); sub(/^gcc-g77/, "gcc-fortran", $2); @@ -2077,7 +2054,7 @@ function replace_requires() { # bad package.xml, see http://pear.php.net/bugs/bug.php?id=17779 sub(/^php-php-gtk/, "php-gtk2", $2); - # jpackages / fedora java packages + # {{{ jpackages / fedora java packages sub(/^antlr3$/, "java-antlr3", $2); sub(/^aqute-bnd$/, "java-bnd", $2); sub(/^avalon-framework$/, "java-avalon-framework", $2); @@ -2152,17 +2129,24 @@ function replace_requires() { sub(/^xml-commons-resolver$/, "java-xml-commons-resolver", $2); sub(/^xmldb-api$/, "java-xmldb", $2); sub(/^xmldb-api-sdk$/, "java-xmldb-sdk", $2); + # }}} - # fedora / redhat + # {{{ fedora / redhat sub(/^Django$/, "python-django", $2); sub(/^GitPython$/, "python-git", $2); + sub(/^MySQL-python$/, "python-MySQLdb", $2); + sub(/^NetworkManager-glib-devel$/, "NetworkManager-devel", $2); sub(/^PyQt4-devel$/, "python-PyQt4-devel", $2); sub(/^PyQwt-devel$/, "python-PyQwt-devel", $2); + sub(/^PyYAML$/, "python-PyYAML", $2); sub(/^ccid$/, "pcsc-driver-ccid", $2); sub(/^chkconfig$/, "/sbin/chkconfig", $2); sub(/^db4-devel$/, "db-devel", $2); sub(/^dbus-python$/, "python-dbus", $2); sub(/^desktop-notification-daemon$/, "dbus(org.freedesktop.Notifications)", $2); + sub(/^device-mapper-multipath$/, "multipath-tools", $2); + sub(/^django-tagging$/, "python-django_tagging", $2); + sub(/^elfutils-libelf-devel$/, "elfutils-devel", $2); sub(/^file-devel$/, "libmagic-devel", $2); sub(/^freetype2-devel$/, "freetype-devel", $2); sub(/^fuse-devel$/, "libfuse-devel", $2); @@ -2176,6 +2160,7 @@ function replace_requires() { sub(/^gtk-sharp2-devel$/, "dotnet-gtk-sharp2-devel", $2); sub(/^gtk2$/, "gtk+2", $2); sub(/^gtk2-devel$/, "gtk+2-devel", $2); + sub(/^gtk3$/, "gtk+3", $2); sub(/^gtk3-devel$/, "gtk+3-devel", $2); sub(/^initscripts$/, "rc-scripts", $2); sub(/^iproute$/, "iproute2", $2); @@ -2193,6 +2178,10 @@ function replace_requires() { sub(/^libXinerama-devel$/, "xorg-lib-libXinerama-devel", $2); sub(/^libXrandr-devel$/, "xorg-lib-libXrandr-devel", $2); sub(/^libXrender-devel$/, "xorg-lib-libXrender-devel", $2); + sub(/^libXt-devel$/, "xorg-lib-libXt-devel", $2); + sub(/^libXtst-devel$/, "xorg-lib-libXtst-devel", $2); + sub(/^libXv-devel$/, "xorg-lib-libXv-devel", $2); + sub(/^libXxf86misc-devel$/, "xorg-lib-libXxf86misc-devel", $2); sub(/^libXxf86vm-devel$/, "xorg-lib-libXxf86vm-devel", $2); sub(/^libacl-devel$/, "acl-devel", $2); sub(/^libcurl-devel$/, "curl-devel", $2); @@ -2205,6 +2194,8 @@ function replace_requires() { sub(/^libtevent$/, "tevent", $2); sub(/^libtevent-devel$/, "tevent-devel", $2); sub(/^libusb1-devel$/, "libusb-devel", $2); + sub(/^libuser-python$/, "python-libuser", $2); + sub(/^libxkbfile-devel$/, "xorg-lib-libxkbfile", $2); sub(/^mod_wsgi$/, "apache-mod_wsgi", $2); sub(/^newt-python$/, "python-snack", $2); sub(/^notify-python$/, "python-pynotify", $2); @@ -2214,13 +2205,18 @@ function replace_requires() { sub(/^pycairo$/, "python-pycairo", $2); sub(/^pyflakes$/, "python-pyflakes", $2); sub(/^pygobject2$/, "python-pygobject", $2); + sub(/^pygobject3$/, "python-pygobject3", $2); sub(/^pygobject3-devel$/, "python-pygobject3-common-devel", $2); sub(/^pygtk2$/, "python-pygtk", $2); sub(/^pygtk2-devel$/, "python-pygtk-devel", $2); sub(/^pygtk2-libglade$/, "python-pygtk-glade", $2); + sub(/^pykickstart$/, "python-pykickstart", $2); + sub(/^pyparsing$/, "python-pyparsing", $2); + sub(/^pyparted$/, "python-parted", $2); sub(/^pysvn$/, "python-pysvn", $2); sub(/^pytalloc$/, "python-talloc", $2); sub(/^pytalloc-devel$/, "python-talloc-devel", $2); + sub(/^pytest$/, "python-pytest", $2); sub(/^python-cups$/, "python-pycups", $2); sub(/^python-enchant$/, "python-pyenchant", $2); sub(/^python-imaging$/, "python-PIL", $2); @@ -2233,6 +2229,7 @@ function replace_requires() { sub(/^python-twisted-names$/, "python-TwistedNames", $2); sub(/^python2-devel$/, "python-devel", $2); sub(/^pytz$/, "python-pytz", $2); + sub(/^pyxdg$/, "python-pyxdg", $2); sub(/^qt4-devel$/, "qt4-build", $2); sub(/^qt4-webkit-devel$/, "QtWebKit-devel", $2); sub(/^qtlockedfile-devel$/, "QtLockedFile-devel", $2); @@ -2245,8 +2242,9 @@ function replace_requires() { sub(/^webkitgtk3-devel$/, "gtk-webkit3-devel", $2); sub(/^xapian-bindings-python$/, "python-xapian", $2); sub(/^xorg-x11-server-sdk$/, "xorg-xserver-server-devel", $2); + # }}} - # mandriva + # {{{ mandriva sub(/^python-gobject-devel$/, "python-pygobject-devel", $2); sub(/^python-pyrex$/, "python-Pyrex", $2); sub(/^webkitgtk-devel$/, "gtk-webkit-devel", $2); @@ -2254,8 +2252,9 @@ function replace_requires() { sub(/^python-webkitgtk$/, "python-pywebkitgtk", $2); sub(/^pygtk2.0$/, "python-pygtk-gtk", $2); sub(/^gnome-python-gconf$/, "python-gnome-gconf", $2); + # }}} - # debian / ubuntu + # {{{ debian / ubuntu sub(/^blkid-dev$/, "libblkid-devel", $2); sub(/^ext2fs-dev$/, "e2fsprogs-devel", $2); sub(/^libao-dev$/, "libao-devel", $2); @@ -2292,8 +2291,9 @@ function replace_requires() { sub(/^tcp_wrappers-devel$/, "libwrap-devel", $2); sub(/^vala-tools$/, "vala", $2); sub(/^vala-devel$/, "vala", $2); + # }}} - # altlinux + # {{{ altlinux sub(/^libatk-devel$/, "atk-devel", $2); sub(/^libgit-devel$/, "git-core-devel", $2); sub(/^libgtk\+2-devel$/, "gtk+2-devel", $2); @@ -2303,8 +2303,9 @@ function replace_requires() { sub(/^libpcre-devel$/, "pcre-devel", $2); sub(/^libpopt-devel$/, "popt-devel", $2); sub(/^libssl-devel$/, "openssl-devel", $2); + # }}} - # suse + # {{{ suse/opensuse sub(/^alsa-devel$/, "alsa-lib-devel", $2); sub(/^gtk-sharp2$/, "dotnet-gtk-sharp2", $2); sub(/^gtkmm2-devel$/, "gtkmm-devel", $2); @@ -2313,9 +2314,14 @@ function replace_requires() { sub(/^libopenssl-devel$/, "openssl-devel", $2); sub(/^libpulse-devel$/, "pulseaudio-devel", $2); sub(/^monodoc-core$/, "mono-monodoc", $2); + sub(/^python-cairo$/, "python-pycairo", $2); + sub(/^python-gobject$/, "python-pygobject", $2); + sub(/^python-gstreamer-0_10$/, "python-gstreamer", $2); sub(/^python-gtk$/, "python-pygtk-gtk", $2); + sub(/^python-xdg$/, "python-pyxdg", $2); + # }}} - replace_php_virtual_deps() + replace_php_virtual_deps(field) } -# vim:ts=4:sw=4 +# vim:ts=4:sw=4 fdm=marker diff --git a/adapter.sh b/adapter.sh index 44a4ee2..d5c7866 100755 --- a/adapter.sh +++ b/adapter.sh @@ -12,17 +12,16 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -RCSID='$Id$' -REVISION=${RCSID#* * } REVISION=${REVISION%% *} +REVISION=1.50 VERSION="v0.35/$REVISION" VERSIONSTRING="\ Adapter adapts .spec files for PLD Linux. -$VERSION (C) 1999-2010 Free Penguins". +$VERSION (C) 1999-2013 Free Penguins". PROGRAM=${0##*/} dir=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d") adapter=$dir/adapter.awk -usage="Usage: $PROGRAM [FLAGS] SPECFILE +usage="Usage: $PROGRAM [FLAGS] SPECFILEs -s|--no-sort|--skip-sort skip BuildRequires, Requires sorting @@ -61,7 +60,7 @@ fi t=$(getopt -o hsomdaV --long help,version,sort,sort-br,no-macros,skip-macros,skip-desc,skip-defattr -n "$PROGRAM" -- "$@") || exit $? eval set -- "$t" -while true; do +while :; do case "$1" in -h|--help) echo 2>&1 "$usage" @@ -215,11 +214,16 @@ import_rpm_macros() { py3_ver ruby_archdir - ruby_ridir - ruby_rubylibdir + ruby_libdir + ruby_sitedir ruby_sitearchdir ruby_sitelibdir + ruby_vendordir + ruby_vendorarchdir + ruby_vendorlibdir + ruby_rubylibdir ruby_rdocdir + ruby_ridir php_pear_dir php_data_dir @@ -247,6 +251,9 @@ import_rpm_macros() { } adapterize() { + local SPECFILE="$1" + [ -f "$SPECFILE" ] || SPECFILE="$(basename $SPECFILE .spec).spec" + local workdir workdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit $? awk=gawk @@ -300,20 +307,19 @@ adapterize() { cat $tmp.diff fi else - echo "The SPEC is perfect ;)" + echo "The spec $SPECFILE is perfect ;)" fi rm -rf $workdir } -SPECFILE="$1" -[ -f "$SPECFILE" ] || SPECFILE="$(basename $SPECFILE .spec).spec" - -if [ $# -ne 1 -o ! -f "$SPECFILE" ]; then +if [ $# -eq 0 ]; then echo "$usage" exit 1 fi -adapterize +for SPECFILE in "$@"; do + adapterize $SPECFILE +done # vim: ts=4:sw=4 diff --git a/builder.sh b/builder.sh index b3824f1..e7e8d34 100755 --- a/builder.sh +++ b/builder.sh @@ -39,9 +39,9 @@ RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev= VERSION="v0.35/$rev" VERSIONSTRING="\ Build package utility from PLD Linux Packages repository -$VERSION (C) 1999-2012 Free Penguins". +$VERSION (C) 1999-2013 Free Penguins". -PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" +CLEAN_PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" # required rpm-build-macros RPM_MACROS_VER=1.534 @@ -84,6 +84,10 @@ TARGET=$(rpm -E %{_target}) # Yes, you can use variable name! Note _single_ quotes! LOGFILE='' +# use teeboth Perl wrapper +# temporary option to disable if broken +USE_TEEBOTH=yes + LOGDIR="" LOGDIROK="" LOGDIRFAIL="" @@ -255,6 +259,7 @@ fi POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/" POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask" +# TODO: add teeboth run_poldek() { RES_FILE=$(tempfile) if [ -n "$LOGFILE" ]; then @@ -263,6 +268,7 @@ run_poldek() { echo "LASTLOG=$LOG" > $LASTLOG_FILE fi (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG + # FIXME $exit_pldk undefined return $exit_pldk else (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null @@ -297,6 +303,10 @@ download_lftp() { usage() { if [ -n "$DEBUG" ]; then set -xv; fi +# NOTE: +# to make this output parseable by bash-completion _parse_help() +# if the line contains short and long option, it will take only the long option +# but if you want both being completed, put the short option to separate line echo "\ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build] [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade] @@ -309,46 +319,52 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ [--show-bconds] [--with/--without ] [--define ] [.spec][:tag] --4 - force ipv4 when transferring files --5, --update-md5 - update md5 comments in spec, implies -nd -ncs --6 - force ipv6 when transferring files --a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs +-4 - force IPv4 when transferring files +-6 - force IPv6 when transferring files +-5, +--update-md5 - update md5 comments in spec, implies -nd -ncs +-a5, +--add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs --all-branches - make shallow fetch of all branches; --depth required -n5, --no-md5 - ignore md5 comments in spec -D, --debug - enable builder script debugging mode, -debug - produce rpm debug package (same as --opts -debug) -V, --version - output builder version string --short-version - output builder short version --a, --add_vcs - try add new package to PLD repo. --b, -ba, --build - get all files from PLD repo or HTTP/FTP and build package +-a - try add new package to PLD repo. +-b, +-ba + - get all files from PLD repo or HTTP/FTP and build package from .spec, --bb, --build-binary - get all files from PLD repo or HTTP/FTP and build binary +-bb - get all files from PLD repo or HTTP/FTP and build binary only package from .spec, --bp, --build-prep - execute the %prep phase of .spec, +-bp - execute the %prep phase of .spec, -bc - execute the %build phase of .spec, -bi - execute the %install phase of .spec -bl - execute the %files phase of .spec --bs, --build-source - get all files from PLD repo or HTTP/FTP and only pack +-bs - get all files from PLD repo or HTTP/FTP and only pack them into src.rpm, --short-circuit - short-circuit build -B, --branch - add branch --c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands. +-c, +--clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands. may be used with building process. -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES, SPECS and \$RPM_BUILD_ROOT). Doesn't run any rpm building. -cf, --cvs-force - use -f when tagging ---define +--define ' ' - define a macro with value , --depth - make shallow fetch --alt_kernel - same as --define 'alt_kernel ' --nodeps - rpm won't check any dependences --g, --get - get .spec and all related files from PLD repo - or HTTP/FTP, +-g +--get - get .spec and all related files from PLD repo -h, --help - this message, --jN, -j N - set %_smp_mflags to propagate concurrent jobs ---ftp, --http - use ftp or http protocol to access distfiles server --l , --logtofile +-j N - set %_smp_mflags to propagate concurrent jobs +--ftp - use FTP protocol to access distfiles server +--http - use HTTP protocol to access distfiles server +-l , --logtofile= - log all to file, -ncs, --no-cvs-specs - don't pull from PLD repo @@ -358,7 +374,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -ns, --no-srcs - don't download Sources/Patches -ns0, --no-source0 - don't download Source0 -nn, --no-net - don't download anything from the net --pN, -p N - set PARALLEL_DOWNLOADS to N (default $PARALLEL_DOWNLOADS) +-p N - set PARALLEL_DOWNLOADS to N (default $PARALLEL_DOWNLOADS) -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES --no-init - don't initialize builder paths (SPECS and SOURCES) @@ -370,8 +386,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ --date yyyy-mm-dd - build package using resources from specified date, -r , --cvstag - build package using resources from specified branch/tag, --A - build package using master branch as any sticky - tags/branch/date being reset. +-A - build package using master branch as any sticky tags/branch/date being reset. -R, --fetch-build-requires - fetch what is BuildRequired, -RB, --remove-build-requires @@ -381,33 +396,32 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ - remove all you fetched with -R or --fetch-build-requires remember, this option works without confirmation, -sd, --source-distfiles - - list sources available from distfiles (intended for - offline operations; does not work when Icon field is - present but icon file is absent), + - list sources available from distfiles (intended for offline + operations; does not work when Icon field is present + but icon file is absent), -sc, --source-cvs - list sources available from PLD repo -sdp, --source-distfiles-paths - list sources available from distfiles - - paths relative to distfiles directory (intended for - offline operations; does not work when Icon field is - present but icon file is absent), + paths relative to distfiles directory (intended for offline + operations; does not work when Icon field is present + but icon file is absent), -sf, --source-files - list sources - bare filenames (intended for offline operations; does not work when Icon field is present but icon file is absent), -lsp, --source-paths - - list sources - filenames with full local paths (intended - for offline operations; does not work when Icon field is - present but icon file is absent), + - list sources - filenames with full local paths (intended for + offline operations; does not work when Icon field is present + but icon file is absent), -su, --source-urls - list urls - urls to sources and patches - intended for copying urls with spec with lots of macros - in urls + intended for copying urls with spec with lots of macros in urls -T , --tag - add git tag for files, -Tvs, --tag-version-stable - add git tags STABLE and NAME-VERSION-RELEASE for files, -Ts, --tag-stable - add git tag STABLE for files, --Tv, --tag-version - - add git tag NAME-VERSION-RELEASE for files, +-Tv, +--tag-version - add git tag NAME-VERSION-RELEASE for files, -Tp, --tag-prefix - add to NAME-VERSION-RELEASE tags, -tt, --test-tag @@ -420,24 +434,27 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ - as above, but allow float version php-pear-Services_Digg/ --upgrade-version - upgrade to specified version in try-upgrade --U, --update - refetch sources, don't use distfiles, and update md5 - comments +-U, --update - refetch sources, don't use distfiles, and update md5 comments -Upi, --update-poldek-indexes - refresh or make poldek package index files. --sp, --skip-patch +-sp , +--skip-patch - don't apply . may be repeated. --np, --nopatch +-np , +--nopatch - abort instead of applying patch +--noinit + - do not initialize SPECS_DIR and SOURCES_DIR (set them to .) --show-bconds - show available conditional builds, which can be used - with --with and/or --without switches. ---show-bcond-args - show active bconds, from ~/.bcondrc. this is used by - ./repackage.sh script. In other words, the output is - parseable by scripts. +--show-bcond-args - show active bconds, from ~/.bcondrc. this is used by ./repackage.sh script. + In other words, the output is parseable by scripts. --show-avail-bconds - show available bconds ---with/--without +--with , +--without - conditional build package depending on %_with_/ %_without_ macro switch. You may now use - --with feat1 feat2 --without feat3 feat4 --with feat5 + --with feat1 feat2 feat3 --without feat4 feat5 --with feat6 constructions. Set GROUP_BCONDS to yes to make use of it. --target , --target= - build for platform . @@ -450,11 +467,11 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ # create tempfile. as secure as possible tempfile() { - mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$ + mktemp --tmpdir -t builder.$PACKAGE_NAME.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$ } tempdir() { - mktemp -d builder.XXXXXX + mktemp --tmpdir -d builder.$PACKAGE_NAME.XXXXXX } # inserts git log instead of %changelog @@ -468,15 +485,28 @@ insert_gitlog() { # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997' # otherwise i'd use --date=iso here # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1 - # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31 + # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c;h=56ba69daa41d65ec9fd18c9f371b8ff14118cdca;hb=a113baa510a004476edc44b5ebaaf559238a18b6#l33 # NOTE: changelog date is always in UTC for rpmbuild # * 1265749244 +0000 Random Hacker 9370900 - git rev-list -${log_entries:-20} HEAD | while read sha1; do + git rev-list --date-order -${log_entries:-20} HEAD 2>/dev/null | while read sha1; do local logfmt='%B%n' - git notes list $sha1 1>/dev/null 2>&1 && logfmt=%N - git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n${logfmt}%n" --date=raw | sed '/^$/q' + git notes list $sha1 > /dev/null 2>&1 && logfmt='%N' + git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n- ${logfmt}%n" --date=raw | sed -re 's/^- +- */- /'| sed '/^$/q' done > $gitlog - LC_ALL=C gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog + + # add link to full git logs + local giturl="http://git.tld-linux.org/?p=packages/$PACKAGE_NAME.git;a=log" + if [ -n "$CVSTAG" ]; then + giturl="$giturl;h=$CVSTAG" + fi + local gitauthor="TLD Linux " + LC_ALL=C gawk -vgiturl="$giturl" -vgitauthor="$gitauthor" -vpackage=$PACKAGE_NAME 'BEGIN{ + printf("* %s %s\n- For complete changelog see: %s\n", strftime("%a %b %d %Y"), gitauthor, giturl); + print; + exit + }' > $speclog + + LC_ALL=C gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog >> $speclog sed '/^%changelog/,$d' $SPECFILE | sed -e "\${ a%changelog r $speclog @@ -486,6 +516,29 @@ insert_gitlog() { echo $specdir } +# @param string logfile +# @param varargs... commands to execute +teeboth() { + local rc + # use teeboth from toys/cleanbuild, if available and enabled + if [ "$USE_TEEBOTH" = "yes" ] && [ -x $APPDIR/teeboth ]; then + $APPDIR/teeboth "$@" + rc=$? + else + local efile rc logfile=$1; shift + if [ "$logfile" ]; then + efile=$(tempfile) + { "$@" 2>&1; echo $? > $efile; } | tee -a $logfile + rc=$(< $efile) + rm -f $efile + else + "$@" + rc=$? + fi + fi + return $rc +} + # change dependency to specname # common changes: # - perl(Package::Name) -> perl-Package-Name @@ -529,9 +582,9 @@ update_shell_title() { # set TARGET from BuildArch: from SPECFILE set_spec_target() { if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then - tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE) + local tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE) if [ "$tmp" ]; then - target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}') + local target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}') TARGET="$tmp" case "$RPMBUILD" in "rpmbuild") @@ -569,6 +622,7 @@ minirpm() { %releq_kernel_up(n:) ERROR %releq_kernel_smp(n:) ERROR %releq_kernel(n:) ERROR +%py_postclean(x:) ERROR %kgcc_package ERROR %_fontsdir ERROR %ruby_version ERROR @@ -611,7 +665,7 @@ EOF %_sourcedir ./ EOF fi - eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1 + eval PATH=$CLEAN_PATH $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1 } cache_rpm_dump() { @@ -622,7 +676,7 @@ cache_rpm_dump() { if [ -x /usr/bin/rpm-specdump ]; then update_shell_title "cache_rpm_dump using rpm-specdump command" - rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE) + rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE) else update_shell_title "cache_rpm_dump using rpmbuild command" local rpm_dump @@ -780,6 +834,9 @@ Exit_error() { remove_build_requires echo >&2 "Error: problem with remote (${2})" exit 13 ;; + "err_no_checkut" ) + echo >&2 "Error: cannot checkout $2" + exit 14 ;; "err_not_implemented" ) remove_build_requires echo >&2 "Error: functionality not yet imlemented" @@ -817,7 +874,7 @@ init_builder() { export GIT_WORK_TREE=$PACKAGE_DIR export GIT_DIR=$PACKAGE_DIR/.git - if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then + if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ] && git rev-parse --verify -q HEAD > /dev/null; then if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then CVSTAG=${CVSTAG#refs/heads/} if [ "$CVSTAG" != "master" ]; then @@ -850,7 +907,7 @@ create_git_repo() { exit 101 fi [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes - # ssh $GIT_SERVER create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed + ssh $GIT_PUSH create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed git init git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git && \ git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} \ @@ -867,18 +924,14 @@ get_spec() { fi cd "$REPO_DIR" - if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then - # XXX: still needed? - SPECFILE=$(basename $SPECFILE) - fi - + SPECFILE=$(basename $SPECFILE) if [ "$NOCVSSPEC" != "yes" ]; then if [ -z "$DEPTH" ]; then - if [ -d "$ASSUMED_NAME/.git" ]; then + if [ -d "$PACKAGE_DIR/.git" ]; then git fetch $REMOTE_PLD || Exit_error err_no_spec_in_repo elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then - if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then - echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2 + if [ ! -r "$PACKAGE_DIR/$SPECFILE" ]; then + echo "ERROR: No package to add ($PACKAGE_DIR/$SPECFILE)" >&2 exit 101 fi Exit_error err_not_implemented @@ -887,20 +940,23 @@ get_spec() { unset GIT_WORK_TREE git clone -o $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git || { # softfail if new package, i.e not yet added to PLD rep - [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo + [ ! -f "$PACKAGE_DIR/$SPECFILE" ] && Exit_error err_no_spec_in_repo echo "Warning: package not in CVS - assuming new package" NOCVSSPEC="yes" } + git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} ) fi else - if [ ! -d "$ASSUMED_NAME/.git" ]; then - if [ ! -d "$ASSUMED_NAME" ]; then - mkdir $ASSUMED_NAME + if [ ! -d "$PACKAGE_DIR/.git" ]; then + if [ ! -d "$PACKAGE_DIR" ]; then + install -d $PACKAGE_DIR fi git init - git remote add $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git + git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git + git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' + git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} CVSTAG=${CVSTAG:-"master"} fi local refs='' @@ -919,43 +975,50 @@ get_spec() { # add default log format to .gitignore if it is relative to package dir if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then # substitute known "macros" to glob - local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g') + local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\|TARGET\),*,g') if [ "$logfile" ]; then cvsignore_df "$logfile" fi fi # create symlinks for tools - if [ "$SYMLINK_TOOLS" != "no" ]; then - for a in dropin md5 adapter builder {relup,compile,repackage,pearize}.sh pldnotify.awk; do + if [ "$SYMLINK_TOOLS" != "no" -a -d "$PACKAGE_DIR" ]; then + for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do # skip tools that don't exist in top dir [ -f $a ] || continue # skip tools that already exist - [ -f $ASSUMED_NAME/$a ] && continue - ln -s ../$a $ASSUMED_NAME + [ -f $PACKAGE_DIR/$a ] && continue + ln -s ../$a $PACKAGE_DIR cvsignore_df $a done fi fi if [ -n "$CVSTAG" ]; then - git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit - git symbolic-ref -q HEAD > /dev/null && - git merge '@{u}' + if git rev-parse --verify -q "$CVSTAG"; then + git checkout "$CVSTAG" -- + elif git rev-parse --verify -q "refs/remotes/${REMOTE_PLD}/$CVSTAG"; then + git checkout -t "refs/remotes/${REMOTE_PLD}/$CVSTAG" > /dev/null + fi + if [ $(git rev-parse "$CVSTAG") != $(git rev-parse HEAD) ]; then + Exit_error "err_no_checkut" "$CVSTAG" + fi + git merge --ff-only '@{u}' + git symbolic-ref -q HEAD > /dev/null && [ "$NOCVSSPEC" != "yes" ] && if [ -n "$CVSDATE" ]; then git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1 fi fi - if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then + if [ ! -f "$PACKAGE_DIR/$SPECFILE" ]; then Exit_error err_no_spec_in_repo fi if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then - chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE + chmod $CHMOD_MODE $PACKAGE_DIR/$SPECFILE fi unset OPTIONS - [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE + [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $PACKAGE_DIR/$SPECFILE set_spec_target } @@ -964,7 +1027,7 @@ find_mirror() { cd "$REPO_DIR" local url="$1" if [ ! -f "mirrors" ] ; then - ln -s rpm-build-tools/mirrors . + ln -s ../rpm-build-tools/mirrors . fi IFS="|" @@ -1004,15 +1067,16 @@ src_md5() { cd $PACKAGE_DIR local md5 - if [ -f additional-md5sums ]; then - md5=$(grep -s -v '^#' additional-md5sums | \ - grep -E "[ ]$(basename "$1")([ ,]|\$)" | \ + # use "sources" file from package dir, like vim + if [ -f sources ]; then + md5=$(grep -s -v '^#' sources | \ + grep -E "[ *]$(basename "$1")([ ,]|\$)" | \ sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \ grep -E '^[0-9a-f]{32}$') if [ "$md5" ]; then if [ $(echo "$md5" | wc -l) != 1 ] ; then - echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2 + echo "$SPECFILE: more then one entry in sources for $1" 1>&2 fi echo "$md5" | tail -n 1 return @@ -1227,10 +1291,6 @@ get_files() { update_shell_title "${GETLOCAL%% *}: $url" ${GETLOCAL} $url $target else - if [ -z "$NOMIRRORS" ]; then - url=$(find_mirror "$url") - fi - local uri=${url} # make shorter message for distfiles urls if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then @@ -1253,9 +1313,6 @@ get_files() { update_shell_title "${GETLOCAL%% *}: $url_attic" ${GETLOCAL} $url_attic $target else - if [ -z "$NOMIRRORS" ]; then - url_attic=$(find_mirror "$url_attic") - fi update_shell_title "${GETURI%% *}: $url_attic" ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then @@ -1340,14 +1397,20 @@ get_files() { } tag_exist() { +# If tag exists and points to other commit exit with error +# If it existsts and points to HEAD return 1 +# If it doesn't exist return 0 local _tag="$1" + local sha1=$(git rev-parse HEAD) echo "Searching for tag $_tag..." if [ -n "$DEPTH" ]; then - local ref=`git ls-remote $REMOTE_PLD "refs/tags/$_tag"` - [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$_tag" + local ref=$(git ls-remote $REMOTE_PLD "refs/tags/$_tag" | cut -c -40) else - git show-ref "refs/tags/$_tag" && Exit_error err_tag_exists "$_tag" + local ref=$(git show-ref -s "refs/tags/$_tag") fi + [ -z "$ref" ] && return 0 + [ "$ref" = "$sha1" ] || Exit_error err_tag_exists "$_tag" + return 1 } make_tagver() { @@ -1376,8 +1439,6 @@ make_tagver() { } tag_files() { - TAG_FILES="$@" - if [ -n "$DEBUG" ]; then set -x set -v @@ -1386,33 +1447,25 @@ tag_files() { echo "Version: $PACKAGE_VERSION" echo "Release: $PACKAGE_RELEASE" - local TAGVER + local _tag if [ "$TAG_VERSION" = "yes" ]; then - TAGVER=`make_tagver` - echo "tag: $TAGVER" + _tag=`make_tagver` fi if [ -n "$TAG" ]; then - echo "tag: $TAG" + _tag="$TAG" fi + echo "tag: $_tag" local OPTIONS="tag $CVS_FORCE" - local _tag=$TAG - if [ "$TAG_VERSION" = "yes" ]; then - _tag=$TAGVER - fi; - cd "$PACKAGE_DIR" - if [ "$TAG_VERSION" = "yes" ]; then - update_shell_title "tag sources: $TAGVER" - git $OPTIONS $TAGVER || exit - git push $CVS_FORCE $REMOTE_PLD tag $TAGVER || Exit_error err_remote_problem $REMOTE_PLD - fi - if [ -n "$TAG" ]; then - update_shell_title "tag sources: $TAG" - git $OPTIONS $TAG $chunk || exit - git push $CVS_FORCE $REMOTE_PLD tag $TAG || Exit_error err_remote_problem $REMOTE_PLD + if tag_exist $_tag || [ -n "$CVS_FORCE" ]; then + update_shell_title "tag sources: $_tag" + git $OPTIONS $_tag || exit + git push $CVS_FORCE $REMOTE_PLD tag $_tag || Exit_error err_remote_problem $REMOTE_PLD + else + echo "Tag $_tag already exists and points to the same commit" fi } @@ -1549,36 +1602,34 @@ build_package() { esac update_shell_title "build_package: $COMMAND" + local logfile retval if [ -n "$LOGFILE" ]; then - LOG=`eval echo $LOGFILE` - if [ -d "$LOG" ]; then - echo "Log file $LOG is a directory." + logfile=`eval echo $LOGFILE` + if [ -d "$logfile" ]; then + echo "Log file $logfile is a directory." echo "Parse error in the spec?" Exit_error err_build_fail fi if [ -n "$LASTLOG_FILE" ]; then - echo "LASTLOG=$LOG" > $LASTLOG_FILE + echo "LASTLOG=$logfile" > $LASTLOG_FILE fi - RES_FILE=$(tempfile) - local specdir=$(insert_gitlog $SPECFILE) - - (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG - RETVAL=`cat $RES_FILE` - rm -r $RES_FILE $specdir - if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then - if [ "$RETVAL" -eq "0" ]; then - mv $LOG $LOGDIROK - else - mv $LOG $LOGDIRFAIL - fi + fi + + local specdir=$(insert_gitlog $SPECFILE) + # FIXME: eval here is exactly why? + PATH=$CLEAN_PATH eval teeboth "'$logfile'" ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE + retval=$? + rm -r $specdir + + if [ -n "$logfile" ] && [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then + if [ "$retval" -eq "0" ]; then + mv $logfile $LOGDIROK + else + mv $logfile $LOGDIRFAIL fi - else - local specdir=$(insert_gitlog $SPECFILE) - eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE - RETVAL=$? - rm -r $specdir fi - if [ "$RETVAL" -ne "0" ]; then + + if [ "$retval" -ne "0" ]; then if [ -n "$TRY_UPGRADE" ]; then echo "\nUpgrade package to new version failed." if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then @@ -1809,7 +1860,7 @@ display_bconds() { display_branches() { echo -n "Available branches: " - git branch -r | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs + git branch -r 2>/dev/null | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs } # checks a given list of packages/files/provides agains current rpmdb. @@ -2061,9 +2112,13 @@ init_rpm_dir() { if [ ! -e ../rpm-build-tools ]; then git clone ${GIT_SERVER}/${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools fi - for a in adapter builder; do - ln -s ../rpm-build-tools/${a}.sh $a + for a in adapter builder fetchsrc_request compile repackage; do + ln -sf ../rpm-build-tools/${a}.sh $a + done + for a in md5; do + ln -sf ../rpm-build-tools/${a} $a done + ln -sf ../rpm-build-tools/mirrors mirrors init_builder } @@ -2073,7 +2128,7 @@ mr_proper() { DONT_PRINT_REVISION="yes" # remove spec and sources - $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE + PATH=$CLEAN_PATH $RPMBUILD --clean --rmsource --rmspec --nodeps --define "__urlgetfile() %nil" --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE rm -rf $PACKAGE_DIR/{.git,.gitignore} rmdir --ignore-fail-on-non-empty $PACKAGE_DIR } @@ -2199,7 +2254,7 @@ while [ $# -gt 0 ]; do -pm | --prefer-mirrors ) PREFMIRRORS="yes" shift;; - --no-init ) + --noinit | --no-init ) NOINIT="yes" shift;; --opts ) @@ -2524,12 +2579,15 @@ case "$COMMAND" in # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt if [ -n "$TEST_TAG" ]; then local TAGVER=`make_tagver` - tag_exist $TAGVER + tag_exist $TAGVER || [ $TAGVER = $CVSTAG ] || Exit_error err_tag_exists $TAGVER # check also tags created in CVS - tag_exist $(echo $TAGVER | tr '[.@]' '[_#]') + local TAGVER_CVS=$(echo $TAGVER | tr '[.@]' '[_#]') + local CVSTAG_CVS=$(echo $CVSTAG | tr '[.@]' '[_#]') + tag_exist $TAGVER_CVS || [ $TAGVER_CVS = $CVSTAG_CVS ] \ + || Exit_error err_tag_exists $TAGVER_CVS # - do not allow to build from HEAD when XX-branch exists TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto/\([a-zA-Z]\+\)/.*#\1#g') - if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then + if [ "$TAGVER" != "$CVSTAG" -a "$TAGVER_CVS" != "$CVSTAG" -a "$TREE_PREFIX" != "$TAG_PREFIX" ]; then TAG_BRANCH="${TREE_PREFIX}-branch" if [ -n "$DEPTH" ]; then cmd_branches="git ls-remote --heads" @@ -2538,8 +2596,8 @@ case "$COMMAND" in cmd_branches="git show-ref" ref_prefix=refs/remotes/${REMOTE_PLD} fi - TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$") - if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then + TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$" | cut -c'-40') + if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != $(git rev-parse "$CVSTAG") ]; then Exit_error err_branch_exists "$TAG_STATUS" fi fi @@ -2553,7 +2611,7 @@ case "$COMMAND" in case $? in 0) get_files $SOURCES $PATCHES - check_md5 $SOURCES + check_md5 $SOURCES $PATCHES ;; *) NODIST="yes" get_files $SOURCES $PATCHES @@ -2594,8 +2652,7 @@ case "$COMMAND" in fi done git add $SPECFILE - git commit -m 'Initial commit' - git push --dry-run $REMOTE_PLD master || Exit_error err_cvs_add_failed + echo "When you are ready commit your changes and run git push origin master" else echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}" fi @@ -2658,13 +2715,13 @@ case "$COMMAND" in done ;; "list-sources-urls" ) - init_builder + init_builder >&2 NOCVSSPEC="yes" DONT_PRINT_REVISION="yes" - get_spec - parse_spec + get_spec >&2 + parse_spec >&2 SAPS="$SOURCES $PATCHES" - for SAP in $SAPS ; do + for SAP in $SAPS; do echo $SAP done ;; diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..8aa5607 --- /dev/null +++ b/compile.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# will build package, skipping %prep and %build stage +# i use it a lot! +# +# Usage: +# make only %build stage (i.e. after %prep has been done), for example after +# modifying some sources for more complicated specs whose %build is not just +# %{__make}: +# SPECS$ ./compile.sh kdelibs.spec +# +# See also: SPECS/repackage.sh +# +# -glen 2005-03-03 + +dir=$(dirname "$0") +if [ $# = 0 ]; then + # if no spec name passed, glob *.spec + set -- *.spec + if [ ! -f "$1" -o $# -gt 1 ]; then + echo >&2 "ERROR: Too many or too few .spec files found" + echo >&2 "Usage: ${0##*/} PACKAGE.spec" + exit 1 + fi +fi +exec $dir/builder --no-md5 -ncs -nn --short-circuit -bc "$@" diff --git a/fetchsrc_request b/fetchsrc_request.sh similarity index 74% rename from fetchsrc_request rename to fetchsrc_request.sh index adad881..8d3e5e2 100755 --- a/fetchsrc_request +++ b/fetchsrc_request.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: fetchsrc_request,v 1.22 2010/01/16 17:29:11 sparky Exp $ +# $Id$ # # Sending by MAILER='/usr/sbin/sendmail' @@ -16,12 +16,13 @@ VIA_ARGS="" DMAIL="df@tld-linux.org" # # CVS LOGIN or fill it by hand :) -#tmp=$(awk -F: '{ print $3; }' CVS/Root) -#LOGIN=${tmp%@*} -#LOGIN="lisu" +tmp=$(git config user.email) +LOGIN=${tmp%@*} +#LOGIN="djrzulf" # # HOST HOST=`hostname -f` +#HOST="knycz.net" # # functions @@ -37,19 +38,16 @@ if [ "$#" = 0 ]; then usage exit 1 fi -if [ "$LOGIN" == "cvs" ]; then - echo "Use fetchsrc_request from your R/W CVS tree or set LOGIN by hand" >&2 - exit 1 -fi if [ "$2" != "" ]; then BRANCH="$2" else - BRANCH="HEAD" + BRANCH="refs/heads/master" fi -SPEC="$(basename $1)" -if [[ "$SPEC" != *.spec ]]; then - SPEC="$SPEC.spec" +if [[ "$BRANCH" != refs/* ]]; then + BRANCH="refs/heads/$BRANCH" fi +SPEC="$(basename $1)" +SPEC=${SPEC%.spec} if [ "$VIA" = "SENDMAIL" ]; then echo >&2 "Requesting $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}" @@ -57,10 +55,9 @@ if [ "$VIA" = "SENDMAIL" ]; then To: $DMAIL From: $LOGIN <$LOGIN@$HOST> Subject: fetchsrc_request notify -X-CVS-Module: SPECS X-distfiles-request: yes X-Login: $LOGIN -X-Spec: $SPEC +X-Package: $SPEC X-Branch: $BRANCH X-Flags: force-reply @@ -75,10 +72,9 @@ RCPT TO: $DMAIL DATA To: $DMAIL Subject: fetchsrc_request notify -X-CVS-Module: SPECS X-distfiles-request: yes X-Login: $LOGIN -X-Spec: $SPEC +X-Package: $SPEC X-Branch: $BRANCH X-Flags: force-reply diff --git a/pldnotify.awk b/pldnotify.awk old mode 100644 new mode 100755 index 11cff98..d6192e7 --- a/pldnotify.awk +++ b/pldnotify.awk @@ -1,7 +1,6 @@ #!/bin/awk -f -# $Revision$, $Date$ # -# Copyright (C) 2000-2011 PLD-Team +# Copyright (C) 2000-2013 PLD-Team # Authors: # Sebastian Zagrodzki # Jacek Konieczny @@ -16,6 +15,18 @@ # - "SourceXActiveFTP" support # - support debian/watch http://wiki.debian.org/debian/watch/ +# NOTE: +# to test run this, run: +# $ awk -vDEBUG=1 pldnotify.awk < specfile +# +# To get full out of it, you need to have following tools installed: +# - perl, sed, wget, coreutils, util-linux +# - perl-HTML-Tree (HTML::TreeBuilder module) for better links parser (-vUSE_PERL=0 to disable) +# - pear (php-pear-PEAR) for php-pear package updates +# - npm for nodejs packages +# - gem (ruby-rubygems) for ruby/rubygem packages +# +# Additionally "mirrors" file in current dir, controls local mirrors you prefer function d(s) { if (!DEBUG) { @@ -267,6 +278,17 @@ function get_links(url,filename, errno,link,oneline,retval,odp,wholeodp,lowero d("github tarball url, mungled url to: " url) } + if (url ~/^(http|https):\/\/github.com\/.*\/(.*)\/archive\//) { + gsub("\/archive\/.*", "/tags", url) + d("github archive url, mungled url to: " url) + } + + # https://bitbucket.org/logilab/pylint/get/tip.tar.bz2 -> https://bitbucket.org/logilab/pylint/downloads + if (url ~/^(http|https):\/\/bitbucket.org\/.*\/get\/.*/) { + gsub("\/get\/.*", "/downloads", url) + d("github bitbucket url, mungled url to: " url) + } + if (url ~/^(http|https):\/\/cgit\..*\/(.*)\/snapshot\//) { gsub("\/snapshot\/.*", "/", url) d("cgit snapshot tarball url, mungled url to: " url) @@ -277,6 +299,21 @@ function get_links(url,filename, errno,link,oneline,retval,odp,wholeodp,lowero d("aquamaniac.de tarball url, mungled url to: " url) } + if (url ~/^(http|https):\/\/www.process-one.net\/downloads\/ejabberd\//) { + url = "http://www.process-one.net/en/ejabberd/archive/" + d("ejabberd tarball url, mungled url to: " url) + } + + if (url ~/^(http|https):\/\/llvm.org\/releases\//) { + url = "http://llvm.org/releases/download.html" + d("llvm tarball url, mungled url to: " url) + } + + if (url ~/^(http|https):\/\/download\.owncloud\.org\/community\//) { + url = "http://owncloud.org/changelog/" + d("owncloud tarball url, mungled url to: " url) + } + d("Retrieving: " url) user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100129 PLD/3.0 (Th) Iceweasel/3.6" cmd = "wget -t 2 -T 45 --user-agent \"" user_agent "\" -nv -O - \"" url "\" --passive-ftp --no-check-certificate > " tmpfile " 2> " tmpfileerr @@ -378,7 +415,12 @@ if (USE_PERL) { continue } - retval = (retval " " link) + # link ends with at least 2 digit version + mlink = "" + if (link ~ /^.*\/[v]*[0-9\.]+[0-9]\/$/) + mlink = get_links(link) + + retval = (retval " " link " " mlink) d("href(\"\"): " link) } else if (lowerodp ~ /href=[ \t]*'[^']*'/) { sub(/[hH][rR][eE][fF]=[ \t]*'/,"href='",odp) @@ -460,8 +502,8 @@ function find_mirror(url) { return url } -function process_source(number, lurl, name, version) { # fetches file list, and compares version numbers +function process_source(number, lurl, name, version) { d("Processing " lurl) if (index(lurl, version) == 0) { @@ -494,6 +536,7 @@ function process_source(number, lurl, name, version) { gsub("[+]","\\+",filenameexp) sub(version,"[A-Za-z0-9.]+",filenameexp) gsub("[.]","\\.",filenameexp) + sub("\.(bz|bz2|gz|lzma|xz|zip)$",".(bz|bz2|gz|lzma|xz|zip)",filenameexp) d("Expression: " filenameexp) match(filename,version) prever=substr(filename,1,RSTART-1) @@ -557,83 +600,126 @@ function process_source(number, lurl, name, version) { } } -function rss_upgrade(name, ver, url, regex, cmd, nver) { +function rss_upgrade(name, ver, url, regex, cmd) { regex = "s/.*" regex "<\/title>.*/\\1/p" cmd = "wget -t 2 -T 45 -q -O - " url " | sed -nre '" regex "' | head -n1" d("rss_upgrade_cmd: " cmd) - cmd | getline nver + cmd | getline ver close(cmd) - if (compare_ver(ver, nver)) { - print name " [OLD] " ver " [NEW] " nver - } else { - print name " seems ok: " ver - } + return ver } # check for ZF upgrade from rss function zf_upgrade(name, ver) { - rss_upgrade(name, ver, \ + return rss_upgrade(name, ver, \ "http://devzone.zend.com/tag/Zend_Framework_Management/format/rss2.0", \ "Zend Framework ([^\\s]+) Released" \ ); } function hudson_upgrade(name, ver) { - rss_upgrade(name, ver, \ + return rss_upgrade(name, ver, \ "https://hudson.dev.java.net/servlets/ProjectRSS?type=news", \ "Hudson ([0-9.]+) released" \ ); } # upgrade check for pear package using PEAR CLI -function pear_upgrade(name, ver, pname, pearcmd, nver) { - pname = name; - sub(/^php-pear-/, "", pname); +function pear_upgrade(name, ver, cmd) { + sub(/^php-pear-/, "", name); - pearcmd = "pear remote-info " pname " | awk '/^Latest/{print $NF}'" - d("pearcmd: " pearcmd) - pearcmd | getline nver - close(pearcmd) + cmd = "pear remote-info " name " | awk '/^Latest/{print $NF}'" + d("PEAR: " cmd) + cmd | getline ver + close(cmd) + + return ver +} - if (compare_ver(ver, nver)) { - print name " [OLD] " ver " [NEW] " nver +function vim_upgrade(name, ver, cmd) { + # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.2/7.2.%03g 1 %{patchlevel} + cmd = "wget -q -O - ftp://ftp.vim.org/pub/editors/vim/patches/" DEFS["ver"] "/MD5SUMS|grep -vF .gz|tail -n1|awk '{print $2}'" + d("VIM: " cmd) + cmd | getline ver + close(cmd) + return ver +} + +function nodejs_upgrade(name, ver, cmd) { + d("NODEJS " name " (as " DEFS["pkg"] ") " ver); + if (DEFS["pkg"]) { + cmd = "npm info " DEFS["pkg"] " dist-tags.latest" } else { - print name " seems ok: " ver + cmd = "npm info " name " dist-tags.latest" } + cmd | getline ver + close(cmd) - return + return ver } -function vim_upgrade(name, ver, mver, nver, vimcmd) { - # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.2/7.2.%03g 1 %{patchlevel} - mver = substr(ver, 0, 4) - vimcmd = "wget -q -O - ftp://ftp.vim.org/pub/editors/vim/patches/"mver"/MD5SUMS|grep -vF .gz|tail -n1|awk '{print $2}'" - d("vimcmd: " vimcmd) - vimcmd | getline nver - close(vimcmd) - - if (compare_ver(ver, nver)) { - print name " [OLD] " ver " [NEW] " nver +function rubygem_upgrade(name, ver, cmd, pkg) { + if (DEFS["gem_name"]) { + pkg = DEFS["gem_name"]; + + } else if (DEFS["gemname"]) { + pkg = DEFS["gemname"]; + + } else if (DEFS["pkgname"]) { + pkg = DEFS["pkgname"]; + } else { - print name " seems ok: " ver + pkg = name; + gsub(/^ruby-/, "", pkg); } + + cmd = "gem list --remote '^" pkg "$' | awk '/" pkg "/ {v=$2; sub(/\(/, \"\", v); print v}'" + d("RUBYGEM " name " (as " pkg ") " ver ": " cmd); + cmd | getline ver + + close(cmd) + + return ver } -function process_data(name, ver, rel, src) { +function chrome_upgrade(name, ver, cmd, sourceurl) { + sourceurl = "http://dl.google.com/linux/chrome/rpm/stable/x86_64/repodata/primary.xml.gz" + cmd = "curl -s " sourceurl " | zcat | perl -ne 'm{<name>google-chrome-" DEFS["state"] "</name>} and m{<version .*ver=.([\d.]+)} and print $1'" + d("CHROME " cmd); + cmd | getline ver + close(cmd) + + return ver +} + +function process_data(name, ver, rel, src, nver) { if (name ~ /^php-pear-/) { - return pear_upgrade(name, ver); - } - if (name == "ZendFramework") { - return zf_upgrade(name, ver); - } - if (name == "hudson") { - return hudson_upgrade(name, ver); - } - if (name == "vim") { - return vim_upgrade(name, ver); + nver = pear_upgrade(name, ver); + } else if (name == "ZendFramework") { + nver = zf_upgrade(name, ver); + } else if (name == "hudson") { + nver = hudson_upgrade(name, ver); + } else if (name == "vim") { + nver = vim_upgrade(name, ver); + } else if (name == "google-chrome") { + nver = chrome_upgrade(name, ver); + } else if (name ~ "^nodejs-") { + nver = nodejs_upgrade(name, ver); + } else if (name ~ "^ruby-") { + nver = rubygem_upgrade(name, ver); + } + + if (nver) { + if (compare_ver(ver, nver)) { + print name " [OLD] " ver " [NEW] " nver + } else { + print name " seems ok: " ver + } + return; } + if (name == "xulrunner") { ver = subst_defines(DEFS["firefox_ver"], DEFS) d("package xulrunner, change version to firefox ["ver"]") @@ -655,7 +741,7 @@ function process_data(name, ver, rel, src) { } BEGIN { - # if U want to use DEBUG, run script with "-v DEBUG=1" + # if you want to use DEBUG, run script with "-v DEBUG=1" # or uncomment the line below # DEBUG = 1 @@ -687,6 +773,7 @@ FNR==1 { FNAME=FILENAME DEFS["_alt_kernel"]="" DEFS["20"]="\\ " + DEFS["nil"]="" } /^[Uu][Rr][Ll]:/&&(URL=="") { URL=subst_defines($2,DEFS) ; DEFS["url"]=URL } diff --git a/relup.sh b/relup.sh index 6426218..9a07402 100755 --- a/relup.sh +++ b/relup.sh @@ -17,13 +17,15 @@ get_dump() { } usage="Usage: -${0##*/} [-i] [-u] [-t] [-n] [-m <MESSAGE>] <SPECLIST> +${0##*/} [-i] [-g] [-u] [-t|-n] [-m <MESSAGE>] <SPECLIST> Options: -i Try to increment package release +-g + get packages if missing, do nothing else -u - git pull first + update packages (git pull) -t | -n Test mode (dry-run). do not commit -m @@ -51,12 +53,44 @@ set_release() { " $specfile } +bump_release() { + local release=$1 rel + + rel=$(expr ${release} + 1) + echo $rel +} + +# normalize spec +# takes as input: +# - PACKAGE/ +# - ./PACKAGE/ +# - PACKAGE +# - PACKAGE.spec +# - ./PACKAGE.spec +# - PACKAGE/PACKAGE +# - PACKAGE/PACKAGE.spec +# - ./PACKAGE/PACKAGE.spec +# - rpm/PACKAGE/PACKAGE +# - rpm/PACKAGE/PACKAGE.spec +# - ./rpm/PACKAGE/PACKAGE.spec +# returns PACKAGE +package_name() { + local specfile="${1%/}" package + + # basename + specfile=${specfile##*/} + # strip .spec + package=${specfile%.spec} + + echo $package +} + if [ ! -x /usr/bin/getopt ]; then echo >&1 "You need to install util-linux to use relup.sh" exit 1 fi -t=$(getopt -o 'm:inuth' -n "${0##*/}" -- "$@") || exit $? +t=$(getopt -o 'm:inguth' -n "${0##*/}" -- "$@") || exit $? # Note the quotes around `$t': they are essential! eval set -- "$t" @@ -68,6 +102,9 @@ while true; do -u) update=1 ;; + -g) + get=1 + ;; -t | -n) test=1 ;; @@ -91,49 +128,63 @@ while true; do shift done -tmpd=$(mktemp -d "${TMPDIR:-/tmp}/relXXXXXX") topdir=$(rpm -E '%{_topdir}') + +n="$(echo -e '\nn')" +n="${n%%n}" + cd "$topdir" for pkg in "$@"; do - name=${pkg%.spec} name=${name##*/} - spec=$(rpm -D "name $name" -E '%{_specdir}/%{name}.spec') + # pkg: package %{name} + pkg=$(package_name "$pkg") + + # spec: package/package.spec + spec=$(rpm -D "name $pkg" -E '%{_specdir}/%{name}.spec') spec=${spec#$topdir/} - if [ "$update" = "1" ]; then + + # pkgdir: package/ + pkgdir=${spec%/*} + + # specname: only spec filename + specname=${spec##*/} + + # start real work + echo "$pkg ..." + + # get package + [ "$get" = 1 -a -d "$pkgdir" ] && continue + + if [ "$update" = "1" -o "$get" = "1" ]; then ./builder -g -ns "$spec" fi + + [ "$get" = 1 ] && continue + + # update .spec files rel=$(get_release "$spec") if [ "$inc" = 1 ]; then if [[ $rel = *%* ]]; then relmacro=${rel#*%} - relnum=${rel%%%*} - newrel=$(expr ${relnum} + 1) + newrel=$(bump_release ${rel%%%*}) set_release "$spec" $rel "${newrel}%${relmacro}" else - newrel=$(expr ${rel} + 1) + newrel=$(bump_release ${rel}) set_release "$spec" $rel $newrel fi # refetch release rel=$(get_release "$spec") fi - echo "$spec" >> "$tmpd/$rel" -done -n="$(echo -e '\nn')" -n="${n%%n}" -for file in $(ls "$tmpd" 2>/dev/null); do - files=$(cat "$tmpd/$file") - pkg=$(cat "$tmpd/$file" |sed -e 's|/.*||') - spec=$(cat "$tmpd/$file" |sed -e 's|.*/||') - rel=$(basename "$file") + # commit the changes msg="" [ -n "$message" ] && msg="$msg- $message$n" - msg="$msg- release ${rel%%%*} (by relup.sh)$n" + msg="$msg- release ${rel%%%*} (by relup.sh)" + echo git commit -m "$msg" $spec if [ "$test" != 1 ]; then - cd $pkg - git commit -m "$msg" $spec + cd $pkgdir + git commit -m "$msg" $specname git push cd .. fi done -rm -rf $tmpd diff --git a/repackage.sh b/repackage.sh new file mode 100755 index 0000000..5dfe9c3 --- /dev/null +++ b/repackage.sh @@ -0,0 +1,140 @@ +#!/bin/sh +# will build package, skipping %prep and %build stage +# i use it a lot! +# +# -glen 2005-03-03 +# +# Usage: +# do %install and rpm package, skips %clean +# SPECS$ ./repackage.sh kdelibs.spec +# +# after that is done you could try only package creation (as %clean was +# skipped), for adjusting %files lists: +# SPECS$ ./repackage.sh kdelibs.spec -bb +# +# See also: SPECS/compile.sh +# +# TODO +# - make builder to understand -bi and use builder for short-circuit + +set -e + +skip_dep_generators() { + local dep + for dep in \ + font \ + gstreamer \ + java \ + kernel \ + libtool \ + mimetype \ + mono \ + perl \ + php \ + pkgconfig \ + python \ + ruby \ + ; do + printf "--define __%s_provides%%{nil}\n" $dep + printf "--define __%s_requires%%{nil}\n" $dep + done +} + +rpmbuild() { + # preprocess args, we must have --target as first arg to rpmbuild + # we need to grab also dir where spec resides + local a spec specdir + while [ $# -gt 0 ]; do + case "$1" in + --target) + shift + TARGET=$1 + ;; + *.spec) + spec="$1" + a="$a $1" + ;; + *) + a="$a $1" + ;; + esac + shift + done + + specdir=$(dirname "$(pwd)/${spec:-.}") + + # use gz payload as time is what we need here, not compress ratio + + # we use %__ldconfig variable to test are we on rpm 4.4.9 + # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead + # on 4.4.2 we must redefine %clean to contain %clean + set -x + /usr/bin/rpmbuild \ + ${TARGET:+--target $TARGET} \ + --short-circuit \ + --define "_specdir $specdir" --define "_sourcedir $specdir" \ + --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \ + exit 0%{nil}' \ + --define 'check %%check \ + exit 0%{nil}' \ + --define '_source_payload w5.gzdio' \ + --define '_binary_payload w5.gzdio' \ + --define '__spec_install_pre %___build_pre' \ + --define '__spec_clean_body %{nil}' \ + --define '_enable_debug_packages 0' \ + ${bb+$(skip_dep_generators)} \ + ${bb+--define '%py_postclean() %{nil}'} \ + $a || exit +} + +specdump() { + local a + while [ $# -gt 0 ]; do + case "$1" in + --target|--with|--without) + a="$a $1 $2" + shift + ;; + --define) + a="$a $1 \"$2\"" + shift + ;; + -*) + ;; + *) + a="$a $1" + ;; + esac + shift + done + set -x + eval rpm-specdump $a || echo >&2 $? +} + +if [ $# = 0 ]; then + # if no spec name passed, glob *.spec + set -- *.spec + if [ ! -f "$1" -o $# -gt 1 ]; then + echo >&2 "ERROR: Too many or too few .spec files found" + echo >&2 "Usage: ${0##*/} PACKAGE.spec" + exit 1 + fi +else + # $1 must be spec, ensure it has .spec ext + spec=$1; shift + set -- ${spec%.spec}.spec "$@" +fi + +tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}') +if [ "$tmp" ]; then + TARGET="$tmp" +fi + +# skip -bi if -bb is somewhere in the args +if [[ *$@* = *-bb* ]]; then + bb= +else + bb= rpmbuild -bi "$@" + unset bb +fi +rpmbuild -bb "$@" diff --git a/rpm-build-tools.spec b/rpm-build-tools.spec index 3a58603..948c0bd 100644 --- a/rpm-build-tools.spec +++ b/rpm-build-tools.spec @@ -6,7 +6,7 @@ Summary(ru.UTF-8): Скрипты и утилиты, необходимые дл Summary(uk.UTF-8): Скрипти та утиліти, необхідні для побудови пакетів Name: rpm-build-tools Version: 4.5 -Release: 2 +Release: 10 License: GPL Group: Applications/File Group: Base @@ -17,6 +17,7 @@ Source3: pldnotify.awk Source4: shrc.sh BuildRequires: sed >= 4.0 Requires: gawk >= 3.1.7 +Requires: git-core >= 1.7 Requires: grep Requires: less Requires: perl-base @@ -25,11 +26,10 @@ Requires: rpmbuild(macros) >= 1.539 Requires: sed >= 4.0 Requires: util-linux Requires: wget -Suggests: git-core >= 1.7 Suggests: rpm-specdump >= 0.3 Suggests: schedtool Suggests: vim-syntax-spec -Conflicts: git-core < 1.7 +Conflicts: mktemp < 1.6 BuildArch: noarch BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) diff --git a/shrc.sh b/shrc.sh index 1c39f00..8e36984 100755 --- a/shrc.sh +++ b/shrc.sh @@ -37,7 +37,7 @@ ac-tag() { fi git tag -f $branch - git push origin $branch + git push -f origin $branch } # undo spec utf8 @@ -192,7 +192,7 @@ get-buildlog() { fi # no $dist set alias adif="dif -x '*.m4' -x ltmain.sh -x install-sh -x depcomp -x 'Makefile.in' -x compile -x 'config.*' -x configure -x missing -x mkinstalldirs -x autom4te.cache" -alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'" +alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Tylko\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'" # makes diff from PLD CVS urls # requires: cvs, tee diff --git a/teeboth b/teeboth new file mode 100755 index 0000000..5c3f5c0 --- /dev/null +++ b/teeboth @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Fcntl; +use POSIX ":sys_wait_h"; +use IPC::Open3; +use IO::Handle; +use IO::Select; + +my $out = shift @ARGV; +die unless @ARGV; + +open my $fout, ">>", $out or die "Can't write to $out: $!" if $out; + +my $select = IO::Select->new(); +my $alive = 1; +my $pid; +my $interactive = -t STDOUT; + +my $code; +sub sigchld +{ + my $kid; + do { + $kid = waitpid( -1, WNOHANG ); + if ( $kid == $pid ) { + $code = $? >> 8; + $alive = 0 + } + } while ( $kid > 0 ); +} +$SIG{CHLD} = \&sigchld; + +$pid = open3( "<&STDIN", \*child_out, \*child_err, @ARGV ); + +sub sethandle +{ + my $h = shift; + my $flags = 0; + + fcntl ( $h, F_GETFL, $flags ) + or die "Couldn't get flags for HANDLE : $!\n"; + $flags |= O_NONBLOCK; + fcntl ( $h, F_SETFL, $flags ) + or die "Couldn't set flags for HANDLE: $!\n"; + + $select->add( $h ); +} + +sethandle( \*child_out ); +sethandle( \*child_err ); + +while ( $alive ) { + foreach my $h ( $select->can_read() ) { + sysread $h, $_, 1024; + print $fout $_ if $fout; + if ( $interactive && $h == \*child_err ) { + print "\033[31m$_\033[0m"; + } else { + print $_; + } + STDOUT->flush(); + } +} + +exit $code;