From 199ff8588a19b92bbd1b367d5794296efee3f0e4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 27 Dec 2016 18:12:41 +0000 Subject: Support merging when applying updates that target existing packages --- .../service/maintenance/updatesProcessor.cpp | 51 +++++++++++++++------- .../sql/maintenance/updatesMoveUserPackages.sql | 14 ++++++ .../app-backup/backintime/Manifest | 1 - .../app-backup/backintime/metadata.xml | 17 -------- .../md5-cache/app-backup/backintime-1.1.8-r1 | 15 ------- .../metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 | 15 +++++++ .../profiles/updates/4Q-2016 | 1 + gentoobrowse-api/unittests/testMaintenance.cpp | 2 +- 8 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql delete mode 100644 gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest delete mode 100644 gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml delete mode 100644 gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 create mode 100644 gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 diff --git a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp index 04db644..5fd998f 100644 --- a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include using namespace AdHoc::FileUtils; @@ -25,7 +27,9 @@ namespace Gentoo { UpdatesPatch(DB::Connection * db) : movePackageDirFiles(db->modify(sql::maintenance::updatesPackageDirFiles.getSql())), moveMD5CacheFiles(db->modify(sql::maintenance::updatesMD5CacheFiles.getSql())), + findPackage(db->select(sql::portage::findPackage.getSql())), movePackages(db->modify(sql::maintenance::updatesMovePackages.getSql())), + moveUserPackages(db->modify(sql::maintenance::updatesMoveUserPackages.getSql())), updatePacks("updatePack") { this->src = Utils::Database::emptyClone(db, "gentoobrowse.updates"); @@ -53,29 +57,44 @@ namespace Gentoo { DB::ModifyCommandPtr drop; DB::ModifyCommandPtr movePackageDirFiles; DB::ModifyCommandPtr moveMD5CacheFiles; + DB::SelectCommandPtr findPackage; DB::ModifyCommandPtr movePackages; + DB::ModifyCommandPtr moveUserPackages; Utils::EntityWhereFilter updatePacks; void move(DB::SelectCommandPtr s) { s->forEachRow([this](auto catfrom, auto catto, auto namefrom, auto nameto, auto) { - movePackageDirFiles->bindParamS(0, catto); - movePackageDirFiles->bindParamS(1, nameto); - movePackageDirFiles->bindParamS(2, catfrom); - movePackageDirFiles->bindParamS(3, namefrom); - movePackageDirFiles->execute(); - moveMD5CacheFiles->bindParamS(0, catto); - moveMD5CacheFiles->bindParamS(1, namefrom); - moveMD5CacheFiles->bindParamS(2, nameto); - moveMD5CacheFiles->bindParamS(3, catfrom); - moveMD5CacheFiles->bindParamS(4, namefrom); - moveMD5CacheFiles->execute(); - movePackages->bindParamS(0, nameto); - movePackages->bindParamS(1, namefrom); - movePackages->bindParamS(2, catfrom); - movePackages->bindParamS(3, catto); - movePackages->execute(); + findPackage->bindParamS(0, catto); + findPackage->bindParamS(1, nameto); + if (findPackage->fetch()) { // Does target already exist? + // Merge + moveUserPackages->bindParamS(0, catfrom); + moveUserPackages->bindParamS(1, namefrom); + moveUserPackages->bindParamS(2, catto); + moveUserPackages->bindParamS(3, nameto); + moveUserPackages->execute(); + } + else { + // Move + movePackageDirFiles->bindParamS(0, catto); + movePackageDirFiles->bindParamS(1, nameto); + movePackageDirFiles->bindParamS(2, catfrom); + movePackageDirFiles->bindParamS(3, namefrom); + movePackageDirFiles->execute(); + moveMD5CacheFiles->bindParamS(0, catto); + moveMD5CacheFiles->bindParamS(1, namefrom); + moveMD5CacheFiles->bindParamS(2, nameto); + moveMD5CacheFiles->bindParamS(3, catfrom); + moveMD5CacheFiles->bindParamS(4, namefrom); + moveMD5CacheFiles->execute(); + movePackages->bindParamS(0, nameto); + movePackages->bindParamS(1, namefrom); + movePackages->bindParamS(2, catfrom); + movePackages->bindParamS(3, catto); + movePackages->execute(); + } }); } }; diff --git a/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql b/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql new file mode 100644 index 0000000..e305ac7 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql @@ -0,0 +1,14 @@ +UPDATE gentoobrowse.user_packages up SET + packageid = np.packageid +FROM gentoobrowse.packages op, gentoobrowse.packages np, gentoobrowse.categories oc, gentoobrowse.categories nc +WHERE up.packageid = op.packageid +AND op.categoryid = oc.categoryid +AND np.categoryid = nc.categoryid +AND oc.name = ? +AND op.name = ? +AND nc.name = ? +AND np.name = ? +AND NOT EXISTS ( + SELECT FROM gentoobrowse.user_packages eup + WHERE up.userid = eup.userid + AND np.packageid = eup.packageid) diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest deleted file mode 100644 index e377aca..0000000 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest +++ /dev/null @@ -1 +0,0 @@ -DIST backintime-1.1.8.tar.gz 617754 SHA256 a1f2d210e95633dfe383eb50b3b560d1e09c43de4ce89dd4cb193cab40cb8a1e SHA512 550e270dcf341ec5ad952f4decd836007d19ff9bf60cada834dfb488dbf29954b6fd3ed80a4f8fb4406a0166895a7f7c922e5622d06c43086dd54073e5aabd99 WHIRLPOOL ea9af3c432c61def4214e1d1e2c70e40cb7e50867bb0fa08930740c13133293ad135fd6c97295ab176deaedacb33e72583dc7c34dcfc3cb375a8b6e7fc7ab632 diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml deleted file mode 100644 index c5512af..0000000 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - xmw@gentoo.org - Michael Weber - - -Back In Time is a simple backup tool for Linux inspired from “flyback project” and “TimeVault”. The backup is done by taking snapshots of a specified set of directories. -Currently there are two GUI available: Gnome and KDE 4 (>= 4.1). - -All you have to do is configure: - Where to save snapshot - What directories to backup - When backup should be done (manual, every hour, every day, every week, every month) - - diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 deleted file mode 100644 index ac07dcf..0000000 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 +++ /dev/null @@ -1,15 +0,0 @@ -DEFINED_PHASES=compile configure install prepare setup -DEPEND=python_single_target_python3_3? ( >=dev-lang/python-3.3.2-r2:3.3 ) python_single_target_python3_4? ( dev-lang/python:3.4 ) >=dev-lang/python-exec-2:=[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/dbus-python[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/keyring[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] net-misc/openssh net-misc/rsync[xattr,acl] -DESCRIPTION=Backup system inspired by TimeVault and FlyBack, with a GUI for GNOME and KDE4 -EAPI=5 -HOMEPAGE=http://backintime.le-web.org/ -IUSE=qt4 python_targets_python3_3 python_targets_python3_4 python_single_target_python3_3 python_single_target_python3_4 -KEYWORDS=amd64 x86 -LICENSE=GPL-2 -RDEPEND=python_single_target_python3_3? ( >=dev-lang/python-3.3.2-r2:3.3 ) python_single_target_python3_4? ( dev-lang/python:3.4 ) >=dev-lang/python-exec-2:=[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/dbus-python[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/keyring[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] net-misc/openssh net-misc/rsync[xattr,acl] qt4? ( dev-python/PyQt4 ) -REQUIRED_USE=^^ ( python_single_target_python3_3 python_single_target_python3_4 ) python_single_target_python3_3? ( python_targets_python3_3 ) python_single_target_python3_4? ( python_targets_python3_4 ) -SLOT=0 -SRC_URI=http://backintime.le-web.org/download/backintime/backintime-1.1.8.tar.gz -_eclass_exported_funcs=pkg_setup:python-single-r1 src_prepare:- src_configure:- src_compile:- src_install:- -_eclasses_=eutils 9d81603248f2ba3ec59124320d123e5e multilib 23ae8c186171e6476af098d2a50d0ee0 python-single-r1 2ebea8fbab356d63110245129a67a6dd python-utils-r1 2e6826f6a93ad2acf904eecf5b5fb6d2 toolchain-funcs d513d423d449877e49d99af3f7af7acb -_md5_=a10459ab9c4dc19406285a5678317f1c diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 new file mode 100644 index 0000000..ac07dcf --- /dev/null +++ b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 @@ -0,0 +1,15 @@ +DEFINED_PHASES=compile configure install prepare setup +DEPEND=python_single_target_python3_3? ( >=dev-lang/python-3.3.2-r2:3.3 ) python_single_target_python3_4? ( dev-lang/python:3.4 ) >=dev-lang/python-exec-2:=[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/dbus-python[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/keyring[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] net-misc/openssh net-misc/rsync[xattr,acl] +DESCRIPTION=Backup system inspired by TimeVault and FlyBack, with a GUI for GNOME and KDE4 +EAPI=5 +HOMEPAGE=http://backintime.le-web.org/ +IUSE=qt4 python_targets_python3_3 python_targets_python3_4 python_single_target_python3_3 python_single_target_python3_4 +KEYWORDS=amd64 x86 +LICENSE=GPL-2 +RDEPEND=python_single_target_python3_3? ( >=dev-lang/python-3.3.2-r2:3.3 ) python_single_target_python3_4? ( dev-lang/python:3.4 ) >=dev-lang/python-exec-2:=[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/dbus-python[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] dev-python/keyring[python_targets_python3_3(-)?,python_targets_python3_4(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python2_7(-),-python_single_target_python3_5(-),python_single_target_python3_3(+)?,python_single_target_python3_4(+)?] net-misc/openssh net-misc/rsync[xattr,acl] qt4? ( dev-python/PyQt4 ) +REQUIRED_USE=^^ ( python_single_target_python3_3 python_single_target_python3_4 ) python_single_target_python3_3? ( python_targets_python3_3 ) python_single_target_python3_4? ( python_targets_python3_4 ) +SLOT=0 +SRC_URI=http://backintime.le-web.org/download/backintime/backintime-1.1.8.tar.gz +_eclass_exported_funcs=pkg_setup:python-single-r1 src_prepare:- src_configure:- src_compile:- src_install:- +_eclasses_=eutils 9d81603248f2ba3ec59124320d123e5e multilib 23ae8c186171e6476af098d2a50d0ee0 python-single-r1 2ebea8fbab356d63110245129a67a6dd python-utils-r1 2e6826f6a93ad2acf904eecf5b5fb6d2 toolchain-funcs d513d423d449877e49d99af3f7af7acb +_md5_=a10459ab9c4dc19406285a5678317f1c diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 index dc38e7b..96442b9 100644 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 +++ b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 @@ -1,3 +1,4 @@ slotmove a/b 0 1 move app-backup/amanda dev-vcs/wasamanda move doesnt/exist some/thing +move app-backup/backintime dev-vcs/wasamanda diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index d864659..4c3bffe 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree ) m, 2080, 5, 1, 482, 981, 3626, 4593, 501, 393, 238, 50, 1573, 2008, 1543, 81, 152); doRefreshPackageTree(sd, db, "756569aa764177340726dd3d40b41d89b11b20c7", "gentoo", - m, 2084, 5, 1, 484, 982, 3638, 4599, 503, 393, 238, 50, 1573, 2009, 1546, 79, 152); + m, 2082, 5, 1, 483, 982, 3638, 4599, 502, 393, 238, 50, 1573, 2009, 1546, 79, 152); doRefreshPackageTree(sd, db, "", "gentoo", m, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); -- cgit v1.2.3