diff options
author | eric <eric> | 2004-10-24 20:55:30 +0000 |
---|---|---|
committer | eric <eric> | 2004-10-24 20:55:30 +0000 |
commit | d118769d8ca25cd406ceb7412b84aa87f97c808f (patch) | |
tree | 1e3856cd1e4e95549b6b107140cf7694a0467b64 /web | |
parent | f35f7206869d359a1a5adbc919a8b2a9e23e4ad4 (diff) | |
download | aurweb-d118769d8ca25cd406ceb7412b84aa87f97c808f.tar.xz |
just a little work on it - still have some code and plenty of debugging to do
Diffstat (limited to 'web')
-rw-r--r-- | web/html/pkgsubmit.php | 268 | ||||
-rw-r--r-- | web/lib/aur.inc | 8 | ||||
-rw-r--r-- | web/testing/xmms-skins.tar.gz | bin | 1803 -> 2850 bytes | |||
-rw-r--r-- | web/testing/xmms-skins/PKGBUILD | 22 |
4 files changed, 163 insertions, 135 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 4439911..1b986cc 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -1,6 +1,7 @@ <? include("aur.inc"); # access AUR common functions include("submit_po.inc"); # use some form of this for i18n support +include("pkgfuncs.inc"); # package functions set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in html_header(); # print out the HTML header @@ -14,12 +15,6 @@ $DBUG = 1; $UPLOAD_DIR = "/tmp/aur/temp/"; $INCOMING_DIR = "/tmp/aur/incoming/"; -function exitError($msg) { - print "<span class='error'>" . $msg . "</span><br />\n"; - print "</center>\n"; - html_footer("\$Id$"); - exit(); -} if ($_COOKIE["AURSID"]) { # track upload errors @@ -37,7 +32,9 @@ if ($_COOKIE["AURSID"]) { if (!$_REQUEST["pkgname"]) { $error = __("You did not specify a package name."); } else { - $pkg_name = escapeshellarg($_REQUEST["pkgname"]); + $pkg_name = str_replace("'", "", $_REQUEST["pkgname"]); + $pkg_name = escapeshellarg($pkg_name); + $pkg_name = str_replace("'", "", $pkg_name); # get rid of single quotes $presult = preg_match("/^[a-z][a-z0-9_-]*$/", $pkg_name); if ($presult == FALSE || $presult <= 0) { # FALSE => error processing regex, 0 => invalid characters @@ -47,9 +44,7 @@ if ($_COOKIE["AURSID"]) { } if (!$error && (!$_REQUEST["comments"] || $_REQUEST["comments"] == '')) { - $error = __("You must supply a comment."); - } else { - print exitError($error); + $error = __("You must supply a comment for this upload/change."); } if (!$error) { @@ -69,10 +64,15 @@ if ($_COOKIE["AURSID"]) { array("<b>", $pkg_name, "</b>")); } } - } else { - print exitError($error); } + # TODO check to see if the user has the ability to 'change' package + # attributes such as location and/or category. Examples: TUs can + # only add/change packages in Unsupported and the AUR, normal users + # can only add/change packages in Unsupported. + # + + if (!$error) { # no errors checking upload permissions, go ahead and try to process # the uploaded package file. @@ -93,36 +93,33 @@ if ($_COOKIE["AURSID"]) { # $error = __("Error trying to upload file - please try again."); } - } else { - print exitError($error); } # at this point, we can safely unpack the uploaded file and parse # its contents. # - if (!@mkdir($INCOMING_DIR.$pkg_name)) { - $error = __("Could not create incoming directory: %s.", - array($INCOMING_DIR.$pkg_name)); - } else { - if (!@chdir($INCOMING_DIR.$pkg_name)) { - $error = __("Could not change directory to %s.", - array($INCOMING_DIR.$pkg_name)); - } else { - # try .gz first - # - exec("/bin/sh -c 'tar xzf ".$upload_file."'", $retval); - if (!$retval) { - # now try .bz2 format - # - exec("/bin/sh -c 'tar xjf ".$upload_file."'", $retval); - } - if (!$retval) { - $error = __("Unknown file format for uploaded file."); - } - } - } - if ($error) { - print exitError($error); + if (!$error) { + if (!@mkdir($INCOMING_DIR.$pkg_name)) { + $error = __("Could not create incoming directory: %s.", + array($INCOMING_DIR.$pkg_name)); + } else { + if (!@chdir($INCOMING_DIR.$pkg_name)) { + $error = __("Could not change directory to %s.", + array($INCOMING_DIR.$pkg_name)); + } else { + # try .gz first + # + @exec("/bin/sh -c 'tar xzf ".$upload_file."'", $trash, $retval); + if (!$retval) { + # now try .bz2 format + # + @exec("/bin/sh -c 'tar xjf ".$upload_file."'", $trash, $retval); + } + if (!$retval) { + $error = __("Unknown file format for uploaded file."); + } + } + } } # At this point, if no error exists, the package has been extracted @@ -131,39 +128,41 @@ if ($_COOKIE["AURSID"]) { # packaged without the $pkg_name subdirectory, try and create it # and move the package contents into the new sub-directory. # - if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) && - is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { - # the files were packaged correctly - # - if (!chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { - $error = __("Could not change to directory %s.", - array($INCOMING_DIR.$pkg_name."/".$pkg_name)); - } - $pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; - } elseif (is_file($INCOMING_DIR.$pkg_name."/PKGBUILD")) { - # not packaged correctly, but recovery may be possible. - # try and create $INCOMING_DIR.$pkg_name."/".$pkg_name and - # move package contents into the new dir - # - if (!@mkdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { - $error = __("Could not create directory %s.", - array($INCOMING_DIR.$pkg_name."/".$pkg_name)); - } else { - exec("/bin/sh -c 'mv * ".$pkg_name."'"); - if (!file_exists($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { - $error = __("Error exec'ing the mv command."); - } - } - if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { - $error = __("Could not change to directory %s.", - array($INCOMING_DIR.$pkg_name."/".$pkg_name)); - } - $pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; - } else { - # some wierd packaging/extraction error - baal - # - $error = __("Error trying to unpack upload - PKGBUILD does not exist."); - } + if (!$error) { + if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) && + is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { + # the files were packaged correctly + # + if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { + $error = __("Could not change to directory %s.", + array($INCOMING_DIR.$pkg_name."/".$pkg_name)); + } + $pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; + } elseif (is_file($INCOMING_DIR.$pkg_name."/PKGBUILD")) { + # not packaged correctly, but recovery may be possible. + # try and create $INCOMING_DIR.$pkg_name."/".$pkg_name and + # move package contents into the new dir + # + if (!@mkdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { + $error = __("Could not create directory %s.", + array($INCOMING_DIR.$pkg_name."/".$pkg_name)); + } else { + @exec("/bin/sh -c 'mv * ".$pkg_name."'"); + if (!file_exists($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { + $error = __("Error exec'ing the mv command."); + } + } + if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { + $error = __("Could not change to directory %s.", + array($INCOMING_DIR.$pkg_name."/".$pkg_name)); + } + $pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name; + } else { + # some wierd packaging/extraction error - baal + # + $error = __("Error trying to unpack upload - PKGBUILD does not exist."); + } + } # if no error, get list of directory contents and process PKGBUILD # @@ -271,60 +270,64 @@ if ($_COOKIE["AURSID"]) { } } } - if ($error) { - print exitError($error); - } - print "Groovy!!! - We're all set to populate the database!!<br />\n"; - print "</center>\n"; - html_footer("\$Id$"); - exit(); + # TODO This is where other additional error checking can be + # performed. Examples: #md5sums == #sources?, md5sums of any + # included files match?, install scriptlet file exists? + # + + + # Now, run through the pkgbuild array and do any $pkgname/$pkgver + # substituions. + # + if (!$error) { + $pkgname_var = $pkgbuild["pkgname"]; + $pkgver_var = $pkgbuild["pkgver"]; + $new_pkgbuild = array(); + while (list($k, $v) = each($pkgbuild)) { + $v = str_replace("\$pkgname", $pkgname_var, $v); + $v = str_replace("\$pkgver", $pkgver_var, $v); + $new_pkgbuild[$k] = $v; + } + } - # update the backend database if there are no errors + # update the backend database # - if (!$error) { - $dbh = db_connect(); - if ($pkg_exists) { - - # this is an overwrite of an existing package, the database ID - # needs to be preserved so that any votes are retained. However, - # PackageDepends, PackageSources, and PackageContents can be - # purged. - # - $q = "SELECT * FROM Packages "; - $q.= "WHERE Name = '".mysql_escape_string($_FILES["pfile"]["name"])."'"; - $result = db_query($q, $dbh); - $pdata = mysql_fetch_assoc($result); - - # flush out old data that will be replaced with new data - # - $q = "DELETE FROM PackageContents WHERE PackageID = ".$pdata["ID"]; - db_query($q, $dbh); - $q = "DELETE FROM PackageDepends WHERE PackageID = ".$pdata["ID"]; - db_query($q, $dbh); - $q = "DELETE FROM PackageSources WHERE PackageID = ".$pdata["ID"]; - db_query($q, $dbh); - - # TODO - # $q = "UPDATE Packages ..." + if (!$error) { + $dbh = db_connect(); + if ($pkg_exists) { + + # this is an overwrite of an existing package, the database ID + # needs to be preserved so that any votes are retained. However, + # PackageDepends, PackageSources, and PackageContents can be + # purged. + # + $q = "SELECT * FROM Packages "; + $q.= "WHERE Name = '".mysql_escape_string($_FILES["pfile"]["name"])."'"; + $result = db_query($q, $dbh); + $pdata = mysql_fetch_assoc($result); + + # flush out old data that will be replaced with new data + # + $q = "DELETE FROM PackageContents WHERE PackageID = ".$pdata["ID"]; + db_query($q, $dbh); + $q = "DELETE FROM PackageDepends WHERE PackageID = ".$pdata["ID"]; + db_query($q, $dbh); + $q = "DELETE FROM PackageSources WHERE PackageID = ".$pdata["ID"]; + db_query($q, $dbh); + + # TODO + # $q = "UPDATE Packages ..." # $q = "INSERT INTO PackageUploadHistory ..." - } else { - # this is a brand new package - # - # TODO - # $q = "INSERT ..." - } - } - - # TODO clean up on error? How much cleaning to do? - # - if ($error) { - # TODO clean house (filesystem/database) - # - } - + } else { + # this is a brand new package + # + # TODO + # $q = "INSERT ..." + } + } } @@ -337,6 +340,9 @@ if ($_COOKIE["AURSID"]) { print "<span class='error'>".$error."</span><br />\n"; print "<br /> <br />\n"; } + $pkg_categories = pkgCategories(); + $pkg_locations = pkgLocations(); + print "<form action='/pkgsubmit.php' method='post'"; print " enctype='multipart/form-data'>\n"; print "<input type='hidden' name='pkgsubmit' value='1' />\n"; @@ -350,6 +356,28 @@ if ($_COOKIE["AURSID"]) { print "<input type='text' name='pkgname' size='30' maxlength='15' />\n"; print " </td>\n"; print "</tr>\n"; + print "<tr>\n"; + print " <td span='f4' align='right'>"; + print __("Package Category").":</td>\n"; + print " <td span='f4' align='left'>"; + print "<select name='category'>"; + print "<option value='0'> " . __("Select Category") . "</option>"; + while (list($k, $v) = each($pkg_categories)) { + print "<option value='".$k."'> " . $v . "</option>"; + } + print "</select></td>\n"; + print "</tr>\n"; + print "<tr>\n"; + print " <td span='f4' align='right'>"; + print __("Package Location").":</td>\n"; + print " <td span='f4' align='left'>"; + print "<select name='location'>"; + print "<option value='0'> " . __("Select Location") . "</option>"; + while (list($k, $v) = each($pkg_locations)) { + print "<option value='".$k."'> " . $v . "</option>"; + } + print "</select></td>\n"; + print "</tr>\n"; print "<tr>\n"; print " <td span='f4' align='right'>"; print __("Upload package file").":</td>\n"; @@ -362,9 +390,9 @@ if ($_COOKIE["AURSID"]) { print __("Overwrite existing package?"); print " </td>\n"; print " <td span='f4' align='left'>"; - print "<input type='checkbox' name='overwrite' value='1'> ".__("Yes"); + print "<input type='radio' name='overwrite' value='1'> ".__("Yes"); print " "; - print "<input type='checkbox' name='overwrite' value='0' checked> "; + print "<input type='radio' name='overwrite' value='0' checked> "; print __("No"); print " </td>\n"; print "</tr>\n"; diff --git a/web/lib/aur.inc b/web/lib/aur.inc index f652b06..e696d5b 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -512,11 +512,11 @@ function rm_rf($dirname="") { $d = dir($dirname); while ($f = $d->read()) { if ($f != "." && $f != "..") { - if (is_dir($dirname.$f)) { - rm_rf($dirname.$f."/"); + if (is_dir($dirname."/".$f)) { + rm_rf($dirname."/".$f); } - if (is_file($dirname.$f) || is_link($dirname.$f)) { - unlink($dirname.$f); + if (is_file($dirname."/".$f) || is_link($dirname."/".$f)) { + unlink($dirname."/".$f); } } } diff --git a/web/testing/xmms-skins.tar.gz b/web/testing/xmms-skins.tar.gz Binary files differindex 9fb0db3..1b313f8 100644 --- a/web/testing/xmms-skins.tar.gz +++ b/web/testing/xmms-skins.tar.gz diff --git a/web/testing/xmms-skins/PKGBUILD b/web/testing/xmms-skins/PKGBUILD index e2c7b38..83d934b 100644 --- a/web/testing/xmms-skins/PKGBUILD +++ b/web/testing/xmms-skins/PKGBUILD @@ -33,17 +33,17 @@ source=(http://spacefem.com/skins/ChalkItUp.tar.gz \ http://gd.tuwien.ac.at/mm/xmms/Skins/xmms_skin-0.9.zip \ http://havardk.xmms.org/skins/xmmsskins-1.0.tar.gz) -md5sums=('1a541ca4fbcbd60eaffac97a8e01a514' '60b5249618067baba41093d566f56c9f' -'2eef6028cb492eb6c61e3d4833f050d1' 'ae60e6fd170737af35caf219ddf859ec' -'d3d5e43860db73a73b37a4949eebfe4f' 'a38d448ac059f42bd32e52f3999a6ca5' -'93891ba6259280d07a8781cd89234703' '92dd1ae652c43ea514764460b852f42c' -'9f79f309e5859b878b0cdcfb3d97a8b0' '55b6ada4b963132bb561156eddd47615' -'880be0a9dbbd9a3a458739063c6e0904' '89c7acb342bee6c7977047669ba195d7' -'7caaa4977c73c23e70c758a94c4104ef' '96340dd2f5634a6d49c9a314c1db7ad1' -'83f2cdc3d2cd2fbd5f3a4f92eba8d932' '108266865bcf9509edea839ca0a76d57' -'2b2fee8ce2ba18074dc202a50372ce95' 'acb8bf4189ad7d00a36ca74514686f8e' -'a770f9e537a0cec3818b331696d7ffff' 'b90c21851264fd273bb06196fb157a7a' -'aaaed9cd81b233e4fe5f896e9353443e' 'f625e06f82d8132209ed947c6d8502a4') +md5sums=('1a541ca4fbcbd60eaffac97a8e01a514' '60b5249618067baba41093d566f56c9f' \ + '2eef6028cb492eb6c61e3d4833f050d1' 'ae60e6fd170737af35caf219ddf859ec' \ + 'd3d5e43860db73a73b37a4949eebfe4f' 'a38d448ac059f42bd32e52f3999a6ca5' \ + '93891ba6259280d07a8781cd89234703' '92dd1ae652c43ea514764460b852f42c' \ + '9f79f309e5859b878b0cdcfb3d97a8b0' '55b6ada4b963132bb561156eddd47615' \ + '880be0a9dbbd9a3a458739063c6e0904' '89c7acb342bee6c7977047669ba195d7' \ + '7caaa4977c73c23e70c758a94c4104ef' '96340dd2f5634a6d49c9a314c1db7ad1' \ + '83f2cdc3d2cd2fbd5f3a4f92eba8d932' '108266865bcf9509edea839ca0a76d57' \ + '2b2fee8ce2ba18074dc202a50372ce95' 'acb8bf4189ad7d00a36ca74514686f8e' \ + 'a770f9e537a0cec3818b331696d7ffff' 'b90c21851264fd273bb06196fb157a7a' \ + 'aaaed9cd81b233e4fe5f896e9353443e' 'f625e06f82d8132209ed947c6d8502a4') build() { cd $startdir/src/ |