index : website | |
Archlinux32 website - obsolete | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | pkgapi/pacman-i486.conf | 64 | ||||
-rw-r--r-- | pkgapi/pacman-i686.conf | 64 | ||||
-rw-r--r-- | pkgapi/pkginfo.php | 53 |
diff --git a/pkgapi/pacman-i486.conf b/pkgapi/pacman-i486.conf new file mode 100644 index 0000000..3dee4f9 --- /dev/null +++ b/pkgapi/pacman-i486.conf @@ -0,0 +1,64 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +DBPath = /var/lib/pacman-i486/ +CacheDir = /var/cache/pacman-i486/pkg/ +LogFile = /dev/null +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = i486 + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +#Color +#TotalDownload +CheckSpace +#VerbosePkgLists + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +[staging] +Include = /etc/pacman.d/mirrorlist32 + +[community-staging] +Include = /etc/pacman.d/mirrorlist32 + +[testing] +Include = /etc/pacman.d/mirrorlist32 + +[community-testing] +Include = /etc/pacman.d/mirrorlist32 + +[core] +Include = /etc/pacman.d/mirrorlist32 + +[extra] +Include = /etc/pacman.d/mirrorlist32 + +[community] +Include = /etc/pacman.d/mirrorlist32 diff --git a/pkgapi/pacman-i686.conf b/pkgapi/pacman-i686.conf new file mode 100644 index 0000000..442b10e --- /dev/null +++ b/pkgapi/pacman-i686.conf @@ -0,0 +1,64 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +DBPath = /var/lib/pacman-i686/ +CacheDir = /var/cache/pacman-i686/pkg/ +LogFile = /dev/null +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = i686 + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +#Color +#TotalDownload +CheckSpace +#VerbosePkgLists + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +[staging] +Include = /etc/pacman.d/mirrorlist32 + +[community-staging] +Include = /etc/pacman.d/mirrorlist32 + +[testing] +Include = /etc/pacman.d/mirrorlist32 + +[community-testing] +Include = /etc/pacman.d/mirrorlist32 + +[core] +Include = /etc/pacman.d/mirrorlist32 + +[extra] +Include = /etc/pacman.d/mirrorlist32 + +[community] +Include = /etc/pacman.d/mirrorlist32 diff --git a/pkgapi/pkginfo.php b/pkgapi/pkginfo.php new file mode 100644 index 0000000..d9301ed --- /dev/null +++ b/pkgapi/pkginfo.php @@ -0,0 +1,53 @@ +<?php +require_once "../init.php"; + +include BASE . "/lib/http.php"; + +foreach (array('arch', 'repo', 'pkgname') as $must_have_key) { + if (!array_key_exists($must_have_key, $_GET)) + throw_http_error(400, 'Malformed request', 'Key ' . $must_have_key . ' was not given.'); + if (!preg_match('/^[-+_.a-zA-Z0-9]+$/', $_GET[$must_have_key])) + throw_http_error(400, 'Malformed request', 'Value for ' . $must_have_key . ' is invalid.'); +} + +if (($_GET['arch'] != 'i486') && ($_GET['arch'] != 'i686')) + throw_http_error(400, 'Malformed request', 'Architecture ' . $_GET['arch'] . ' is unkown.'); + +$infos = trim( + shell_exec( + 'pacinfo' . + ' --config=' . BASE . '/pkgapi/pacman-' . $_GET['arch'] . '.conf ' . + $_GET['repo'] . '/' . + $_GET['pkgname'] . + ' | grep "^Build Date:"; ' . + 'pacinfo' . + ' --raw' . + ' --config=' . BASE . '/pkgapi/pacman-' . $_GET['arch'] . '.conf ' . + $_GET['repo'] . '/' . + $_GET['pkgname'] . + ' | grep -v "^Build Date:"' + ) +); + +if (!isset($infos)) + throw_http_error(404, 'Package not found.'); + +function parse_pacinfo_line($line) { + return preg_split('/: +/', $line, 2); +} + +function extract_first($array) { + return $array[0]; +} + +$infos = explode("\n", $infos); +$infos = array_map('parse_pacinfo_line', $infos); +$merged_infos = array(); +foreach ($infos as $info) + $merged_infos = array_merge_recursive($merged_infos, array($info[0] => $info[1])); + +header ("Content-type: application/json"); +print json_encode( + $merged_infos, + JSON_UNESCAPED_SLASHES +); |