|
|
4a01cf |
/*******************************************************************/
|
|
|
4a01cf |
/* slibtool: a skinny libtool implementation, written in C */
|
|
|
49181b |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
4a01cf |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
4a01cf |
/*******************************************************************/
|
|
|
4a01cf |
|
|
|
4a01cf |
#include <slibtool/slibtool.h>
|
|
|
c81d16 |
#include "slibtool_driver_impl.h"
|
|
|
c1e423 |
#include "slibtool_symlink_impl.h"
|
|
|
8a1d14 |
#include "slibtool_errinfo_impl.h"
|
|
|
4a01cf |
|
|
|
89caff |
/* legacy fallback, no longer in use */
|
|
|
65cb35 |
extern int slbt_archive_import_mri(
|
|
|
65cb35 |
const struct slbt_driver_ctx * dctx,
|
|
|
65cb35 |
struct slbt_exec_ctx * ectx,
|
|
|
65cb35 |
char * dstarchive,
|
|
|
65cb35 |
char * srcarchive);
|
|
|
4a01cf |
|
|
|
89caff |
/* use slibtool's in-memory archive merging facility */
|
|
|
89caff |
static int slbt_archive_import_impl(
|
|
|
89caff |
const struct slbt_driver_ctx * dctx,
|
|
|
89caff |
struct slbt_exec_ctx * ectx,
|
|
|
89caff |
char * dstarchive,
|
|
|
89caff |
char * srcarchive)
|
|
|
89caff |
{
|
|
|
89caff |
int ret;
|
|
|
89caff |
struct slbt_archive_ctx * arctxv[3] = {0,0,0};
|
|
|
89caff |
struct slbt_archive_ctx * arctx;
|
|
|
89caff |
|
|
|
89caff |
(void)ectx;
|
|
|
89caff |
|
|
|
89caff |
if (slbt_get_archive_ctx(dctx,dstarchive,&arctxv[0]) < 0)
|
|
|
89caff |
return SLBT_NESTED_ERROR(dctx);
|
|
|
89caff |
|
|
|
89caff |
if (slbt_get_archive_ctx(dctx,srcarchive,&arctxv[1]) < 0) {
|
|
|
89caff |
slbt_free_archive_ctx(arctxv[0]);
|
|
|
89caff |
return SLBT_NESTED_ERROR(dctx);
|
|
|
89caff |
}
|
|
|
89caff |
|
|
|
89caff |
ret = slbt_merge_archives(arctxv,&arctx);
|
|
|
89caff |
|
|
|
89caff |
slbt_free_archive_ctx(arctxv[0]);
|
|
|
89caff |
slbt_free_archive_ctx(arctxv[1]);
|
|
|
89caff |
|
|
|
89caff |
if (ret == 0) {
|
|
|
89caff |
ret = slbt_store_archive(arctx,dstarchive,0644);
|
|
|
89caff |
slbt_free_archive_ctx(arctx);
|
|
|
89caff |
}
|
|
|
89caff |
|
|
|
89caff |
return (ret < 0) ? SLBT_NESTED_ERROR(dctx) : 0;
|
|
|
89caff |
}
|
|
|
89caff |
|
|
|
89caff |
|
|
|
cfec3a |
int slbt_archive_import(
|
|
|
4a01cf |
const struct slbt_driver_ctx * dctx,
|
|
|
4a01cf |
struct slbt_exec_ctx * ectx,
|
|
|
4a01cf |
char * dstarchive,
|
|
|
4a01cf |
char * srcarchive)
|
|
|
4a01cf |
{
|
|
|
c1e423 |
if (slbt_symlink_is_a_placeholder(
|
|
|
c1e423 |
slbt_driver_fdcwd(dctx),
|
|
|
c1e423 |
srcarchive))
|
|
|
c1e423 |
return 0;
|
|
|
c1e423 |
|
|
|
89caff |
return slbt_archive_import_impl(
|
|
|
65cb35 |
dctx,ectx,
|
|
|
65cb35 |
dstarchive,
|
|
|
65cb35 |
srcarchive);
|
|
|
4a01cf |
}
|