diff -u mtop-0.6.6/debian/changelog mtop-0.6.6/debian/changelog --- mtop-0.6.6/debian/changelog +++ mtop-0.6.6/debian/changelog @@ -1,3 +1,19 @@ +mtop (0.6.6-1.2ubuntu3) intrepid; urgency=low + + * New feature --local for mkill and mtop (to use /etc/mysql/debian.cnf) + - Depend on libconfig-ini-simple-perl + * Removed --idle option from mkill's documentation (isn't implemented) + * Stripped create_user (postinst) because it was broken. There was also + no need because mtop can be used non-local as well (LP: #77980) + * Removed 'Recommends: mysql-server'. Same reason + * Rewrote postrm + * Satisfy lintian + - Fixed debian-rules-ignores-make-clean-error + - Fixed debian-rules-sets-DH_COMPAT + - Bumped Standards-Version to 3.8.0 + + -- Patrick Kuijvenhoven Sun, 18 Jan 2009 12:01:14 +0100 + mtop (0.6.6-1.2) unstable; urgency=low * Non-maintainer upload to fix pending l10n issues. diff -u mtop-0.6.6/debian/mtop.postrm mtop-0.6.6/debian/mtop.postrm --- mtop-0.6.6/debian/mtop.postrm +++ mtop-0.6.6/debian/mtop.postrm @@ -5,60 +5,18 @@ set -e -get_config() -{ - db_get mtop/mysql_server - mysql_server="$RET" - db_get mtop/mysql_port - mysql_port="$RET" - db_get mtop/root - root_mysql="$RET" - db_get mtop/password - root_passwd="$RET" -} - -remove_user() -{ - ${mysqlcmd} -e " - CONNECT mysql; - delete from user where user=\"mysqltop\"; - delete from db where user=\"mysqltop\"; - flush privileges; - " -} - -# summary of how this script can be called: -# * `remove' -# * `purge' -# * `upgrade' -# * `failed-upgrade' -# * `abort-install' -# * `abort-install' -# * `abort-upgrade' -# * `disappear' overwrit>r> -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - case "$1" in purge|remove) - if [ -f /usr/share/debconf/confmodule ] && [ -f /usr/bin/mysql ]; then - . /usr/share/debconf/confmodule - db_version 2.0 - - get_config - password=`dd if=/dev/random bs=512 count=1 2> /dev/null| md5sum` - if [ "$root_passwd" != 'none' ]; then - mysqlpwd="-p${root_passwd}" - fi - mysqlcmd="mysql -h ${mysql_server} -P ${mysql_port} -u${root_mysql} ${mysqlpwd}" - if ${mysqlcmd} -B -e 'select user from user' mysql | grep -q "^mysqltop$" - then - remove_user; + if [ -f /usr/bin/mysql -a -f /etc/mysql/debian.cnf -a -f /usr/sbin/mysqld ]; then + # Former versions of mtop automaticly added a user to mysql + mysqlcmd="mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names -B -e " + hits=`${mysqlcmd} "SELECT COUNT(user) FROM user WHERE user='mysqltop'" mysql` + if [ $hits -gt 0 ]; then + echo "Removing user 'mysqltop'" + ${mysqlcmd} "DELETE FROM user WHERE user='mysqltop'; FLUSH PRIVILEGES" mysql fi fi - ;; upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) diff -u mtop-0.6.6/debian/mtop.postinst mtop-0.6.6/debian/mtop.postinst --- mtop-0.6.6/debian/mtop.postinst +++ mtop-0.6.6/debian/mtop.postinst @@ -5,64 +5,9 @@ set -e -get_config() -{ - db_get mtop/mysql_server - mysql_server="$RET" - db_get mtop/mysql_port - mysql_port="$RET" - db_get mtop/root - root_mysql="$RET" - db_get mtop/password - root_passwd="$RET" -} - -create_user() -{ - ${mysqlcmd} -e " - CONNECT mysql; - grant select on test.* to mysqltop; - grant select on test.* to mysqltop@localhost; - update user set process_priv='y' where user='mysqltop'; - flush privileges; -" -} - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see /usr/share/doc/packaging-manual/ -# -# quoting from the policy: -# Any necessary prompting should almost always be confined to the -# post-installation script, and should be protected with a conditional -# so that unnecessary prompting doesn't happen if a package's -# installation fails and the `postinst' is called with `abort-upgrade', -# `abort-remove' or `abort-deconfigure'. - case "$1" in configure) - # Source debconf library - . /usr/share/debconf/confmodule - db_version 2.0 - - get_config - password=`dd if=/dev/random bs=512 count=1 2> /dev/null| md5sum` - if [ "$root_passwd" != 'none' ]; then - mysqlpwd="-p${root_passwd}" - fi - mysqlcmd="mysql -h ${mysql_server} -P ${mysql_port} -u${root_mysql} ${mysqlpwd}" - if ${mysqlcmd} -B -e 'select user from user' mysql | grep -q "^mysqltop$" - then - echo "User already exists"; - else - create_user - fi + ;; abort-upgrade|abort-remove|abort-deconfigure) diff -u mtop-0.6.6/debian/rules mtop-0.6.6/debian/rules --- mtop-0.6.6/debian/rules +++ mtop-0.6.6/debian/rules @@ -1,8 +1,6 @@ #!/usr/bin/make -f #-*- makefile -*- -export DH_COMPAT=4 - PACKAGE=$(shell dh_listpackages) ifndef PERL @@ -26,7 +24,7 @@ dh_testdir dh_testroot rm -f build-stamp - -$(MAKE) realclean + [ ! -f Makefile ] || $(MAKE) realclean rm -f mkill mtop debconf-updatepo diff -u mtop-0.6.6/debian/control mtop-0.6.6/debian/control --- mtop-0.6.6/debian/control +++ mtop-0.6.6/debian/control @@ -3,14 +3,14 @@ Priority: optional Build-Depends: debhelper (>= 4.0.0), po-debconf Build-Depends-Indep: perl, libdbd-mysql-perl, libcurses-perl -Maintainer: Andrés Roldán +Maintainer: Ubuntu MOTU Developers +XSBC-Original-Maintainer: Andrés Roldán Uploaders: Luis Bustamante -Standards-Version: 3.6.1.0 +Standards-Version: 3.8.0 Package: mtop Architecture: all -Depends: ${perl:Depends}, debconf (>= 1.2.9) | debconf-2.0, libcurses-perl, libdbd-mysql-perl, libnet-perl, mysql-client -Recommends: mysql-server +Depends: ${perl:Depends}, debconf (>= 1.2.9) | debconf-2.0, libcurses-perl, libdbd-mysql-perl, libnet-perl, mysql-client, libconfig-ini-simple-perl Description: MySQL terminal based query monitor mtop (MySQL top) monitors a MySQL database showing the queries which are taking the most amount of time to complete. Features include only in patch2: unchanged: --- mtop-0.6.6.orig/mtop.PL +++ mtop-0.6.6/mtop.PL @@ -70,7 +70,7 @@ [--password={mysqluser_pw}] [--seconds={refresh}] [--[no]idle] [--filter-user={regex}] [--filter-host={regex}] [--filter-db={regex}] [--filter-command={regex}] [--filter-state={regex}] [--filter-info={{regex}}] - [--fold-select-columns] + [--fold-select-columns] [--[no]local] [--user={user}] [--manualrefresh] [--slow={seconds}] [--vs|veryslow={seconds}] [--vvs|veryveryslow={seconds}] @@ -268,6 +268,11 @@ By default, processes in the B command state are not shown. This option turns on display of idle threads. +=item --[no]local + +Will take the client credentials as specified in /etc/mysql/debian.cnf. +This file is only readable for root. + =item -u {user}, --user={user} Show only threads owned by this user. @@ -451,6 +456,8 @@ use constant NOECHO => 1; use constant DESC => 1; +my $debian_cnf = '/etc/mysql/debian.cnf'; + my $opt_host = ""; my $opt_dbport = ""; my $opt_dbsocket = ""; @@ -459,6 +466,7 @@ my $opt_seconds = 5; my $opt_idle = 0; my $opt_user; +my $opt_local = 0; my $opt_version; my $opt_help; my $opt_manualrefresh; @@ -549,6 +557,7 @@ 'help|?' => \$opt_help, 'manualrefresh' => \$opt_manualrefresh, 'idle!' => \$opt_idle, + 'local!' => \$opt_local, ) || usage(); $DEBUG = 1 if defined $DEBUG; @@ -1703,6 +1712,24 @@ my $db = shift; my %params = @_; + if($opt_local) { + print STDERR "Getting information from $debian_cnf\n" if $DEBUG; + die("Unable to open $debian_cnf, are you root?\n") if(! -r $debian_cnf); + require Config::INI::Simple; + my $conf = Config::INI::Simple->new(); + if($conf->read($debian_cnf) && + defined($conf->{'client'}->{'host'}) && + defined($conf->{'client'}->{'user'}) && + defined($conf->{'client'}->{'password'})) { + %params = ( 'hostname' => $conf->{'client'}->{'host'} ); + $opt_dbuser = $conf->{'client'}->{'user'}; + $opt_passwd = $conf->{'client'}->{'password'}; + } + else { + die("Unable to get required information from $debian_cnf\n"); + } + } + my $dsn_opts = get_dsnoptstr(%params); my $dbh; only in patch2: unchanged: --- mtop-0.6.6.orig/mkill.PL +++ mtop-0.6.6/mkill.PL @@ -282,12 +282,15 @@ use constant NOECHO => 1; use constant DESC => 1; +my $debian_cnf = '/etc/mysql/debian.cnf'; + my $opt_host = ""; my $opt_dbport = ""; my $opt_dbsocket = ""; my $opt_dbuser = "mysqltop"; my $opt_passwd = ""; my $opt_user; +my $opt_local = 0; my $opt_version; my $opt_test; my $opt_help; @@ -352,6 +355,7 @@ 'version' => \$opt_version, 'test' => \$opt_test, 'help|?' => \$opt_help, + 'local!' => \$opt_local, ) || usage(); $DEBUG = 1 if defined $DEBUG; @@ -516,6 +520,24 @@ my $db = shift; my %params = @_; + if($opt_local) { + print STDERR "Getting information from $debian_cnf\n" if $DEBUG; + die("Unable to open $debian_cnf, are you root?\n") if(! -r $debian_cnf); + require Config::INI::Simple; + my $conf = Config::INI::Simple->new(); + if($conf->read($debian_cnf) && + defined($conf->{'client'}->{'host'}) && + defined($conf->{'client'}->{'user'}) && + defined($conf->{'client'}->{'password'})) { + %params = ( 'hostname' => $conf->{'client'}->{'host'} ); + $opt_dbuser = $conf->{'client'}->{'user'}; + $opt_passwd = $conf->{'client'}->{'password'}; + } + else { + die("Unable to get required information from $debian_cnf\n"); + } + } + my $dsn_opts = get_dsnoptstr(%params); my $dbh; @@ -638,7 +660,7 @@ --host={mysql_host} Connect to the MySQL server on {mysql_host} --dbuser={mysql_user} Connect to the MySQL server as {mysql_user} --password={mysqluser_pw} Use {mysqluser_pw} when connecting - --[no]idle Display/don't display idle threads + --[no]local Will take the client credentials from /etc/mysql/debian.cnf --filter-user={regex} Filter display based on user regular expression --filter-host={regex} Filter display based on host regular expression --filter-db={regex} Filter display based on db regular expression only in patch2: unchanged: --- mtop-0.6.6.orig/debian/compat +++ mtop-0.6.6/debian/compat @@ -0,0 +1 @@ +4