Simple wrapper for perl5 with LD_PRELOAD=libthr for amanda 3.*.

This commit is contained in:
Jun Kuriyama 2010-11-01 13:52:47 +00:00
parent 1bd12469d8
commit bbde95d76e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=263893
4 changed files with 65 additions and 0 deletions

View file

@ -9,6 +9,7 @@
SUBDIR += airoflash
SUBDIR += alevt
SUBDIR += amanda-client
SUBDIR += amanda-perl-wrapper
SUBDIR += amanda-server
SUBDIR += amanda25-client
SUBDIR += amanda25-server

View file

@ -0,0 +1,39 @@
# New ports collection makefile for: amanda-perl-wrapper
# Date created: 1 Nov 2010
# Whom: Jun Kuriyama <kuriyama@FreeBSD.org>
#
# $FreeBSD$
#
PORTNAME= amanda-perl-wrapper
PORTVERSION= 1.00
CATEGORIES= misc perl5
MASTER_SITES= # empty
DISTFILES= # empty
MAINTAINER= kuriyama@FreeBSD.org
COMMENT= Perl wrapper to use with Amanda (with libthr.so.* linked)
USE_PERL5_RUN= yes
SUB_FILES= perl-amanda.c
SUB_LIST= PREFIX=${LOCALBASE}
PLIST_FILES= bin/perl-amanda
WRKSRC= ${WRKDIR}
do-fetch:
@${DO_NADA}
pre-build: apply-slist
do-build:
cd ${WRKSRC} && ${CC} -o perl-amanda perl-amanda.c
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/perl-amanda ${PREFIX}/bin/
.include <bsd.port.pre.mk>
LIBTHR!= ${LS} /lib/libthr.so.* | ${TAIL} -1
SUB_LIST+= LIBTHR=${LIBTHR_CMD}
.include <bsd.port.post.mk>

View file

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char *const argv[], char *const envp[])
{
int i, len = 0;
char **argv2 = malloc(sizeof(char*) * (argc + 1));
argv2[0] = "%%LOCALBASE%%/bin/perl";
for (i = 1; i < argc + 1; i++) {
argv2[i] = argv[i];
}
for (i = 0; envp[i]; i++) {
len++;
}
char **envp2 = malloc(sizeof(char*) * (len + 2));
envp2[0] = "LD_PRELOAD=%%LIBTHR%%";
/* Copy last null, too. */
for (i = 0; i < len + 1; i++) {
envp2[i + 1] = envp[i];
}
return execve(argv2[0], argv2, envp2);
}

View file

@ -0,0 +1 @@
Simple wrapper for perl5 with LD_PRELOAD=libthr.