Import mktorrent, a command-line .torrent file creator.

ok sthen@
This commit is contained in:
stsp 2009-03-10 13:43:05 +00:00
parent f19dfd412b
commit 1e192eed8c
6 changed files with 196 additions and 0 deletions

30
net/mktorrent/Makefile Normal file
View File

@ -0,0 +1,30 @@
# $OpenBSD: Makefile,v 1.1.1.1 2009/03/10 13:43:05 stsp Exp $
COMMENT = command-line .torrent file creator
DISTNAME = mktorrent-0.9.9
CATEGORIES = net
HOMEPAGE = http://borg.uu3.net/~borg/
MAINTAINER = Stefan Sperling <stsp@openbsd.org>
# BSD-like
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
WANTLIB = c crypto
MASTER_SITES = ftp://borg.uu3.net/pub/unix/mktorrent/
EXTRACT_SUFX = .tgz
NO_REGRESS = Yes
WRKDIST = ${WRKDIR}/mktorrent
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/mktorrent ${PREFIX}/bin
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/mktorrent
${INSTALL_DATA} ${WRKSRC}/LICENSE ${PREFIX}/share/doc/mktorrent
.include <bsd.port.mk>

5
net/mktorrent/distinfo Normal file
View File

@ -0,0 +1,5 @@
MD5 (mktorrent-0.9.9.tgz) = i9+jaYJEbzzNhUn+3vt0SA==
RMD160 (mktorrent-0.9.9.tgz) = ZLQ2ub5cTSZ2oXwoSg2zVyZtLyI=
SHA1 (mktorrent-0.9.9.tgz) = bkM0CXrh4a6abQGcE2QL1jVeJgU=
SHA256 (mktorrent-0.9.9.tgz) = 2dw40T3/6BfE4gycSJsORqDyua4rwDZ9Xmu6jlzd6D8=
SIZE (mktorrent-0.9.9.tgz) = 6087

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-Makefile,v 1.1.1.1 2009/03/10 13:43:05 stsp Exp $
--- Makefile.orig Thu Mar 27 18:38:06 2008
+++ Makefile Tue Mar 10 12:21:21 2009
@@ -1,24 +1,14 @@
-CC=gcc
-
-# Default
-CFLAGS = -w -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFS64
-LFLAGS =
+CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFS64
LIBS = -lcrypto
-# Default (no large file support)
-#CFLAGS = -w -O2
-#LFLAGS =
-#LIBS = -lcrypto
-
-
APPN = mktorrent
OBJS = mktorrent.o
.c.o:
- $(CC) $(CFLAGS) -c $?
+ $(CC) $(CFLAGS) $(DEBUG) -c $?
all: $(OBJS)
- $(CC) $(LFLAGS) -o $(APPN) $(OBJS) $(LIBS)
+ $(CC) $(LDFLAGS) -o $(APPN) $(OBJS) $(LIBS)
clean:
rm *.o

View File

@ -0,0 +1,124 @@
$OpenBSD: patch-mktorrent_c,v 1.1.1.1 2009/03/10 13:43:05 stsp Exp $
--- mktorrent.c.orig Thu Mar 27 18:38:06 2008
+++ mktorrent.c Tue Mar 10 11:53:08 2009
@@ -50,8 +50,6 @@ char *path;
void *link;
};
-static char str[1024];
-
static char *name;
static char *announce;
static char *announce_list[AL_MAX+1];
@@ -62,7 +60,7 @@ static int bs;
static int flags;
#define benc_raw(f,s) fprintf(f,"%s",s)
-#define benc_str(f,s) fprintf(f,"%u:%s",strlen(s),s)
+#define benc_str(f,s) fprintf(f,"%zd:%s",strlen(s),s)
#define benc_int(f,i) fprintf(f,"i%de",i)
#define benc_int64(f,i) fprintf(f,"i%llde",i)
@@ -301,7 +299,7 @@ if(totalsize%bs)
benc_str(fo,"pieces");
fprintf(fo,"%lld:",pieces*SHA_DIGEST_LENGTH);
-printf("Creating torrent file...\n",out_fn);
+printf("Creating %s\n",out_fn);
if((f=open(file->fn,MO_RDONLY))==-1)
{
fclose(fo);
@@ -312,7 +310,7 @@ if((f=open(file->fn,MO_RDONLY))==-1)
exit(1);
}
otm=time(0);
-fprintf(stdout,"done: %3d%%",cps);
+fprintf(stdout,"done: %3ld%%",cps);
fflush(stdout);
while((r=read(f,buf,bs))>0)
{
@@ -323,14 +321,14 @@ while((r=read(f,buf,bs))>0)
ctm=time(0);
if(ctm!=otm && cps!=ops)
{
- fprintf(stdout,"\rdone: %3d%%",cps);
+ fprintf(stdout,"\rdone: %3ld%%",cps);
fflush(stdout);
ops=cps;
otm=ctm;
}
}
close(f);
-fprintf(stdout,"\rdone: %3d%%\n",cps);
+fprintf(stdout,"\rdone: %3ld%%\n",cps);
fflush(stdout);
if(r<0)
{
@@ -446,9 +444,9 @@ if(totalsize%bs)
benc_str(fo,"pieces");
fprintf(fo,"%lld:",pieces*SHA_DIGEST_LENGTH);
-printf("Creating torrent file...\n",out_fn);
+printf("Creating %s\n", out_fn);
otm=time(0);
-fprintf(stdout,"done: %3d%%",cps);
+fprintf(stdout,"done: %3ld%%",cps);
fflush(stdout);
f=0;
ptr=filelist;
@@ -472,7 +470,7 @@ while(ptr)
ctm=time(0);
if(ctm!=otm && cps!=ops)
{
- fprintf(stdout,"\rdone: %3d%%",cps);
+ fprintf(stdout,"\rdone: %3ld%%",cps);
fflush(stdout);
ops=cps;
otm=ctm;
@@ -523,7 +521,7 @@ while(ptr)
ctm=time(0);
if(ctm!=otm && cps!=ops)
{
- fprintf(stdout,"\rdone: %3d%%",cps);
+ fprintf(stdout,"\rdone: %3ld%%",cps);
fflush(stdout);
ops=cps;
otm=ctm;
@@ -532,7 +530,7 @@ while(ptr)
if(!f)
ptr=ptr->link;
}
-fprintf(stdout,"\rdone: %3d%%\n",cps);
+fprintf(stdout,"\rdone: %3ld%%\n",cps);
fflush(stdout);
if(!(flags&F_PUB))
{
@@ -547,9 +545,10 @@ free(sha);
free_files();
}
-static char mycmpi(char *s1,char *s2)
+static int mycmpi(char *s1,char *s2)
{
-char c1,c2,r;
+char c1,c2;
+int r;
while(*s1 && *s2)
{
@@ -559,6 +558,7 @@ while(*s1 && *s2)
return r;
s1++,s2++;
}
+return 0;
}
static int mydcmpi(char *s1,char *s2)
@@ -576,6 +576,7 @@ while(*s1 && *s2)
d++;
s1++,s2++;
}
+return d;
}
static void add_file(char *fn,char *tp,struct stat *st)

2
net/mktorrent/pkg/DESCR Normal file
View File

@ -0,0 +1,2 @@
mktorrent is a command-line .torrent file creator.
It supports multi trackers (tier groups).

4
net/mktorrent/pkg/PLIST Normal file
View File

@ -0,0 +1,4 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2009/03/10 13:43:05 stsp Exp $
@bin bin/mktorrent
share/doc/mktorrent/
share/doc/mktorrent/LICENSE