just a little work on it - still have some code and plenty of debugging to do

This commit is contained in:
eric 2004-10-24 20:55:30 +00:00
parent f35f720686
commit d118769d8c
4 changed files with 160 additions and 132 deletions

View file

@ -1,6 +1,7 @@
<? <?
include("aur.inc"); # access AUR common functions include("aur.inc"); # access AUR common functions
include("submit_po.inc"); # use some form of this for i18n support 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 set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in check_sid(); # see if they're still logged in
html_header(); # print out the HTML header html_header(); # print out the HTML header
@ -14,12 +15,6 @@ $DBUG = 1;
$UPLOAD_DIR = "/tmp/aur/temp/"; $UPLOAD_DIR = "/tmp/aur/temp/";
$INCOMING_DIR = "/tmp/aur/incoming/"; $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"]) { if ($_COOKIE["AURSID"]) {
# track upload errors # track upload errors
@ -37,7 +32,9 @@ if ($_COOKIE["AURSID"]) {
if (!$_REQUEST["pkgname"]) { if (!$_REQUEST["pkgname"]) {
$error = __("You did not specify a package name."); $error = __("You did not specify a package name.");
} else { } 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); $presult = preg_match("/^[a-z][a-z0-9_-]*$/", $pkg_name);
if ($presult == FALSE || $presult <= 0) { if ($presult == FALSE || $presult <= 0) {
# FALSE => error processing regex, 0 => invalid characters # FALSE => error processing regex, 0 => invalid characters
@ -47,9 +44,7 @@ if ($_COOKIE["AURSID"]) {
} }
if (!$error && (!$_REQUEST["comments"] || $_REQUEST["comments"] == '')) { if (!$error && (!$_REQUEST["comments"] || $_REQUEST["comments"] == '')) {
$error = __("You must supply a comment."); $error = __("You must supply a comment for this upload/change.");
} else {
print exitError($error);
} }
if (!$error) { if (!$error) {
@ -69,10 +64,15 @@ if ($_COOKIE["AURSID"]) {
array("<b>", $pkg_name, "</b>")); 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) { if (!$error) {
# no errors checking upload permissions, go ahead and try to process # no errors checking upload permissions, go ahead and try to process
# the uploaded package file. # the uploaded package file.
@ -93,13 +93,12 @@ if ($_COOKIE["AURSID"]) {
# #
$error = __("Error trying to upload file - please try again."); $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 # at this point, we can safely unpack the uploaded file and parse
# its contents. # its contents.
# #
if (!$error) {
if (!@mkdir($INCOMING_DIR.$pkg_name)) { if (!@mkdir($INCOMING_DIR.$pkg_name)) {
$error = __("Could not create incoming directory: %s.", $error = __("Could not create incoming directory: %s.",
array($INCOMING_DIR.$pkg_name)); array($INCOMING_DIR.$pkg_name));
@ -110,19 +109,17 @@ if ($_COOKIE["AURSID"]) {
} else { } else {
# try .gz first # try .gz first
# #
exec("/bin/sh -c 'tar xzf ".$upload_file."'", $retval); @exec("/bin/sh -c 'tar xzf ".$upload_file."'", $trash, $retval);
if (!$retval) { if (!$retval) {
# now try .bz2 format # now try .bz2 format
# #
exec("/bin/sh -c 'tar xjf ".$upload_file."'", $retval); @exec("/bin/sh -c 'tar xjf ".$upload_file."'", $trash, $retval);
} }
if (!$retval) { if (!$retval) {
$error = __("Unknown file format for uploaded file."); $error = __("Unknown file format for uploaded file.");
} }
} }
} }
if ($error) {
print exitError($error);
} }
# At this point, if no error exists, the package has been extracted # At this point, if no error exists, the package has been extracted
@ -131,11 +128,12 @@ if ($_COOKIE["AURSID"]) {
# packaged without the $pkg_name subdirectory, try and create it # packaged without the $pkg_name subdirectory, try and create it
# and move the package contents into the new sub-directory. # and move the package contents into the new sub-directory.
# #
if (!$error) {
if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) && if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) &&
is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) {
# the files were packaged correctly # the files were packaged correctly
# #
if (!chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) { if (!@chdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) {
$error = __("Could not change to directory %s.", $error = __("Could not change to directory %s.",
array($INCOMING_DIR.$pkg_name."/".$pkg_name)); array($INCOMING_DIR.$pkg_name."/".$pkg_name));
} }
@ -149,7 +147,7 @@ if ($_COOKIE["AURSID"]) {
$error = __("Could not create directory %s.", $error = __("Could not create directory %s.",
array($INCOMING_DIR.$pkg_name."/".$pkg_name)); array($INCOMING_DIR.$pkg_name."/".$pkg_name));
} else { } else {
exec("/bin/sh -c 'mv * ".$pkg_name."'"); @exec("/bin/sh -c 'mv * ".$pkg_name."'");
if (!file_exists($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) { if (!file_exists($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) {
$error = __("Error exec'ing the mv command."); $error = __("Error exec'ing the mv command.");
} }
@ -163,6 +161,7 @@ if ($_COOKIE["AURSID"]) {
# some wierd packaging/extraction error - baal # some wierd packaging/extraction error - baal
# #
$error = __("Error trying to unpack upload - PKGBUILD does not exist."); $error = __("Error trying to unpack upload - PKGBUILD does not exist.");
}
} }
# if no error, get list of directory contents and process PKGBUILD # if no error, get list of directory contents and process PKGBUILD
@ -271,16 +270,28 @@ if ($_COOKIE["AURSID"]) {
} }
} }
} }
if ($error) {
print exitError($error); # 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;
}
} }
print "Groovy!!! - We're all set to populate the database!!<br />\n"; # update the backend database
print "</center>\n";
html_footer("\$Id$");
exit();
# update the backend database if there are no errors
# #
if (!$error) { if (!$error) {
$dbh = db_connect(); $dbh = db_connect();
@ -317,14 +328,6 @@ if ($_COOKIE["AURSID"]) {
# $q = "INSERT ..." # $q = "INSERT ..."
} }
} }
# TODO clean up on error? How much cleaning to do?
#
if ($error) {
# TODO clean house (filesystem/database)
#
}
} }
@ -337,6 +340,9 @@ if ($_COOKIE["AURSID"]) {
print "<span class='error'>".$error."</span><br />\n"; print "<span class='error'>".$error."</span><br />\n";
print "<br />&nbsp;<br />\n"; print "<br />&nbsp;<br />\n";
} }
$pkg_categories = pkgCategories();
$pkg_locations = pkgLocations();
print "<form action='/pkgsubmit.php' method='post'"; print "<form action='/pkgsubmit.php' method='post'";
print " enctype='multipart/form-data'>\n"; print " enctype='multipart/form-data'>\n";
print "<input type='hidden' name='pkgsubmit' value='1' />\n"; print "<input type='hidden' name='pkgsubmit' value='1' />\n";
@ -352,6 +358,28 @@ if ($_COOKIE["AURSID"]) {
print "</tr>\n"; print "</tr>\n";
print "<tr>\n"; print "<tr>\n";
print " <td span='f4' align='right'>"; 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"; print __("Upload package file").":</td>\n";
print " <td span='f4' align='left'>"; print " <td span='f4' align='left'>";
print "<input type='file' name='pfile' size='30' />\n"; print "<input type='file' name='pfile' size='30' />\n";
@ -362,9 +390,9 @@ if ($_COOKIE["AURSID"]) {
print __("Overwrite existing package?"); print __("Overwrite existing package?");
print " </td>\n"; print " </td>\n";
print " <td span='f4' align='left'>"; 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 "&nbsp;&nbsp;&nbsp;"; print "&nbsp;&nbsp;&nbsp;";
print "<input type='checkbox' name='overwrite' value='0' checked> "; print "<input type='radio' name='overwrite' value='0' checked> ";
print __("No"); print __("No");
print " </td>\n"; print " </td>\n";
print "</tr>\n"; print "</tr>\n";

View file

@ -512,11 +512,11 @@ function rm_rf($dirname="") {
$d = dir($dirname); $d = dir($dirname);
while ($f = $d->read()) { while ($f = $d->read()) {
if ($f != "." && $f != "..") { if ($f != "." && $f != "..") {
if (is_dir($dirname.$f)) { if (is_dir($dirname."/".$f)) {
rm_rf($dirname.$f."/"); rm_rf($dirname."/".$f);
} }
if (is_file($dirname.$f) || is_link($dirname.$f)) { if (is_file($dirname."/".$f) || is_link($dirname."/".$f)) {
unlink($dirname.$f); unlink($dirname."/".$f);
} }
} }
} }

Binary file not shown.

View file

@ -33,16 +33,16 @@ source=(http://spacefem.com/skins/ChalkItUp.tar.gz \
http://gd.tuwien.ac.at/mm/xmms/Skins/xmms_skin-0.9.zip \ http://gd.tuwien.ac.at/mm/xmms/Skins/xmms_skin-0.9.zip \
http://havardk.xmms.org/skins/xmmsskins-1.0.tar.gz) http://havardk.xmms.org/skins/xmmsskins-1.0.tar.gz)
md5sums=('1a541ca4fbcbd60eaffac97a8e01a514' '60b5249618067baba41093d566f56c9f' md5sums=('1a541ca4fbcbd60eaffac97a8e01a514' '60b5249618067baba41093d566f56c9f' \
'2eef6028cb492eb6c61e3d4833f050d1' 'ae60e6fd170737af35caf219ddf859ec' '2eef6028cb492eb6c61e3d4833f050d1' 'ae60e6fd170737af35caf219ddf859ec' \
'd3d5e43860db73a73b37a4949eebfe4f' 'a38d448ac059f42bd32e52f3999a6ca5' 'd3d5e43860db73a73b37a4949eebfe4f' 'a38d448ac059f42bd32e52f3999a6ca5' \
'93891ba6259280d07a8781cd89234703' '92dd1ae652c43ea514764460b852f42c' '93891ba6259280d07a8781cd89234703' '92dd1ae652c43ea514764460b852f42c' \
'9f79f309e5859b878b0cdcfb3d97a8b0' '55b6ada4b963132bb561156eddd47615' '9f79f309e5859b878b0cdcfb3d97a8b0' '55b6ada4b963132bb561156eddd47615' \
'880be0a9dbbd9a3a458739063c6e0904' '89c7acb342bee6c7977047669ba195d7' '880be0a9dbbd9a3a458739063c6e0904' '89c7acb342bee6c7977047669ba195d7' \
'7caaa4977c73c23e70c758a94c4104ef' '96340dd2f5634a6d49c9a314c1db7ad1' '7caaa4977c73c23e70c758a94c4104ef' '96340dd2f5634a6d49c9a314c1db7ad1' \
'83f2cdc3d2cd2fbd5f3a4f92eba8d932' '108266865bcf9509edea839ca0a76d57' '83f2cdc3d2cd2fbd5f3a4f92eba8d932' '108266865bcf9509edea839ca0a76d57' \
'2b2fee8ce2ba18074dc202a50372ce95' 'acb8bf4189ad7d00a36ca74514686f8e' '2b2fee8ce2ba18074dc202a50372ce95' 'acb8bf4189ad7d00a36ca74514686f8e' \
'a770f9e537a0cec3818b331696d7ffff' 'b90c21851264fd273bb06196fb157a7a' 'a770f9e537a0cec3818b331696d7ffff' 'b90c21851264fd273bb06196fb157a7a' \
'aaaed9cd81b233e4fe5f896e9353443e' 'f625e06f82d8132209ed947c6d8502a4') 'aaaed9cd81b233e4fe5f896e9353443e' 'f625e06f82d8132209ed947c6d8502a4')
build() { build() {