From b7941073acec76e5b4f89648aca1413c15eb067f Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 4 Apr 2014 00:01:44 +0200 Subject: Add provisional support for package bases This adds a PackageBases table to the database schema and moves the following fields from the Packages table to PackageBases: * CategoryID * NumVotes * OutOfDateTS * SubmittedTS * ModifiedTS * SubmitterUID * MaintainerUID It also fixes all database accesses to comply with the new layout. Having a separate PackageBases table is the first step to split package support. By now, we create one PackageBases entry per package (where the package base has the same name as the corresponding package). When adding full support for split packages later, the package base name will be derived from the pkgbase variable and a single package base will be shared amongst all packages built from one source package. Signed-off-by: Lukas Fleischer --- web/html/pkgsubmit.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'web/html/pkgsubmit.php') diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 373af35..38fbb8c 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -354,7 +354,7 @@ if ($uid): if (!$error) { # First, see if this package already exists, and if it can be overwritten $pkg_id = pkgid_from_name($pkg_name); - if (can_submit_pkg($pkg_name, $_COOKIE["AURSID"])) { + if (can_submit_pkgbase($pkg_name, $_COOKIE["AURSID"])) { if (file_exists($incoming_pkgdir)) { # Blow away the existing file/dir and contents rm_tree($incoming_pkgdir); @@ -409,24 +409,25 @@ if ($uid): # This is an overwrite of an existing package, the database ID # needs to be preserved so that any votes are retained. However, # PackageDepends and PackageSources can be purged. - $packageID = $pdata["ID"]; + $pkgid = $pdata["ID"]; + $base_id = pkgbase_from_pkgid($pkgid); # Flush out old data that will be replaced with new data - remove_pkg_deps($packageID); - remove_pkg_sources($packageID); + remove_pkg_deps($pkgid); + remove_pkg_sources($pkgid); # If a new category was chosen, change it to that if ($category_id > 1) { - update_pkg_category($packageID, $category_id); + update_pkgbase_category($base_id, $category_id); } - # Update package data - update_pkgdetails($new_pkgbuild['pkgname'], $new_pkgbuild['license'], $pkg_version, $new_pkgbuild['pkgdesc'], $new_pkgbuild['url'], $uid, $packageID); + # Update package base and package data + update_pkgbase($base_id, $new_pkgbuild['pkgname'], $uid); + update_pkg($pkgid, $new_pkgbuild['pkgname'], $new_pkgbuild['license'], $pkg_version, $new_pkgbuild['pkgdesc'], $new_pkgbuild['url']); } else { # This is a brand new package - new_pkgdetails($new_pkgbuild['pkgname'], $new_pkgbuild['license'], $pkg_version, $category_id, $new_pkgbuild['pkgdesc'], $new_pkgbuild['url'], $uid); - $packageID = last_insert_id(); - + $base_id = create_pkgbase($new_pkgbuild['pkgname'], $category_id, $uid); + $pkgid = create_pkg($base_id, $new_pkgbuild['pkgname'], $new_pkgbuild['license'], $pkg_version, $new_pkgbuild['pkgdesc'], $new_pkgbuild['url']); } # Update package depends @@ -444,7 +445,7 @@ if ($uid): else if ($deppkgname == "#") { break; } - add_pkg_dep($packageID, $deppkgname, $depcondition); + add_pkg_dep($pkgid, $deppkgname, $depcondition); } } @@ -452,14 +453,14 @@ if ($uid): if (!empty($new_pkgbuild['source'])) { $sources = explode(" ", $new_pkgbuild['source']); foreach ($sources as $src) { - add_pkg_src($packageID, $src); + add_pkg_src($pkgid, $src); } } # If we just created this package, or it was an orphan and we # auto-adopted, add submitting user to the notification list. if (!$pdata || $pdata["MaintainerUID"] === NULL) { - pkg_notify(account_from_sid($_COOKIE["AURSID"]), array($packageID), true); + pkg_notify(account_from_sid($_COOKIE["AURSID"]), array($pkgid), true); } # Entire package creation process is atomic -- cgit v1.2.3-70-g09d2