ftp客戶端移植(基於netkit-ftp-0.17.tar.gz)

使用busybox製作的根文件系統,沒有ftp客戶端工具,無法登錄到其他的ftp服務器,需要自己編譯ftp指令。

在這裏採用源碼包netkit-ftp-0.17.tar.gz編譯,步驟如下:

1、tar解壓

2、打補丁

patch -p1< netkit-ftp-0.17-cross.patch

在源碼目錄下,建立上述名字的補丁文件,內容如下:


diff -Naur netkit-ftp-0.17.orig/configure netkit-ftp-0.17/configure
--- netkit-ftp-0.17.orig/configure 2008-01-21 15:27:56.000000000 -0500
+++ netkit-ftp-0.17/configure 2008-01-21 15:27:58.000000000 -0500
@@ -93,7 +93,6 @@
echo 'no'
echo 'Compiler '"$CC"' does not exist or cannot compile C; try another.'
rm -f __conftest*
- exit
fi
fi

@@ -180,7 +179,6 @@
echo 'no'
echo 'This package needs BSD signal semantics to run.'
rm -f __conftest*
- exit
fi
fi
rm -f __conftest*
@@ -238,7 +236,6 @@
echo 'not found'
echo 'This package needs termcap to run.'
rm -f __conftest*
- exit
fi
fi
rm -f __conftest*
@@ -323,7 +320,6 @@
echo 'no'
echo 'Cannot work out what to use for socklen_t. Help...'
rm -f __conftest*
- exit
fi
fi
fi
@@ -400,7 +396,6 @@
echo 'missing'
echo 'This package requires snprintf.'
rm -f __conftest*
- exit
fi
fi
fi
diff -Naur netkit-ftp-0.17.orig/ftp/cmds.c netkit-ftp-0.17/ftp/cmds.c
--- netkit-ftp-0.17.orig/ftp/cmds.c 2008-01-21 15:27:56.000000000 -0500
+++ netkit-ftp-0.17/ftp/cmds.c 2008-01-21 15:27:58.000000000 -0500
@@ -68,6 +68,10 @@
#include "cmds.h"
#include "glob.h"

+#ifndef index
+#define index strchr
+#endif
+
void intr(int);

extern FILE *cout;
diff -Naur netkit-ftp-0.17.orig/ftp/ftp.c netkit-ftp-0.17/ftp/ftp.c
--- netkit-ftp-0.17.orig/ftp/ftp.c 2008-01-21 15:27:56.000000000 -0500
+++ netkit-ftp-0.17/ftp/ftp.c 2008-01-21 15:27:58.000000000 -0500
@@ -65,6 +65,13 @@

#include "../version.h"

+#ifndef index
+#define index strchr
+#endif
+#ifndef rindex
+#define rindex strrchr
+#endif
+
int data = -1;
off_t restart_point = 0;

diff -Naur netkit-ftp-0.17.orig/ftp/Makefile netkit-ftp-0.17/ftp/Makefile
--- netkit-ftp-0.17.orig/ftp/Makefile 2008-01-21 15:27:56.000000000 -0500
+++ netkit-ftp-0.17/ftp/Makefile 2008-01-21 15:30:01.000000000 -0500
@@ -16,11 +16,12 @@
cmds.o glob.o: glob.h

install: ftp
- install -s -m$(BINMODE) ftp $(INSTALLROOT)$(BINDIR)
- ln -sf ftp $(INSTALLROOT)$(BINDIR)/pftp
- install -m$(MANMODE) ftp.1 $(INSTALLROOT)$(MANDIR)/man1
- ln -sf ftp.1 $(INSTALLROOT)$(MANDIR)/man1/pftp.1
- install -m$(MANMODE) netrc.5 $(INSTALLROOT)$(MANDIR)/man5
+ mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man{1,5}
+ install -m$(BINMODE) ftp $(DESTDIR)$(BINDIR)
+ cd $(DESTDIR)$(BINDIR)/ && ln -sf ftp pftp
+ install -m$(MANMODE) ftp.1 $(DESTDIR)$(MANDIR)/man1
+ cd $(DESTDIR)$(MANDIR)/man1 && ln -sf ftp.1 pftp.1
+ install -m$(MANMODE) netrc.5 $(DESTDIR)$(MANDIR)/man5

clean:
rm -f *.o ftp
diff -Naur netkit-ftp-0.17.orig/ftp/ruserpass.c netkit-ftp-0.17/ftp/ruserpass.c
--- netkit-ftp-0.17.orig/ftp/ruserpass.c 2008-01-21 15:27:56.000000000 -0500
+++ netkit-ftp-0.17/ftp/ruserpass.c 2008-01-21 15:27:58.000000000 -0500
@@ -58,6 +58,10 @@
#define ID 10
#define MACH 11

+#ifndef index
+#define index strchr
+#endif
+
static char tokval[100];

static struct toktab {


3、指定交叉編譯工具,進行configure

./configure --with-c-compiler=arm-none-linux-gnueabi-gcc 


4、make

make時可能出現以下錯誤:

glob.c: In function 'ftpglob':
glob.c:126:15: error: 'ARG_MAX' undeclared (first use in this function)
glob.c:126:15: note: each undeclared identifier is reported only once for each function it appears in
glob.c: In function 'ginit':
glob.c:167:11: error: 'ARG_MAX' undeclared (first use in this function)
glob.c: In function 'Gcat':
glob.c:582:32: error: 'ARG_MAX' undeclared (first use in this function)
make[1]: *** [glob.o] 錯誤 1
make[1]:正在離開目錄 `/home/am335x/package/netkit-ftp-0.17/ftp'
make: *** [ftp.build] 錯誤 2

從網上查找解決方法如下:

修改glob.c,#include “glob.h”添加:

#if define (_POSIX_ARG_MAX)

       #if define (ARG_MAX)

     #undef ARG_MAX

#endif

#endif

但是經過實驗,問題依然沒有解決。

。。。。(待尋找正確、合理的方法解決)。。。。。


5、將編譯的ftp指令上傳到根文件系統,測試一下看看:

ftp: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory

ftp: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

ftp: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

分別在交叉編譯工具的庫中找到上述3個庫,拷貝到根文件系統的lib目錄下。

接下來可以正常的從ftp服務器get想要的文件了。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章