Added support for using noarch packages.
--HG-- extra : convert_revision : a96166ddecb6efe65d35283f25e06a944cc4a038
This commit is contained in:
parent
4f6364a2bd
commit
6b6162bb44
|
@ -175,7 +175,7 @@ main(int argc, char **argv)
|
|||
exit(EXIT_FAILURE);
|
||||
|
||||
/* Temp buffer to verify pkgindex file. */
|
||||
plist = xbps_append_full_path(false, dpkgidx, XBPS_PKGINDEX);
|
||||
plist = xbps_get_pkg_index_plist(dpkgidx);
|
||||
if (plist == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2008 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2009 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -133,7 +133,7 @@ search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
|
|||
repofile = prop_string_cstring_nocopy(obj);
|
||||
assert(repofile != NULL);
|
||||
|
||||
plist = xbps_append_full_path(false, repofile, XBPS_PKGINDEX);
|
||||
plist = xbps_get_pkg_index_plist(repofile);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
@ -165,8 +165,7 @@ show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
|
|||
/* Get the location */
|
||||
repofile = prop_string_cstring_nocopy(obj);
|
||||
|
||||
/* Get string for pkg-index.plist with full path. */
|
||||
plist = xbps_append_full_path(false, repofile, XBPS_PKGINDEX);
|
||||
plist = xbps_get_pkg_index_plist(repofile);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
|
2
doc/TODO
2
doc/TODO
|
@ -8,8 +8,6 @@ xbps-src:
|
|||
* Add support to run the prepost-* scripts, so that the same actions are
|
||||
performed in source/bin packages. Use current postinstall_helpers to
|
||||
automatically add triggers, shared by src/bin pkgs. [IN PROGRESS]
|
||||
* Build non-arch pkgs with the suffix 'noarch' and create the binpkgs
|
||||
into another subdirectory inside of $XBPS_PACKAGESDIR.
|
||||
|
||||
xbps-cmpver:
|
||||
* It fails in some cases: foo-2.0 vs foo-1.99 and foo-2a vs foo-2b.
|
||||
|
|
|
@ -30,8 +30,9 @@
|
|||
char * xbps_append_full_path(bool, const char *, const char *);
|
||||
int xbps_check_is_installed_pkg(const char *);
|
||||
bool xbps_check_is_installed_pkgname(const char *);
|
||||
const char * xbps_get_pkg_version(const char *);
|
||||
char * xbps_get_pkg_index_plist(const char *);
|
||||
char * xbps_get_pkg_name(const char *);
|
||||
const char * xbps_get_pkg_version(const char *);
|
||||
bool xbps_pkg_has_rundeps(prop_dictionary_t);
|
||||
void xbps_set_rootdir(const char *);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd,
|
|||
prop_string_t reqbystr;
|
||||
uint32_t prio = 0;
|
||||
size_t len = 0, dirdepscnt = 0, indirdepscnt = 0;
|
||||
const char *pkgname, *version, *reqbyname, *reqbyver;
|
||||
const char *pkgname, *version, *reqbyname, *reqbyver, *arch;
|
||||
const char *repoloc, *binfile, *originpkg, *short_desc;
|
||||
char *reqby, *pkgnver;
|
||||
int rv = 0;
|
||||
|
@ -113,6 +113,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd,
|
|||
prop_dictionary_get_cstring_nocopy(depd, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(depd, "filename", &binfile);
|
||||
prop_dictionary_get_cstring_nocopy(depd, "short_desc", &short_desc);
|
||||
prop_dictionary_get_cstring_nocopy(depd, "architecture", &arch);
|
||||
prop_dictionary_get_uint32(depd, "priority", &prio);
|
||||
prop_dictionary_get_cstring_nocopy(origind, "pkgname", &reqbyname);
|
||||
prop_dictionary_get_cstring_nocopy(origind, "version", &reqbyver);
|
||||
|
@ -203,6 +204,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd,
|
|||
prop_dictionary_set_uint32(dict, "priority", prio);
|
||||
prop_dictionary_set_cstring(dict, "short_desc", short_desc);
|
||||
prop_dictionary_set_bool(dict, "indirect_dep", indirectdep);
|
||||
prop_dictionary_set_cstring(dict, "architecture", arch);
|
||||
|
||||
/*
|
||||
* Add the dictionary into the array.
|
||||
|
@ -335,8 +337,8 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
|||
* all available binary packages.
|
||||
*/
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
plist = xbps_append_full_path(false,
|
||||
prop_string_cstring_nocopy(obj), XBPS_PKGINDEX);
|
||||
plist =
|
||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||
if (plist == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
|
@ -377,8 +379,8 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
|||
*/
|
||||
prop_object_iterator_reset(iter);
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
plist = xbps_append_full_path(false,
|
||||
prop_string_cstring_nocopy(obj), XBPS_PKGINDEX);
|
||||
plist =
|
||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||
if (plist == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
|
|
|
@ -107,8 +107,7 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
|||
char *plist;
|
||||
int rv = 0;
|
||||
|
||||
plist = xbps_append_full_path(false,
|
||||
prop_string_cstring_nocopy(obj), XBPS_PKGINDEX);
|
||||
plist = xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
|
19
lib/unpack.c
19
lib/unpack.c
|
@ -56,25 +56,34 @@ xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg,
|
|||
const char *destdir,
|
||||
void (*cb_print)(prop_dictionary_t))
|
||||
{
|
||||
prop_string_t filename, repoloc;
|
||||
char *binfile;
|
||||
prop_string_t filename, repoloc, arch;
|
||||
char *binfile, *path;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkg != NULL);
|
||||
|
||||
/* Append filename to the full path for binary pkg */
|
||||
filename = prop_dictionary_get(pkg, "filename");
|
||||
arch = prop_dictionary_get(pkg, "architecture");
|
||||
if (repo)
|
||||
repoloc = prop_dictionary_get(repo, "location-local");
|
||||
else
|
||||
repoloc = prop_dictionary_get(pkg, "repository");
|
||||
|
||||
binfile = xbps_append_full_path(false,
|
||||
path = xbps_append_full_path(false,
|
||||
prop_string_cstring_nocopy(repoloc),
|
||||
prop_string_cstring_nocopy(filename));
|
||||
if (binfile == NULL)
|
||||
prop_string_cstring_nocopy(arch));
|
||||
if (path == NULL)
|
||||
return EINVAL;
|
||||
|
||||
binfile = xbps_append_full_path(false, path,
|
||||
prop_string_cstring_nocopy(filename));
|
||||
if (binfile == NULL) {
|
||||
free(path);
|
||||
return EINVAL;
|
||||
}
|
||||
free(path);
|
||||
|
||||
if (!cb_print)
|
||||
unpack_defcb_print(pkg);
|
||||
else
|
||||
|
|
26
lib/util.c
26
lib/util.c
|
@ -29,6 +29,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
|
||||
|
@ -141,6 +142,31 @@ xbps_get_pkg_name(const char *pkg)
|
|||
return pkgname;
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_pkg_index_plist(const char *path)
|
||||
{
|
||||
struct utsname un;
|
||||
char *plist, *p;
|
||||
|
||||
assert(path != NULL);
|
||||
|
||||
if (uname(&un) == -1)
|
||||
return NULL;
|
||||
|
||||
p = xbps_append_full_path(false, path, un.machine);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
plist = xbps_append_full_path(false, p, XBPS_PKGINDEX);
|
||||
if (plist == NULL) {
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
free(p);
|
||||
|
||||
return plist;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkg_has_rundeps(prop_dictionary_t pkg)
|
||||
{
|
||||
|
|
|
@ -43,23 +43,23 @@ write_repo_pkgindex()
|
|||
[ -z "$repodir" ] && repodir=$XBPS_PACKAGESDIR
|
||||
[ ! -d $repodir ] && exit 1
|
||||
|
||||
found="$(echo $repodir/*)"
|
||||
found="$(echo $repodir/$xbps_machine/*)"
|
||||
if $(echo $found|grep -vq .xbps); then
|
||||
msg_error "couldn't find binary packages on $repodir."
|
||||
fi
|
||||
|
||||
pkgindexf=$(mktemp -t pkgidx.XXXXXXXXXX) || exit 1
|
||||
tmppkgdir=$(mktemp -d -t pkgdir.XXXXXXXX) || exit 1
|
||||
pkgindexf=$(mktemp -t xbps-pkgidx.XXXXXXXXXX) || exit 1
|
||||
tmppkgdir=$(mktemp -d -t xbps-pkgdir.XXXXXXXX) || exit 1
|
||||
|
||||
# Write the header.
|
||||
msg_normal "Creating package index for $repodir..."
|
||||
write_repo_pkgindex_header $pkgindexf $repodir
|
||||
|
||||
#
|
||||
# Write pkg dictionaries from all packages currently available at
|
||||
# XBPS_PACKAGESDIR.
|
||||
# Write pkg dictionaries for all packages currently available at
|
||||
# XBPS_PACKAGESDIR, both for your cpu arch and non arch dependent.
|
||||
#
|
||||
for i in $(echo $repodir/*.xbps); do
|
||||
for i in $(find $repodir/$xbps_machine -type f -name \*.xbps); do
|
||||
pkgname="$(basename ${i%%-[0-9]*.*.$xbps_machine.xbps})"
|
||||
propsf="./var/db/xbps/metadata/$pkgname/props.plist"
|
||||
cd $tmppkgdir && tar xfjp $i $propsf
|
||||
|
@ -67,7 +67,26 @@ write_repo_pkgindex()
|
|||
msg_warn "Couldn't extract $(basename $i) metadata!"
|
||||
continue
|
||||
fi
|
||||
write_repo_pkgindex_dict $propsf $pkgindexf $(basename $i)
|
||||
write_repo_pkgindex_dict $propsf $pkgindexf $(basename $i) \
|
||||
$xbps_machine
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_warn "Couldn't write $i metadata to index file!"
|
||||
continue
|
||||
fi
|
||||
echo "$(basename $i) added."
|
||||
pkgsum=$(($pkgsum + 1))
|
||||
done
|
||||
|
||||
for i in $(find $repodir/noarch -type f -name \*.xbps); do
|
||||
pkgname="$(basename ${i%%-[0-9]*.*.noarch.xbps})"
|
||||
propsf="./var/db/xbps/metadata/$pkgname/props.plist"
|
||||
cd $tmppkgdir && tar xfjp $i $propsf
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_warn "Couldn't extract $(basename $i) metadata!"
|
||||
continue
|
||||
fi
|
||||
write_repo_pkgindex_dict $propsf $pkgindexf $(basename $i) \
|
||||
noarch
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_warn "Couldn't write $i metadata to index file!"
|
||||
continue
|
||||
|
@ -85,7 +104,7 @@ write_repo_pkgindex()
|
|||
exit 1
|
||||
fi
|
||||
msg_normal "Package index created (total pkgs: $pkgsum)."
|
||||
cp -f $pkgindexf $repodir/pkg-index.plist
|
||||
cp -f $pkgindexf $repodir/$xbps_machine/pkg-index.plist
|
||||
fi
|
||||
rm -f $pkgindexf
|
||||
rm -rf $tmppkgdir
|
||||
|
@ -140,14 +159,15 @@ write_repo_pkgindex_dict()
|
|||
local pkgf="$1"
|
||||
local indexf="$2"
|
||||
local binpkgf="$3"
|
||||
local arch="$4"
|
||||
local first_dict=
|
||||
local tmpdictf=
|
||||
local binpkg="$XBPS_PACKAGESDIR/$binpkgf"
|
||||
local getsize=$(du $binpkg|awk '{print $1}')
|
||||
local binpkg="$XBPS_PACKAGESDIR/$arch/$binpkgf"
|
||||
local getsize=$(du -b $binpkg|awk '{print $1}')
|
||||
|
||||
[ -z "$pkgf" -o -z "$indexf" -o -z "$binpkgf" ] && return 1
|
||||
|
||||
tmpdictf=$(mktemp -t pkgdict.XXXXXXXXXX) || exit 1
|
||||
tmpdictf=$(mktemp -t xbps-pkgdict.XXXXXXXXXX) || exit 1
|
||||
|
||||
cat $pkgf | while read line; do
|
||||
# Find the first dictionary.
|
||||
|
|
|
@ -32,6 +32,7 @@ xbps_write_metadata_pkg()
|
|||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
local metadir=$destdir/var/db/xbps/metadata/$pkgname
|
||||
local prioinst=
|
||||
local arch=
|
||||
|
||||
if [ ! -d "$destdir" ]; then
|
||||
echo "ERROR: $pkgname not installed into destdir."
|
||||
|
@ -44,6 +45,12 @@ xbps_write_metadata_pkg()
|
|||
prioinst=0
|
||||
fi
|
||||
|
||||
if [ -n "$noarch" ]; then
|
||||
arch=noarch
|
||||
else
|
||||
arch=$xbps_machine
|
||||
fi
|
||||
|
||||
# Write the files list.
|
||||
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
|
||||
# First add the regular files.
|
||||
|
@ -66,7 +73,7 @@ xbps_write_metadata_pkg()
|
|||
<key>version</key>
|
||||
<string>$version</string>
|
||||
<key>architecture</key>
|
||||
<string>$xbps_machine</string>
|
||||
<string>$arch</string>
|
||||
<key>priority</key>
|
||||
<integer>$prioinst</integer>
|
||||
<key>installed_size</key>
|
||||
|
@ -144,14 +151,24 @@ _EOF
|
|||
xbps_make_binpkg()
|
||||
{
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
local binpkg=$pkgname-$version.$xbps_machine.xbps
|
||||
|
||||
local binpkg=
|
||||
local pkgdir=
|
||||
local arch=
|
||||
cd $destdir || exit 1
|
||||
|
||||
if [ -n "$noarch" ]; then
|
||||
arch=noarch
|
||||
else
|
||||
arch=$xbps_machine
|
||||
fi
|
||||
|
||||
binpkg=$pkgname-$version.$arch.xbps
|
||||
pkgdir=$XBPS_PACKAGESDIR/$arch
|
||||
|
||||
run_rootcmd tar cfjp $XBPS_DESTDIR/$binpkg .
|
||||
if [ $? -eq 0 ]; then
|
||||
[ ! -d $XBPS_PACKAGESDIR ] && mkdir -p $XBPS_PACKAGESDIR
|
||||
mv -f $XBPS_DESTDIR/$binpkg $XBPS_PACKAGESDIR
|
||||
[ ! -d $pkgdir ] && mkdir -p $pkgdir
|
||||
mv -f $XBPS_DESTDIR/$binpkg $pkgdir
|
||||
echo "=> Built package: $binpkg"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user