You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4KB

  1. #!/usr/bin/env php
  2. <?php
  3. define("SMF", true);
  4. $boarddir = getenv("FORUMS_SOURCE");
  5. $sourcedir = "$boarddir/Sources";
  6. $forum_version = "SMF " . getenv("SMF_VERSION");
  7. $temp_dir = "$boarddir/Packages/temp";
  8. require_once("$sourcedir/Errors.php");
  9. require_once("$sourcedir/QueryString.php");
  10. require_once("$sourcedir/Subs.php");
  11. require_once("$sourcedir/Subs-Package.php");
  12. function loadLanguage($language) {}
  13. function download($uri) {
  14. $entries = scandir(".");
  15. passthru("wget --content-disposition \"$uri\"");
  16. return array_values(array_diff(scandir("."), $entries))[0];
  17. }
  18. function downloadPackage($packageUrl) {
  19. global $boarddir;
  20. $packageFile = download($packageUrl);
  21. $fullPackageName = "$boarddir/Packages/$packageFile";
  22. rename($packageFile, $fullPackageName);
  23. return $packageFile;
  24. }
  25. function unpackPackage($packageFile) {
  26. global $boarddir, $temp_dir;
  27. $fullPackageName = "$boarddir/Packages/$packageFile";
  28. mktree($temp_dir, 0777);
  29. read_tgz_file($fullPackageName, $temp_dir);
  30. }
  31. function installPackage($packageFile) {
  32. $packageInfo = getPackageInfo($packageFile);
  33. return parsePackageInfo($packageInfo['xml'], false);
  34. }
  35. function cleanup() {
  36. global $temp_dir;
  37. deltree($temp_dir);
  38. }
  39. $packageUrl = $argv[1];
  40. $packageFile = downloadPackage($packageUrl);
  41. unpackPackage($packageFile);
  42. installPackage($packageFile);
  43. cleanup();