Browse Source

Merged revisions 7323,7519,7521,7530,7539,7542-7543 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r7323 | Almindor | 2007-05-13 11:04:46 +0200 (Sun, 13 May 2007) | 2 lines

* update lNet so latest fpc can compile it (property changes)

........
r7519 | Almindor | 2007-05-29 19:35:04 +0200 (Tue, 29 May 2007) | 2 lines

* update lnet to 0.5.1 (fixes some potential bugs in ftp and smtp)

........
r7521 | peter | 2007-05-29 22:56:59 +0200 (Tue, 29 May 2007) | 4 lines

* avail,scan commands added
* finished createarchive command, compresses still the whole source
dir instead of using files from a specified input list

........
r7530 | peter | 2007-05-30 20:36:12 +0200 (Wed, 30 May 2007) | 2 lines

* remove dependency on fpmktype

........
r7539 | peter | 2007-05-31 21:55:26 +0200 (Thu, 31 May 2007) | 2 lines

* fpmake to fpmkunit package

........
r7542 | peter | 2007-05-31 22:54:26 +0200 (Thu, 31 May 2007) | 2 lines

* detection of installed fpc added

........
r7543 | peter | 2007-06-01 07:49:28 +0200 (Fri, 01 Jun 2007) | 2 lines

* remove fpmake require

........

git-svn-id: branches/fixes_2_2@7708 -

peter 18 years ago
parent
commit
5740806aca

+ 1 - 0
.gitattributes

@@ -8371,6 +8371,7 @@ utils/fppkg/pkgmessages.pp svneol=native#text/plain
 utils/fppkg/pkgmkconv.pp svneol=native#text/plain
 utils/fppkg/pkgmkconv.pp svneol=native#text/plain
 utils/fppkg/pkgocurl.pp svneol=native#text/plain
 utils/fppkg/pkgocurl.pp svneol=native#text/plain
 utils/fppkg/pkgoptions.pp svneol=native#text/plain
 utils/fppkg/pkgoptions.pp svneol=native#text/plain
+utils/fppkg/pkgrepos.pp svneol=native#text/plain
 utils/fppkg/pkgsynapse.pp svneol=native#text/plain
 utils/fppkg/pkgsynapse.pp svneol=native#text/plain
 utils/fppkg/pkgwget.pp svneol=native#text/plain
 utils/fppkg/pkgwget.pp svneol=native#text/plain
 utils/fppkg/rep2xml.lpi svneol=native#text/plain
 utils/fppkg/rep2xml.lpi svneol=native#text/plain

+ 4 - 81
utils/fppkg/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/04/08]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/05/31]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
@@ -2184,7 +2184,7 @@ else
 TAROPT=vz
 TAROPT=vz
 TAREXT=.tar.gz
 TAREXT=.tar.gz
 endif
 endif
-override REQUIRE_PACKAGES=rtl fcl-base fcl-xml fpmake libcurl
+override REQUIRE_PACKAGES=rtl fcl-base fcl-xml libcurl
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_HASH=1
@@ -2194,7 +2194,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
@@ -2204,7 +2203,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
@@ -2215,7 +2213,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_WINUNITS=1
 REQUIRE_PACKAGES_WINUNITS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
@@ -2225,7 +2222,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
@@ -2237,7 +2233,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
@@ -2247,7 +2242,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
@@ -2258,7 +2252,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
@@ -2270,7 +2263,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
@@ -2280,7 +2272,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
@@ -2290,7 +2281,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
@@ -2301,7 +2291,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
@@ -2311,7 +2300,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
@@ -2323,7 +2311,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
@@ -2333,7 +2320,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
@@ -2343,7 +2329,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
@@ -2353,7 +2338,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
@@ -2363,7 +2347,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
@@ -2373,7 +2356,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
@@ -2383,7 +2365,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
@@ -2395,7 +2376,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
@@ -2407,7 +2387,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
@@ -2418,7 +2397,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
@@ -2428,7 +2406,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
@@ -2438,7 +2415,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
@@ -2449,7 +2425,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
@@ -2459,7 +2434,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
@@ -2469,7 +2443,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
@@ -2481,7 +2454,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
@@ -2492,7 +2464,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
@@ -2502,7 +2473,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
@@ -2512,7 +2482,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
@@ -2524,7 +2493,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
@@ -2534,7 +2502,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
@@ -2544,7 +2511,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
@@ -2556,7 +2522,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
@@ -2567,7 +2532,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
@@ -2579,7 +2543,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
@@ -2589,7 +2552,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
@@ -2601,7 +2563,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
@@ -2613,7 +2574,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
@@ -2624,7 +2584,6 @@ REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_WINUNITS=1
 REQUIRE_PACKAGES_WINUNITS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
@@ -2634,7 +2593,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
@@ -2646,7 +2604,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
@@ -2656,7 +2613,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
@@ -2666,7 +2622,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
@@ -2676,7 +2631,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
@@ -2686,7 +2640,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
@@ -2696,7 +2649,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
@@ -2706,7 +2658,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
@@ -2718,7 +2669,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
@@ -2730,7 +2680,6 @@ REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_PTHREADS=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
@@ -2740,7 +2689,6 @@ REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_FCL-XML=1
 REQUIRE_PACKAGES_FCL-XML=1
-REQUIRE_PACKAGES_FPMAKE=1
 REQUIRE_PACKAGES_LIBCURL=1
 REQUIRE_PACKAGES_LIBCURL=1
 endif
 endif
 ifdef REQUIRE_PACKAGES_RTL
 ifdef REQUIRE_PACKAGES_RTL
@@ -2951,32 +2899,6 @@ ifdef UNITDIR_FCL-XML
 override COMPILER_UNITDIR+=$(UNITDIR_FCL-XML)
 override COMPILER_UNITDIR+=$(UNITDIR_FCL-XML)
 endif
 endif
 endif
 endif
-ifdef REQUIRE_PACKAGES_FPMAKE
-PACKAGEDIR_FPMAKE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fpmake/Makefile.fpc,$(PACKAGESDIR))))))
-ifneq ($(PACKAGEDIR_FPMAKE),)
-ifneq ($(wildcard $(PACKAGEDIR_FPMAKE)/units/$(TARGETSUFFIX)),)
-UNITDIR_FPMAKE=$(PACKAGEDIR_FPMAKE)/units/$(TARGETSUFFIX)
-else
-UNITDIR_FPMAKE=$(PACKAGEDIR_FPMAKE)
-endif
-ifdef CHECKDEPEND
-$(PACKAGEDIR_FPMAKE)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_FPMAKE) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_FPMAKE)/$(FPCMADE)
-endif
-else
-PACKAGEDIR_FPMAKE=
-UNITDIR_FPMAKE:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fpmake/Package.fpc,$(UNITSDIR)))))
-ifneq ($(UNITDIR_FPMAKE),)
-UNITDIR_FPMAKE:=$(firstword $(UNITDIR_FPMAKE))
-else
-UNITDIR_FPMAKE=
-endif
-endif
-ifdef UNITDIR_FPMAKE
-override COMPILER_UNITDIR+=$(UNITDIR_FPMAKE)
-endif
-endif
 ifdef REQUIRE_PACKAGES_LIBCURL
 ifdef REQUIRE_PACKAGES_LIBCURL
 PACKAGEDIR_LIBCURL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /libcurl/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_LIBCURL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /libcurl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_LIBCURL),)
 ifneq ($(PACKAGEDIR_LIBCURL),)
@@ -3043,7 +2965,7 @@ override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
 endif
 endif
 ifndef CROSSBOOTSTRAP
 ifndef CROSSBOOTSTRAP
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
-override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+override FPCOPT+=-XP$(BINUTILSPREFIX) 
 endif
 endif
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
 override FPCOPT+=-Xr$(RLINKPATH)
 override FPCOPT+=-Xr$(RLINKPATH)
@@ -3271,6 +3193,7 @@ vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
 vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.inc $(COMPILER_INCLUDEDIR)
 vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
 vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
 vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
 vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
 .PHONY: fpc_shared
 .PHONY: fpc_shared

+ 1 - 1
utils/fppkg/Makefile.fpc

@@ -35,7 +35,7 @@ fpcpackage=y
 fpcdir=../..
 fpcdir=../..
 
 
 [require]
 [require]
-packages=fcl-base fcl-xml fpmake libcurl
+packages=fcl-base fcl-xml libcurl
 
 
 [prerules]
 [prerules]
 # Compatibility to compile with 2.0.x
 # Compatibility to compile with 2.0.x

+ 27 - 12
utils/fppkg/fcl20/zipper.pp

@@ -908,12 +908,13 @@ Procedure TZipper.GetFileInfo;
 
 
 Var
 Var
    Info : TSearchRec;
    Info : TSearchRec;
-   I       : Word;
+   I       : Longint;
    NewNode : TZipItem;
    NewNode : TZipItem;
 
 
 
 
 Begin
 Begin
    For I := 0 to FFiles.Count-1 do
    For I := 0 to FFiles.Count-1 do
+    begin
      If FindFirst(FFiles[I], STDATTR, Info)=0 then
      If FindFirst(FFiles[I], STDATTR, Info)=0 then
        try
        try
          NewNode:=TZipItem.Create;
          NewNode:=TZipItem.Create;
@@ -925,6 +926,7 @@ Begin
        finally
        finally
          FindClose(Info);
          FindClose(Info);
        end;
        end;
+     end;  
 end;
 end;
 
 
 Procedure TZipper.OpenOutput;
 Procedure TZipper.OpenOutput;
@@ -972,17 +974,20 @@ Begin
     Crc32 := 0;
     Crc32 := 0;
     Compressed_Size := 0;
     Compressed_Size := 0;
     Uncompressed_Size := Item.Size;
     Uncompressed_Size := Item.Size;
-    FileName_Length := Length(Item.Name);
+    FileName_Length := 0;
     Extra_Field_Length := 0;
     Extra_Field_Length := 0;
   end ;
   end ;
 End;
 End;
 
 
 
 
 Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean;
 Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean;
-
+var
+  ZFileName  : ShortString;
 Begin
 Begin
+  ZFileName:=Item.Path+Item.Name;
   With LocalHdr do
   With LocalHdr do
     begin
     begin
+    FileName_Length := Length(ZFileName);
     Compressed_Size := FZip.Size;
     Compressed_Size := FZip.Size;
     Crc32 := ACRC;
     Crc32 := ACRC;
     Compress_method:=AMethod;
     Compress_method:=AMethod;
@@ -994,7 +999,7 @@ Begin
       end;
       end;
     end;
     end;
   FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr));
   FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr));
-  FOutFile.WriteBuffer(Item.Name[1],Length(Item.Name));
+  FOutFile.WriteBuffer(ZFileName[1],Length(ZFileName));
 End;
 End;
 
 
 
 
@@ -1064,7 +1069,7 @@ end;
 Procedure TZipper.ZipOneFile(Item : TZipItem);
 Procedure TZipper.ZipOneFile(Item : TZipItem);
 
 
 Var
 Var
-  CRC : Integer;
+  CRC : LongWord;
   ZMethod : Word;
   ZMethod : Word;
   ZipStream : TStream;
   ZipStream : TStream;
   TmpFileName : String;
   TmpFileName : String;
@@ -1114,21 +1119,29 @@ Procedure TZipper.ZipAllFiles;
 Var
 Var
    Item : TZipItem;
    Item : TZipItem;
    I : Integer;
    I : Integer;
-
+   filecnt : integer;
 Begin
 Begin
+  if FFiles.Count=0 then
+    exit;
   FZipping:=True;
   FZipping:=True;
   Try
   Try
     GetFileInfo;
     GetFileInfo;
     OpenOutput;
     OpenOutput;
     Try
     Try
+      filecnt:=0;
       For I:=0 to FFiles.Count-1 do
       For I:=0 to FFiles.Count-1 do
         begin
         begin
-        Item:=FFiles.Objects[i] as TZipItem;
-        ZipOneFile(Item);
+          Item:=FFiles.Objects[i] as TZipItem;
+	  if assigned(Item) then
+	    begin
+              ZipOneFile(Item);
+	      inc(filecnt);
+	    end;  
         end;
         end;
-      BuildZipDirectory;
-    Finally
-       CloseOutput;
+      if filecnt>0 then	
+        BuildZipDirectory;
+    finally
+      CloseOutput;
     end;
     end;
   finally
   finally
     FZipping:=False;
     FZipping:=False;
@@ -1357,7 +1370,9 @@ Begin
       For I:=0 to FZipEntries.Count-1 do
       For I:=0 to FZipEntries.Count-1 do
         begin
         begin
           Item:=FZipEntries[i] as TZipItem;
           Item:=FZipEntries[i] as TZipItem;
-          UnZipOneFile(Item);
+	  if (FFiles=nil) or
+	     (FFiles.IndexOf(Item.Name)<>-1) then
+            UnZipOneFile(Item);
         end;
         end;
     Finally
     Finally
        CloseInput;
        CloseInput;

+ 134 - 134
utils/fppkg/fppkg.lpi

@@ -32,15 +32,15 @@
         <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
         <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
       </local>
       </local>
     </RunParams>
     </RunParams>
-    <Units Count="36">
+    <Units Count="37">
       <Unit0>
       <Unit0>
         <Filename Value="fppkg.pp"/>
         <Filename Value="fppkg.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="fppkg"/>
         <UnitName Value="fppkg"/>
-        <CursorPos X="41" Y="147"/>
-        <TopLine Value="171"/>
+        <CursorPos X="131" Y="33"/>
+        <TopLine Value="18"/>
         <EditorIndex Value="0"/>
         <EditorIndex Value="0"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit0>
       </Unit0>
       <Unit1>
       <Unit1>
@@ -49,61 +49,56 @@
         <UnitName Value="pkgoptions"/>
         <UnitName Value="pkgoptions"/>
         <CursorPos X="41" Y="18"/>
         <CursorPos X="41" Y="18"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="82"/>
       </Unit1>
       </Unit1>
       <Unit2>
       <Unit2>
         <Filename Value="fpmkcnst.inc"/>
         <Filename Value="fpmkcnst.inc"/>
-        <IsPartOfProject Value="True"/>
         <CursorPos X="64" Y="8"/>
         <CursorPos X="64" Y="8"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="72"/>
       </Unit2>
       </Unit2>
       <Unit3>
       <Unit3>
         <Filename Value="fpmktype.pp"/>
         <Filename Value="fpmktype.pp"/>
-        <IsPartOfProject Value="True"/>
         <UnitName Value="fpmktype"/>
         <UnitName Value="fpmktype"/>
         <CursorPos X="3" Y="41"/>
         <CursorPos X="3" Y="41"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <EditorIndex Value="6"/>
-        <UsageCount Value="73"/>
-        <Loaded Value="True"/>
+        <UsageCount Value="72"/>
       </Unit3>
       </Unit3>
       <Unit4>
       <Unit4>
         <Filename Value="fpmkunit.pp"/>
         <Filename Value="fpmkunit.pp"/>
-        <IsPartOfProject Value="True"/>
         <UnitName Value="fpmkunit"/>
         <UnitName Value="fpmkunit"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="72"/>
       </Unit4>
       </Unit4>
       <Unit5>
       <Unit5>
         <Filename Value="fprepos.pp"/>
         <Filename Value="fprepos.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="fprepos"/>
         <UnitName Value="fprepos"/>
-        <CursorPos X="21" Y="368"/>
-        <TopLine Value="356"/>
-        <EditorIndex Value="8"/>
-        <UsageCount Value="73"/>
+        <CursorPos X="1" Y="187"/>
+        <TopLine Value="165"/>
+        <EditorIndex Value="9"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit5>
       </Unit5>
       <Unit6>
       <Unit6>
         <Filename Value="fpxmlrep.pp"/>
         <Filename Value="fpxmlrep.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="fpxmlrep"/>
         <UnitName Value="fpxmlrep"/>
-        <CursorPos X="33" Y="259"/>
-        <TopLine Value="245"/>
-        <EditorIndex Value="9"/>
-        <UsageCount Value="73"/>
+        <CursorPos X="1" Y="43"/>
+        <TopLine Value="43"/>
+        <EditorIndex Value="10"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit6>
       </Unit6>
       <Unit7>
       <Unit7>
         <Filename Value="pkghandler.pp"/>
         <Filename Value="pkghandler.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="pkghandler"/>
         <UnitName Value="pkghandler"/>
-        <CursorPos X="10" Y="167"/>
-        <TopLine Value="153"/>
+        <CursorPos X="56" Y="170"/>
+        <TopLine Value="156"/>
         <EditorIndex Value="1"/>
         <EditorIndex Value="1"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit7>
       </Unit7>
       <Unit8>
       <Unit8>
@@ -112,26 +107,26 @@
         <UnitName Value="pkgmkconv"/>
         <UnitName Value="pkgmkconv"/>
         <CursorPos X="14" Y="53"/>
         <CursorPos X="14" Y="53"/>
         <TopLine Value="29"/>
         <TopLine Value="29"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="82"/>
       </Unit8>
       </Unit8>
       <Unit9>
       <Unit9>
         <Filename Value="pkgdownload.pp"/>
         <Filename Value="pkgdownload.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="pkgdownload"/>
         <UnitName Value="pkgdownload"/>
-        <CursorPos X="18" Y="88"/>
-        <TopLine Value="71"/>
+        <CursorPos X="27" Y="144"/>
+        <TopLine Value="129"/>
         <EditorIndex Value="2"/>
         <EditorIndex Value="2"/>
-        <UsageCount Value="73"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit9>
       </Unit9>
       <Unit10>
       <Unit10>
         <Filename Value="pkgmessages.pp"/>
         <Filename Value="pkgmessages.pp"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="pkgmessages"/>
         <UnitName Value="pkgmessages"/>
-        <CursorPos X="1" Y="29"/>
-        <TopLine Value="27"/>
-        <EditorIndex Value="5"/>
-        <UsageCount Value="73"/>
+        <CursorPos X="34" Y="45"/>
+        <TopLine Value="25"/>
+        <EditorIndex Value="6"/>
+        <UsageCount Value="82"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit10>
       </Unit10>
       <Unit11>
       <Unit11>
@@ -139,48 +134,48 @@
         <UnitName Value="streamcoll"/>
         <UnitName Value="streamcoll"/>
         <CursorPos X="66" Y="88"/>
         <CursorPos X="66" Y="88"/>
         <TopLine Value="65"/>
         <TopLine Value="65"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit11>
       </Unit11>
       <Unit12>
       <Unit12>
         <Filename Value="streamcoll20.pp"/>
         <Filename Value="streamcoll20.pp"/>
         <UnitName Value="streamcoll"/>
         <UnitName Value="streamcoll"/>
         <CursorPos X="3" Y="15"/>
         <CursorPos X="3" Y="15"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit12>
       </Unit12>
       <Unit13>
       <Unit13>
         <Filename Value="../../../fpc20/rtl/objpas/classes/classesh.inc"/>
         <Filename Value="../../../fpc20/rtl/objpas/classes/classesh.inc"/>
         <CursorPos X="14" Y="599"/>
         <CursorPos X="14" Y="599"/>
         <TopLine Value="580"/>
         <TopLine Value="580"/>
-        <UsageCount Value="33"/>
+        <UsageCount Value="32"/>
       </Unit13>
       </Unit13>
       <Unit14>
       <Unit14>
         <Filename Value="../../../fpc20/rtl/inc/objpash.inc"/>
         <Filename Value="../../../fpc20/rtl/inc/objpash.inc"/>
         <CursorPos X="38" Y="277"/>
         <CursorPos X="38" Y="277"/>
         <TopLine Value="269"/>
         <TopLine Value="269"/>
-        <UsageCount Value="31"/>
+        <UsageCount Value="30"/>
       </Unit14>
       </Unit14>
       <Unit15>
       <Unit15>
         <Filename Value="../../../fpc20/fcl/inc/contnrs.pp"/>
         <Filename Value="../../../fpc20/fcl/inc/contnrs.pp"/>
         <UnitName Value="contnrs"/>
         <UnitName Value="contnrs"/>
         <CursorPos X="1" Y="19"/>
         <CursorPos X="1" Y="19"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit15>
       </Unit15>
       <Unit16>
       <Unit16>
         <Filename Value="contnrs20.pp"/>
         <Filename Value="contnrs20.pp"/>
         <UnitName Value="contnrs20"/>
         <UnitName Value="contnrs20"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="25"/>
+        <UsageCount Value="24"/>
       </Unit16>
       </Unit16>
       <Unit17>
       <Unit17>
         <Filename Value="pkgcommands.pp"/>
         <Filename Value="pkgcommands.pp"/>
         <UnitName Value="pkgcommands"/>
         <UnitName Value="pkgcommands"/>
-        <CursorPos X="1" Y="73"/>
-        <TopLine Value="54"/>
-        <EditorIndex Value="4"/>
-        <UsageCount Value="35"/>
+        <CursorPos X="3" Y="73"/>
+        <TopLine Value="59"/>
+        <EditorIndex Value="5"/>
+        <UsageCount Value="39"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit17>
       </Unit17>
       <Unit18>
       <Unit18>
@@ -188,36 +183,36 @@
         <UnitName Value="pkgwget"/>
         <UnitName Value="pkgwget"/>
         <CursorPos X="18" Y="25"/>
         <CursorPos X="18" Y="25"/>
         <TopLine Value="15"/>
         <TopLine Value="15"/>
-        <UsageCount Value="29"/>
+        <UsageCount Value="28"/>
       </Unit18>
       </Unit18>
       <Unit19>
       <Unit19>
         <Filename Value="pkglnet.pas"/>
         <Filename Value="pkglnet.pas"/>
         <UnitName Value="pkglnet"/>
         <UnitName Value="pkglnet"/>
         <CursorPos X="36" Y="19"/>
         <CursorPos X="36" Y="19"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit19>
       </Unit19>
       <Unit20>
       <Unit20>
         <Filename Value="reptest.pp"/>
         <Filename Value="reptest.pp"/>
         <UnitName Value="reptest"/>
         <UnitName Value="reptest"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="22"/>
+        <UsageCount Value="21"/>
       </Unit20>
       </Unit20>
       <Unit21>
       <Unit21>
         <Filename Value="rep2xml.lpr"/>
         <Filename Value="rep2xml.lpr"/>
         <UnitName Value="rep2xml"/>
         <UnitName Value="rep2xml"/>
         <CursorPos X="40" Y="228"/>
         <CursorPos X="40" Y="228"/>
         <TopLine Value="217"/>
         <TopLine Value="217"/>
-        <UsageCount Value="22"/>
+        <UsageCount Value="21"/>
       </Unit21>
       </Unit21>
       <Unit22>
       <Unit22>
-        <Filename Value="pkgarchive.pp"/>
-        <UnitName Value="pkgarchive"/>
-        <CursorPos X="1" Y="70"/>
-        <TopLine Value="56"/>
-        <EditorIndex Value="3"/>
-        <UsageCount Value="26"/>
+        <Filename Value="pkgrepos.pp"/>
+        <UnitName Value="pkgrepos"/>
+        <CursorPos X="30" Y="60"/>
+        <TopLine Value="42"/>
+        <EditorIndex Value="8"/>
+        <UsageCount Value="30"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit22>
       </Unit22>
       <Unit23>
       <Unit23>
@@ -225,86 +220,88 @@
         <UnitName Value="pkgoCurl"/>
         <UnitName Value="pkgoCurl"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit23>
       </Unit23>
       <Unit24>
       <Unit24>
         <Filename Value="pkglibcurl.pp"/>
         <Filename Value="pkglibcurl.pp"/>
         <UnitName Value="pkglibcurl"/>
         <UnitName Value="pkglibcurl"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit24>
       </Unit24>
       <Unit25>
       <Unit25>
         <Filename Value="zipper.pp"/>
         <Filename Value="zipper.pp"/>
         <UnitName Value="zipper"/>
         <UnitName Value="zipper"/>
         <CursorPos X="21" Y="1324"/>
         <CursorPos X="21" Y="1324"/>
         <TopLine Value="1303"/>
         <TopLine Value="1303"/>
-        <UsageCount Value="15"/>
+        <UsageCount Value="14"/>
       </Unit25>
       </Unit25>
       <Unit26>
       <Unit26>
         <Filename Value="../../../fpc20/rtl/objpas/sysutils/filutilh.inc"/>
         <Filename Value="../../../fpc20/rtl/objpas/sysutils/filutilh.inc"/>
         <CursorPos X="12" Y="53"/>
         <CursorPos X="12" Y="53"/>
         <TopLine Value="40"/>
         <TopLine Value="40"/>
-        <UsageCount Value="13"/>
+        <UsageCount Value="12"/>
       </Unit26>
       </Unit26>
       <Unit27>
       <Unit27>
         <Filename Value="../../../fpc20/rtl/inc/systemh.inc"/>
         <Filename Value="../../../fpc20/rtl/inc/systemh.inc"/>
         <CursorPos X="3" Y="214"/>
         <CursorPos X="3" Y="214"/>
         <TopLine Value="313"/>
         <TopLine Value="313"/>
-        <UsageCount Value="13"/>
+        <UsageCount Value="12"/>
       </Unit27>
       </Unit27>
       <Unit28>
       <Unit28>
         <Filename Value="../../../fpc20/rtl/objpas/sysutils/datih.inc"/>
         <Filename Value="../../../fpc20/rtl/objpas/sysutils/datih.inc"/>
         <CursorPos X="16" Y="93"/>
         <CursorPos X="16" Y="93"/>
         <TopLine Value="86"/>
         <TopLine Value="86"/>
-        <UsageCount Value="13"/>
+        <UsageCount Value="12"/>
       </Unit28>
       </Unit28>
       <Unit29>
       <Unit29>
         <Filename Value="zstream.pp"/>
         <Filename Value="zstream.pp"/>
         <UnitName Value="zstream"/>
         <UnitName Value="zstream"/>
         <CursorPos X="38" Y="348"/>
         <CursorPos X="38" Y="348"/>
         <TopLine Value="330"/>
         <TopLine Value="330"/>
-        <UsageCount Value="11"/>
+        <UsageCount Value="10"/>
       </Unit29>
       </Unit29>
       <Unit30>
       <Unit30>
         <Filename Value="../../../fpc20/packages/base/paszlib/paszlib.pas"/>
         <Filename Value="../../../fpc20/packages/base/paszlib/paszlib.pas"/>
         <UnitName Value="paszlib"/>
         <UnitName Value="paszlib"/>
         <CursorPos X="34" Y="139"/>
         <CursorPos X="34" Y="139"/>
         <TopLine Value="118"/>
         <TopLine Value="118"/>
-        <UsageCount Value="11"/>
+        <UsageCount Value="10"/>
       </Unit30>
       </Unit30>
       <Unit31>
       <Unit31>
         <Filename Value="pkgfpmake.pp"/>
         <Filename Value="pkgfpmake.pp"/>
         <UnitName Value="pkgfpmake"/>
         <UnitName Value="pkgfpmake"/>
-        <CursorPos X="48" Y="58"/>
-        <TopLine Value="47"/>
-        <UsageCount Value="14"/>
+        <CursorPos X="25" Y="100"/>
+        <TopLine Value="88"/>
+        <EditorIndex Value="4"/>
+        <UsageCount Value="18"/>
+        <Loaded Value="True"/>
       </Unit31>
       </Unit31>
       <Unit32>
       <Unit32>
         <Filename Value="pkglnet.pp"/>
         <Filename Value="pkglnet.pp"/>
         <UnitName Value="pkglnet"/>
         <UnitName Value="pkglnet"/>
         <CursorPos X="1" Y="1"/>
         <CursorPos X="1" Y="1"/>
         <TopLine Value="1"/>
         <TopLine Value="1"/>
-        <EditorIndex Value="11"/>
-        <UsageCount Value="13"/>
+        <EditorIndex Value="12"/>
+        <UsageCount Value="17"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit32>
       </Unit32>
       <Unit33>
       <Unit33>
         <Filename Value="pkgoptions.pp"/>
         <Filename Value="pkgoptions.pp"/>
         <UnitName Value="pkgoptions"/>
         <UnitName Value="pkgoptions"/>
-        <CursorPos X="2" Y="193"/>
-        <TopLine Value="187"/>
+        <CursorPos X="53" Y="84"/>
+        <TopLine Value="59"/>
         <EditorIndex Value="7"/>
         <EditorIndex Value="7"/>
-        <UsageCount Value="13"/>
+        <UsageCount Value="17"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit33>
       </Unit33>
       <Unit34>
       <Unit34>
         <Filename Value="pkgglobals.pp"/>
         <Filename Value="pkgglobals.pp"/>
         <UnitName Value="pkgglobals"/>
         <UnitName Value="pkgglobals"/>
-        <CursorPos X="1" Y="87"/>
-        <TopLine Value="73"/>
-        <EditorIndex Value="10"/>
-        <UsageCount Value="13"/>
+        <CursorPos X="1" Y="29"/>
+        <TopLine Value="29"/>
+        <EditorIndex Value="11"/>
+        <UsageCount Value="17"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit34>
       </Unit34>
       <Unit35>
       <Unit35>
@@ -312,129 +309,138 @@
         <UnitName Value="URIParser"/>
         <UnitName Value="URIParser"/>
         <CursorPos X="1" Y="193"/>
         <CursorPos X="1" Y="193"/>
         <TopLine Value="189"/>
         <TopLine Value="189"/>
-        <UsageCount Value="10"/>
+        <UsageCount Value="9"/>
       </Unit35>
       </Unit35>
+      <Unit36>
+        <Filename Value="pkgarchive.pp"/>
+        <UnitName Value="pkgarchive"/>
+        <CursorPos X="1" Y="74"/>
+        <TopLine Value="69"/>
+        <EditorIndex Value="3"/>
+        <UsageCount Value="12"/>
+        <Loaded Value="True"/>
+      </Unit36>
     </Units>
     </Units>
     <JumpHistory Count="30" HistoryIndex="29">
     <JumpHistory Count="30" HistoryIndex="29">
       <Position1>
       <Position1>
-        <Filename Value="pkghandler.pp"/>
-        <Caret Line="163" Column="5" TopLine="126"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="1" Column="1" TopLine="1"/>
       </Position1>
       </Position1>
       <Position2>
       <Position2>
-        <Filename Value="pkgdownload.pp"/>
-        <Caret Line="130" Column="16" TopLine="116"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="80" Column="13" TopLine="74"/>
       </Position2>
       </Position2>
       <Position3>
       <Position3>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="27" Column="14" TopLine="46"/>
+        <Filename Value="pkgoptions.pp"/>
+        <Caret Line="181" Column="1" TopLine="169"/>
       </Position3>
       </Position3>
       <Position4>
       <Position4>
-        <Filename Value="pkgcommands.pp"/>
-        <Caret Line="60" Column="36" TopLine="50"/>
+        <Filename Value="pkgoptions.pp"/>
+        <Caret Line="38" Column="27" TopLine="15"/>
       </Position4>
       </Position4>
       <Position5>
       <Position5>
-        <Filename Value="pkgcommands.pp"/>
-        <Caret Line="58" Column="1" TopLine="44"/>
+        <Filename Value="pkgoptions.pp"/>
+        <Caret Line="76" Column="35" TopLine="62"/>
       </Position5>
       </Position5>
       <Position6>
       <Position6>
         <Filename Value="pkgoptions.pp"/>
         <Filename Value="pkgoptions.pp"/>
-        <Caret Line="64" Column="22" TopLine="41"/>
+        <Caret Line="185" Column="14" TopLine="158"/>
       </Position6>
       </Position6>
       <Position7>
       <Position7>
         <Filename Value="pkgoptions.pp"/>
         <Filename Value="pkgoptions.pp"/>
-        <Caret Line="110" Column="27" TopLine="96"/>
+        <Caret Line="256" Column="49" TopLine="242"/>
       </Position7>
       </Position7>
       <Position8>
       <Position8>
-        <Filename Value="pkgoptions.pp"/>
-        <Caret Line="137" Column="39" TopLine="123"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="23" Column="22" TopLine="15"/>
       </Position8>
       </Position8>
       <Position9>
       <Position9>
-        <Filename Value="pkgoptions.pp"/>
-        <Caret Line="159" Column="31" TopLine="145"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="91" Column="1" TopLine="78"/>
       </Position9>
       </Position9>
       <Position10>
       <Position10>
-        <Filename Value="pkgoptions.pp"/>
-        <Caret Line="232" Column="25" TopLine="218"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="46" Column="42" TopLine="32"/>
       </Position10>
       </Position10>
       <Position11>
       <Position11>
         <Filename Value="pkgoptions.pp"/>
         <Filename Value="pkgoptions.pp"/>
-        <Caret Line="96" Column="16" TopLine="90"/>
+        <Caret Line="306" Column="58" TopLine="293"/>
       </Position11>
       </Position11>
       <Position12>
       <Position12>
-        <Filename Value="pkgoptions.pp"/>
-        <Caret Line="45" Column="41" TopLine="44"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="46" Column="42" TopLine="32"/>
       </Position12>
       </Position12>
       <Position13>
       <Position13>
-        <Filename Value="pkgcommands.pp"/>
-        <Caret Line="53" Column="72" TopLine="50"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="58" Column="35" TopLine="40"/>
       </Position13>
       </Position13>
       <Position14>
       <Position14>
-        <Filename Value="pkgcommands.pp"/>
-        <Caret Line="47" Column="15" TopLine="39"/>
+        <Filename Value="fprepos.pp"/>
+        <Caret Line="295" Column="46" TopLine="275"/>
       </Position14>
       </Position14>
       <Position15>
       <Position15>
-        <Filename Value="pkgcommands.pp"/>
-        <Caret Line="59" Column="33" TopLine="45"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="58" Column="27" TopLine="40"/>
       </Position15>
       </Position15>
       <Position16>
       <Position16>
-        <Filename Value="fppkg.pp"/>
-        <Caret Line="85" Column="1" TopLine="58"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="61" Column="52" TopLine="40"/>
       </Position16>
       </Position16>
       <Position17>
       <Position17>
-        <Filename Value="fppkg.pp"/>
-        <Caret Line="149" Column="20" TopLine="135"/>
+        <Filename Value="pkgcommands.pp"/>
+        <Caret Line="55" Column="11" TopLine="45"/>
       </Position17>
       </Position17>
       <Position18>
       <Position18>
-        <Filename Value="pkgmessages.pp"/>
-        <Caret Line="41" Column="18" TopLine="26"/>
+        <Filename Value="pkgcommands.pp"/>
+        <Caret Line="22" Column="16" TopLine="8"/>
       </Position18>
       </Position18>
       <Position19>
       <Position19>
-        <Filename Value="pkgdownload.pp"/>
-        <Caret Line="91" Column="13" TopLine="78"/>
+        <Filename Value="pkgcommands.pp"/>
+        <Caret Line="114" Column="43" TopLine="90"/>
       </Position19>
       </Position19>
       <Position20>
       <Position20>
-        <Filename Value="pkgdownload.pp"/>
-        <Caret Line="86" Column="1" TopLine="78"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="12" Column="1" TopLine="4"/>
       </Position20>
       </Position20>
       <Position21>
       <Position21>
-        <Filename Value="pkghandler.pp"/>
-        <Caret Line="106" Column="21" TopLine="93"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="67" Column="1" TopLine="56"/>
       </Position21>
       </Position21>
       <Position22>
       <Position22>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="62" Column="1" TopLine="48"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="113" Column="49" TopLine="99"/>
       </Position22>
       </Position22>
       <Position23>
       <Position23>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="73" Column="67" TopLine="50"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="211" Column="25" TopLine="197"/>
       </Position23>
       </Position23>
       <Position24>
       <Position24>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="67" Column="30" TopLine="54"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="55" Column="1" TopLine="27"/>
       </Position24>
       </Position24>
       <Position25>
       <Position25>
-        <Filename Value="pkgglobals.pp"/>
-        <Caret Line="87" Column="1" TopLine="73"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="9" Column="11" TopLine="1"/>
       </Position25>
       </Position25>
       <Position26>
       <Position26>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="62" Column="1" TopLine="48"/>
+        <Filename Value="pkgrepos.pp"/>
+        <Caret Line="32" Column="16" TopLine="18"/>
       </Position26>
       </Position26>
       <Position27>
       <Position27>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="64" Column="1" TopLine="50"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="254" Column="1" TopLine="240"/>
       </Position27>
       </Position27>
       <Position28>
       <Position28>
-        <Filename Value="pkgarchive.pp"/>
-        <Caret Line="67" Column="1" TopLine="53"/>
+        <Filename Value="fppkg.pp"/>
+        <Caret Line="13" Column="49" TopLine="1"/>
       </Position28>
       </Position28>
       <Position29>
       <Position29>
         <Filename Value="pkgarchive.pp"/>
         <Filename Value="pkgarchive.pp"/>
-        <Caret Line="68" Column="1" TopLine="54"/>
+        <Caret Line="170" Column="26" TopLine="153"/>
       </Position29>
       </Position29>
       <Position30>
       <Position30>
         <Filename Value="pkgarchive.pp"/>
         <Filename Value="pkgarchive.pp"/>
-        <Caret Line="69" Column="1" TopLine="55"/>
+        <Caret Line="91" Column="33" TopLine="72"/>
       </Position30>
       </Position30>
     </JumpHistory>
     </JumpHistory>
   </ProjectOptions>
   </ProjectOptions>
@@ -469,12 +475,6 @@
     </Other>
     </Other>
   </CompilerOptions>
   </CompilerOptions>
   <Debugging>
   <Debugging>
-    <BreakPoints Count="1">
-      <Item1>
-        <Source Value="pkgarchive.pp"/>
-        <Line Value="62"/>
-      </Item1>
-    </BreakPoints>
     <Watches Count="1">
     <Watches Count="1">
       <Item1>
       <Item1>
         <Expression Value="builddir"/>
         <Expression Value="builddir"/>

+ 8 - 37
utils/fppkg/fppkg.pp

@@ -10,7 +10,7 @@ uses
   Classes, SysUtils, TypInfo, custapp,
   Classes, SysUtils, TypInfo, custapp,
   // Repository handler objects
   // Repository handler objects
   fprepos, fpxmlrep,
   fprepos, fpxmlrep,
-  pkgmessages, pkgglobals, pkgoptions,
+  pkgmessages, pkgglobals, pkgoptions, pkgrepos,
   // Package Handler components
   // Package Handler components
   pkghandler,pkgmkconv, pkgdownload,
   pkghandler,pkgmkconv, pkgdownload,
   pkgarchive, pkgfpmake, pkgcommands
   pkgarchive, pkgfpmake, pkgcommands
@@ -28,10 +28,7 @@ Type
     ActionStack : TActionStack;
     ActionStack : TActionStack;
     ParaAction : string;
     ParaAction : string;
     ParaPackages : TStringList;
     ParaPackages : TStringList;
-    FRepository : TFPRepository;
-    FCompilerConfig : String;
     procedure GenerateParaActions;
     procedure GenerateParaActions;
-    procedure LoadRepository;
     procedure MaybeCreateLocalDirs;
     procedure MaybeCreateLocalDirs;
     procedure ShowUsage;
     procedure ShowUsage;
   Public
   Public
@@ -91,7 +88,7 @@ begin
   for i:=0 to SL.Count-1 do
   for i:=0 to SL.Count-1 do
     Include(Verbosity,StringToVerbosity(SL[i]));
     Include(Verbosity,StringToVerbosity(SL[i]));
   SL.Free;
   SL.Free;
-  FCompilerConfig:=Defaults.DefaultCompilerConfig;
+  Defaults.CurrentCompilerConfig:=Defaults.DefaultCompilerConfig;
   // Tracing of what we've done above, need to be done after the verbosity is set
   // Tracing of what we've done above, need to be done after the verbosity is set
   if GeneratedConfig then
   if GeneratedConfig then
     Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile])
     Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile])
@@ -112,7 +109,7 @@ procedure TMakeTool.LoadCompilerDefaults;
 var
 var
   S : String;
   S : String;
 begin
 begin
-  S:=Defaults.CompilerConfigDir+FCompilerConfig;
+  S:=Defaults.CompilerConfigDir+Defaults.CurrentCompilerConfig;
   if FileExists(S) then
   if FileExists(S) then
     begin
     begin
       Log(vDebug,SLogLoadingCompilerConfig,[S]);
       Log(vDebug,SLogLoadingCompilerConfig,[S]);
@@ -127,32 +124,6 @@ begin
 end;
 end;
 
 
 
 
-procedure TMakeTool.LoadRepository;
-var
-  S : String;
-  X : TFPXMLRepositoryHandler;
-begin
-  FRepository:=TFPRepository.Create(Nil);
-  // Repository
-  Log(vDebug,SLogLoadingPackagesFile,[Defaults.LocalPackagesFile]);
-  if FileExists(Defaults.LocalPackagesFile) then
-    begin
-      X:=TFPXMLRepositoryHandler.Create;
-      With X do
-        try
-          LoadFromXml(FRepository,Defaults.LocalPackagesFile);
-        finally
-          Free;
-        end;
-    end;
-  // Versions
-  S:=Defaults.LocalVersionsFile(FCompilerConfig);
-  Log(vDebug,SLogLoadingVersionsFile,[S]);
-  if FileExists(S) then
-    FRepository.LoadStatusFromFile(S);
-end;
-
-
 procedure TMakeTool.ShowUsage;
 procedure TMakeTool.ShowUsage;
 begin
 begin
   Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
   Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
@@ -161,8 +132,8 @@ begin
   Writeln('  -h --help          This help');
   Writeln('  -h --help          This help');
   Writeln('  -v --verbose       Set verbosity');
   Writeln('  -v --verbose       Set verbosity');
   Writeln('Actions:');
   Writeln('Actions:');
-  Writeln('  update             Update available packages');
-  Writeln('  listpackages       List available packages');
+  Writeln('  update             Update packages list');
+  Writeln('  avail              List available packages');
   Writeln('  build              Build package');
   Writeln('  build              Build package');
   Writeln('  install            Install package');
   Writeln('  install            Install package');
   Writeln('  download           Download package');
   Writeln('  download           Download package');
@@ -236,7 +207,7 @@ begin
       Inc(I);
       Inc(I);
       // Check options.
       // Check options.
       if CheckOption(I,'c','config') then
       if CheckOption(I,'c','config') then
-        FCompilerConfig:=OptionArg(I)
+        Defaults.CurrentCompilerConfig:=OptionArg(I)
       else if CheckOption(I,'v','verbose') then
       else if CheckOption(I,'v','verbose') then
         Include(Verbosity,StringToVerbosity(OptionArg(I)))
         Include(Verbosity,StringToVerbosity(OptionArg(I)))
       else if CheckOption(I,'h','help') then
       else if CheckOption(I,'h','help') then
@@ -279,7 +250,7 @@ begin
         begin
         begin
           for i:=0 to ParaPackages.Count-1 do
           for i:=0 to ParaPackages.Count-1 do
             begin
             begin
-              ActionPackage:=FRepository.PackageByName(ParaPackages[i]);
+              ActionPackage:=CurrentRepository.PackageByName(ParaPackages[i]);
               Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]);
               Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]);
               ActionStack.Push(ActionPackage,ParaAction,[]);
               ActionStack.Push(ActionPackage,ParaAction,[]);
             end;
             end;
@@ -303,7 +274,7 @@ begin
     ProcessCommandLine;
     ProcessCommandLine;
     MaybeCreateLocalDirs;
     MaybeCreateLocalDirs;
     LoadCompilerDefaults;
     LoadCompilerDefaults;
-    LoadRepository;
+    LoadLocalRepository;
     GenerateParaActions;
     GenerateParaActions;
 
 
     repeat
     repeat

+ 130 - 4
utils/fppkg/fprepos.pp

@@ -19,14 +19,23 @@ interface
 uses
 uses
   classes,sysutils,
   classes,sysutils,
   contnrs,
   contnrs,
-  streamcoll,
-  fpmktype;
+  streamcoll;
 
 
 Const
 Const
   StreamVersion   : Integer = 1;
   StreamVersion   : Integer = 1;
   StreamSignature = $FEEF;
   StreamSignature = $FEEF;
 
 
 Type
 Type
+  TOS = (osNone,Amiga,Atari,Darwin,FreeBSD,Go32v2,Linux,MacOS,MorphOS,NetBSD,
+         Netware,NetwLibc,OpenBSD,OS2,PalmOS,Solaris,Win32,Win64,WinCE,Emx);
+  TOSes = Set of TOS;
+
+  TCPU = (cpuNone,Arm,I386,PPC,SPARC,X86_64,M68K,PPC64);
+  TCPUS = Set of TCPU;
+
+  TCompilerMode = (cmFPC,cmTP,cmObjFPC,cmDelphi,cmMacPas);
+  TCompilerModes = Set of TCompilerMode;
+
   { TFPVersion }
   { TFPVersion }
 
 
   TFPVersion = Class(TPersistent)
   TFPVersion = Class(TPersistent)
@@ -156,7 +165,6 @@ Type
     function GetPackage(Index : Integer): TFPPackage;
     function GetPackage(Index : Integer): TFPPackage;
     function GetPackageCount: Integer;
     function GetPackageCount: Integer;
   Protected
   Protected
-    Property PackageCollection : TFPPackages Read FPackages;
     procedure CreatePackages; virtual;
     procedure CreatePackages; virtual;
     Procedure BackupFile(AFileName : String); virtual;
     Procedure BackupFile(AFileName : String); virtual;
     Procedure DoGetPackageDependencies(PackageName : String; List : TStringList; Level : Integer); virtual;
     Procedure DoGetPackageDependencies(PackageName : String; List : TStringList; Level : Integer); virtual;
@@ -189,6 +197,7 @@ Type
     Property PackageCount : Integer Read GetPackageCount;
     Property PackageCount : Integer Read GetPackageCount;
     Property BackupFiles : Boolean Read FBackUpFiles Write FBackupFiles;
     Property BackupFiles : Boolean Read FBackUpFiles Write FBackupFiles;
     Property MaxDependencyLevel : Integer Read FMaxDependencyLevel Write FMaxDependencyLevel;
     Property MaxDependencyLevel : Integer Read FMaxDependencyLevel Write FMaxDependencyLevel;
+    Property PackageCollection : TFPPackages Read FPackages;
   end;
   end;
 
 
   EPackage = Class(Exception);
   EPackage = Class(Exception);
@@ -197,6 +206,20 @@ Const
   // Max level of dependency searching before we decide it's a circular dependency.
   // Max level of dependency searching before we decide it's a circular dependency.
   DefaultMaxDependencyLevel = 15;
   DefaultMaxDependencyLevel = 15;
 
 
+Function OSToString(OS: TOS) : String;
+Function OSesToString(OSes: TOSes) : String;
+Function CPUToString(CPU: TCPU) : String;
+Function CPUSToString(CPUS: TCPUS) : String;
+Function StringToOS(S : String) : TOS;
+Function OSesToString(S : String) : TOSes;
+Function StringToCPU(S : String) : TCPU;
+Function StringToCPUS(S : String) : TCPUS;
+Function ModeToString(Mode: TCompilerMode) : String;
+Function StringToMode(S : String) : TCompilerMode;
+Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
+Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
+
+
 Implementation
 Implementation
 
 
 uses
 uses
@@ -204,7 +227,10 @@ uses
   uriparser;
   uriparser;
 
 
 ResourceString
 ResourceString
-
+  SErrInvalidCPU           = 'Invalid CPU name : "%s"';
+  SErrInvalidOS            = 'Invalid OS name : "%s"';
+  SErrInvalidMode          = 'Invalid compiler mode : "%s"';
+  SErrInvalidTarget        = 'Invalid compiler target: %s';
   SErrPackageNotFound      = 'Package "%s" not found.';
   SErrPackageNotFound      = 'Package "%s" not found.';
   SErrInvalidRepositorySig = 'Invalid repository stream. Stream signature incorrect';
   SErrInvalidRepositorySig = 'Invalid repository stream. Stream signature incorrect';
   SErrBackupFailed         = 'Failed to back up file "%s" to "%s".';
   SErrBackupFailed         = 'Failed to back up file "%s" to "%s".';
@@ -213,6 +239,106 @@ ResourceString
   SErrMaxLevelExceeded     = 'Maximum number of dependency levels exceeded (%d) at package "%s".';
   SErrMaxLevelExceeded     = 'Maximum number of dependency levels exceeded (%d) at package "%s".';
 
 
 
 
+Function OSToString(OS: TOS) : String;
+
+begin
+  Result:=LowerCase(GetenumName(TypeInfo(TOS),Ord(OS)));
+end;
+
+Function OSesToString(OSes: TOSes) : String;
+
+begin
+  Result:=LowerCase(SetToString(PtypeInfo(TypeInfo(TOSes)),Integer(OSes),False));
+end;
+
+Function CPUToString(CPU: TCPU) : String;
+
+begin
+  Result:=LowerCase(GetenumName(TypeInfo(TCPU),Ord(CPU)));
+end;
+
+Function CPUSToString(CPUS: TCPUS) : String;
+
+begin
+  Result:=LowerCase(SetToString(PTypeInfo(TypeInfo(TCPUS)),Integer(CPUS),False));
+end;
+
+Function StringToOS(S : String) : TOS;
+
+Var
+  I : Integer;
+
+begin
+  I:=GetEnumValue(TypeInfo(TOS),S);
+  if (I=-1) then
+    Raise EPackage.CreateFmt(SErrInvalidOS,[S]);
+  Result:=TOS(I);
+end;
+
+
+Function OSesToString(S : String) : TOSes;
+
+begin
+  Result:=TOSes(StringToSet(PTypeInfo(TypeInfo(TOSes)),S));
+end;
+
+Function StringToCPU(S : String) : TCPU;
+
+Var
+  I : Integer;
+
+begin
+  I:=GetEnumValue(TypeInfo(TCPU),S);
+  if (I=-1) then
+    Raise EPackage.CreateFmt(SErrInvalidCPU,[S]);
+  Result:=TCPU(I);
+end;
+
+Function StringToCPUS(S : String) : TCPUS;
+
+begin
+  Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));
+end;
+
+Function ModeToString(Mode: TCompilerMode) : String;
+
+begin
+  Result:=LowerCase(GetenumName(TypeInfo(TCompilerMode),Ord(Mode)));
+end;
+
+Function StringToMode(S : String) : TCompilerMode;
+
+Var
+  I : Integer;
+
+begin
+  I:=GetEnumValue(TypeInfo(TCompilerMode),S);
+  if (I=-1) then
+    Raise EPackage.CreateFmt(SErrInvalidMode,[S]);
+  Result:=TCompilerMode(I);
+end;
+
+
+Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
+
+begin
+  Result:=CPUToString(CPU)+'-'+OSToString(OS);
+end;
+
+Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
+
+Var
+  P : integer;
+
+begin
+  P:=Pos('-',S);
+  If (P=0) then
+    Raise EPackage.CreateFmt(SErrInvalidTarget,[S]);
+  CPU:=StringToCPU(Copy(S,1,P-1));
+  OS:=StringToOs(Copy(S,P+1,Length(S)-P));
+end;
+
+
 { TFPVersion }
 { TFPVersion }
 
 
 function TFPVersion.GetAsString: String;
 function TFPVersion.GetAsString: String;

+ 5 - 3
utils/fppkg/fpxmlrep.pp

@@ -17,7 +17,7 @@ unit fpxmlrep;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, dom, fprepos, fpmktype;
+  Classes, SysUtils, dom, fprepos;
 
 
 Type
 Type
 
 
@@ -647,8 +647,9 @@ begin
     P:=PS.AddPackage('');
     P:=PS.AddPackage('');
     try
     try
       DoXMLToPackage(PN,P);
       DoXMLToPackage(PN,P);
-    finally
+    except
       P.Free;
       P.Free;
+      Raise;
     end;
     end;
     PN:=FindNextElement(PN.NextSibling,SNodePackage);
     PN:=FindNextElement(PN.NextSibling,SNodePackage);
     end;
     end;
@@ -677,8 +678,9 @@ begin
       P:=R.AddPackage('');
       P:=R.AddPackage('');
       try
       try
         DoXMLToPackage(PN,P);
         DoXMLToPackage(PN,P);
-      finally
+      except
         P.Free;
         P.Free;
+        Raise;
       end;
       end;
       PN:=FindNextElement(PN.NextSibling,SNodePackage);
       PN:=FindNextElement(PN.NextSibling,SNodePackage);
       end;
       end;

+ 1 - 1
utils/fppkg/lnet/lcommon.pp

@@ -220,7 +220,7 @@ var
   opt: DWord;
   opt: DWord;
 begin
 begin
   opt := BlockAr[aValue];
   opt := BlockAr[aValue];
-  if ioctlsocket(aHandle, FIONBIO, opt) = SOCKET_ERROR then
+  if ioctlsocket(aHandle, Longint(FIONBIO), opt) = SOCKET_ERROR then
     Exit(False);
     Exit(False);
   Result := True;
   Result := True;
 end;
 end;

+ 5 - 8
utils/fppkg/lnet/levents.pp

@@ -46,10 +46,8 @@ type
 
 
   TLHandleEvent = procedure (aHandle: TLHandle) of object;
   TLHandleEvent = procedure (aHandle: TLHandle) of object;
   TLHandleErrorEvent = procedure (aHandle: TLHandle; const msg: string) of object;
   TLHandleErrorEvent = procedure (aHandle: TLHandle; const msg: string) of object;
-  TLEventerErrorCallback = procedure (const msg: string; Sender: TLEventer) of object;
+  TLEventerErrorEvent = procedure (const msg: string; Sender: TLEventer) of object;
   
   
-  TArrayP = array of Pointer;
-
   { TLHandle }
   { TLHandle }
 
 
   TLHandle = class(TObject)
   TLHandle = class(TObject)
@@ -67,12 +65,12 @@ type
     FPrev: TLHandle;
     FPrev: TLHandle;
     FNext: TLHandle;
     FNext: TLHandle;
     FFreeNext: TLHandle;
     FFreeNext: TLHandle;
-    FUserData: Pointer;
     FInternalData: Pointer;
     FInternalData: Pointer;
     procedure SetIgnoreError(const aValue: Boolean);
     procedure SetIgnoreError(const aValue: Boolean);
     procedure SetIgnoreWrite(const aValue: Boolean);
     procedure SetIgnoreWrite(const aValue: Boolean);
     procedure SetIgnoreRead(const aValue: Boolean);
     procedure SetIgnoreRead(const aValue: Boolean);
    public
    public
+    UserData: Pointer;
     constructor Create; virtual;
     constructor Create; virtual;
     destructor Destroy; override;
     destructor Destroy; override;
     procedure Free; virtual;          // this is a trick
     procedure Free; virtual;          // this is a trick
@@ -85,7 +83,6 @@ type
     property OnRead: TLHandleEvent read FOnRead write FOnRead;
     property OnRead: TLHandleEvent read FOnRead write FOnRead;
     property OnWrite: TLHandleEvent read FOnWrite write FOnWrite;
     property OnWrite: TLHandleEvent read FOnWrite write FOnWrite;
     property OnError: TLHandleErrorEvent read FOnError write FOnError;
     property OnError: TLHandleErrorEvent read FOnError write FOnError;
-    property UserData: Pointer read FUserData write FUserData;
     property Dispose: Boolean read FDispose write FDispose;
     property Dispose: Boolean read FDispose write FDispose;
     property Handle: THandle read FHandle write FHandle;
     property Handle: THandle read FHandle write FHandle;
     property Eventer: TLEventer read FEventer;
     property Eventer: TLEventer read FEventer;
@@ -138,7 +135,7 @@ type
    protected
    protected
     FRoot: TLHandle;
     FRoot: TLHandle;
     FCount: Integer;
     FCount: Integer;
-    FOnError: TLEventerErrorCallback;
+    FOnError: TLEventerErrorEvent;
     FReferences: Integer;
     FReferences: Integer;
     FFreeRoot: TLHandle; // the root of "free" list if any
     FFreeRoot: TLHandle; // the root of "free" list if any
     FFreeIter: TLHandle; // the last of "free" list if any
     FFreeIter: TLHandle; // the last of "free" list if any
@@ -166,7 +163,7 @@ type
     procedure AddRef;
     procedure AddRef;
     procedure DeleteRef;
     procedure DeleteRef;
     property Timeout: DWord read GetTimeout write SetTimeout;
     property Timeout: DWord read GetTimeout write SetTimeout;
-    property OnError: TLEventerErrorCallback read FOnError write FOnError;
+    property OnError: TLEventerErrorEvent read FOnError write FOnError;
     property Count: Integer read FCount;
     property Count: Integer read FCount;
   end;
   end;
   TLEventerClass = class of TLEventer;
   TLEventerClass = class of TLEventer;
@@ -231,7 +228,7 @@ begin
   FOnRead := nil;
   FOnRead := nil;
   FOnWrite := nil;
   FOnWrite := nil;
   FOnError := nil;
   FOnError := nil;
-  FUserData := nil;
+  UserData := nil;
   FEventer := nil;
   FEventer := nil;
   FPrev := nil;
   FPrev := nil;
   FNext := nil;
   FNext := nil;

+ 1 - 1
utils/fppkg/lnet/lftp.pp

@@ -132,7 +132,7 @@ type
     procedure OnControlRe(aSocket: TLSocket);
     procedure OnControlRe(aSocket: TLSocket);
     procedure OnControlCo(aSocket: TLSocket);
     procedure OnControlCo(aSocket: TLSocket);
     procedure OnControlDs(aSocket: TLSocket);
     procedure OnControlDs(aSocket: TLSocket);
-    
+
     function GetTransfer: Boolean;
     function GetTransfer: Boolean;
 
 
     function GetEcho: Boolean;
     function GetEcho: Boolean;

+ 23 - 18
utils/fppkg/lnet/lhttp.pp

@@ -33,6 +33,7 @@ uses
 
 
 type
 type
   TLHTTPMethod = (hmHead, hmGet, hmPost, hmUnknown);
   TLHTTPMethod = (hmHead, hmGet, hmPost, hmUnknown);
+  TLHTTPMethods = set of TLHTTPMethod;
   TLHTTPParameter = (hpConnection, hpContentLength, hpContentType,
   TLHTTPParameter = (hpConnection, hpContentLength, hpContentType,
     hpAccept, hpAcceptCharset, hpAcceptEncoding, hpAcceptLanguage, hpHost,
     hpAccept, hpAcceptCharset, hpAcceptEncoding, hpAcceptLanguage, hpHost,
     hpFrom, hpReferer, hpUserAgent, hpRange, hpTransferEncoding,
     hpFrom, hpReferer, hpUserAgent, hpRange, hpTransferEncoding,
@@ -338,9 +339,6 @@ type
   TLHTTPServerSocket = class(TLHTTPSocket)
   TLHTTPServerSocket = class(TLHTTPSocket)
   protected
   protected
     FLogMessage: TStringBuffer;
     FLogMessage: TStringBuffer;
-    FRequestInfo: TRequestInfo;
-    FResponseInfo: TResponseInfo;
-    FHeaderOut: THeaderOutInfo;
     FSetupEncodingState: TSetupEncodingState;
     FSetupEncodingState: TSetupEncodingState;
 
 
     procedure AddContentLength(ALength: integer); override;
     procedure AddContentLength(ALength: integer); override;
@@ -358,24 +356,29 @@ type
     procedure WriteError(AStatus: TLHTTPStatus); override;
     procedure WriteError(AStatus: TLHTTPStatus); override;
     procedure WriteHeaders(AHeaderResponse, ADataResponse: TOutputItem);
     procedure WriteHeaders(AHeaderResponse, ADataResponse: TOutputItem);
   public
   public
+    FHeaderOut: THeaderOutInfo;
+    FRequestInfo: TRequestInfo;
+    FResponseInfo: TResponseInfo;
+
     constructor Create; override;
     constructor Create; override;
     destructor Destroy; override;
     destructor Destroy; override;
 
 
     function  SetupEncoding(AOutputItem: TBufferOutput): boolean;
     function  SetupEncoding(AOutputItem: TBufferOutput): boolean;
     procedure StartMemoryResponse(AOutputItem: TMemoryOutput; ACustomErrorMessage: boolean = false);
     procedure StartMemoryResponse(AOutputItem: TMemoryOutput; ACustomErrorMessage: boolean = false);
     procedure StartResponse(AOutputItem: TBufferOutput; ACustomErrorMessage: boolean = false);
     procedure StartResponse(AOutputItem: TBufferOutput; ACustomErrorMessage: boolean = false);
-
-    property HeaderOut: THeaderOutInfo read FHeaderOut;
-    property RequestInfo: TRequestInfo read FRequestInfo;
-    property ResponseInfo: TResponseInfo read FResponseInfo;
   end;
   end;
   
   
   TURIHandler = class(TObject)
   TURIHandler = class(TObject)
   private
   private
     FNext: TURIHandler;
     FNext: TURIHandler;
+    FMethods: TLHTTPMethods;
   protected
   protected
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; virtual; abstract;
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; virtual; abstract;
     procedure RegisterWithEventer(AEventer: TLEventer); virtual;
     procedure RegisterWithEventer(AEventer: TLEventer); virtual;
+  public
+    constructor Create;
+
+    property Methods: TLHTTPMethods read FMethods write FMethods;
   end;
   end;
 
 
   TLAccessEvent = procedure(AMessage: string) of object;
   TLAccessEvent = procedure(AMessage: string) of object;
@@ -558,6 +561,11 @@ end;
 
 
 { TURIHandler }
 { TURIHandler }
 
 
+constructor TURIHandler.Create;
+begin
+  FMethods := [hmHead, hmGet, hmPost];
+end;
+
 procedure TURIHandler.RegisterWithEventer(AEventer: TLEventer);
 procedure TURIHandler.RegisterWithEventer(AEventer: TLEventer);
 begin
 begin
 end;
 end;
@@ -1594,14 +1602,8 @@ begin
   lPos^ := #0;
   lPos^ := #0;
   for I := Low(TLHTTPMethod) to High(TLHTTPMethod) do
   for I := Low(TLHTTPMethod) to High(TLHTTPMethod) do
   begin
   begin
-    if I = hmUnknown then
-    begin
-      WriteError(hsNotImplemented);
-      exit;
-    end;
-    
-    if ((lPos-FBufferPos) = Length(HTTPMethodStrings[I]))
-    and CompareMem(FBufferPos, PChar(HTTPMethodStrings[I]), lPos-FBufferPos) then
+    if (I = hmUnknown) or (((lPos-FBufferPos) = Length(HTTPMethodStrings[I]))
+      and CompareMem(FBufferPos, PChar(HTTPMethodStrings[I]), lPos-FBufferPos)) then
     begin
     begin
       repeat
       repeat
         inc(lPos);
         inc(lPos);
@@ -1913,9 +1915,12 @@ begin
   lHandler := FHandlerList;
   lHandler := FHandlerList;
   while lHandler <> nil do
   while lHandler <> nil do
   begin
   begin
-    Result := lHandler.HandleURI(ASocket);
-    if ASocket.ResponseInfo.Status <> hsOK then break;
-    if Result <> nil then break;
+    if ASocket.FRequestInfo.RequestType in lHandler.Methods then
+    begin
+      Result := lHandler.HandleURI(ASocket);
+      if ASocket.FResponseInfo.Status <> hsOK then break;
+      if Result <> nil then break;
+    end;
     lHandler := lHandler.FNext;
     lHandler := lHandler.FNext;
   end;
   end;
 end;
 end;

+ 32 - 33
utils/fppkg/lnet/lnet.pp

@@ -1,4 +1,4 @@
-{ lNet v0.4.0
+{ lNet v0.5.1
 
 
   CopyRight (C) 2004-2006 Ales Katona
   CopyRight (C) 2004-2006 Ales Katona
 
 
@@ -93,8 +93,6 @@ type
     FPeerAddress: TInetSockAddr;
     FPeerAddress: TInetSockAddr;
     FConnected: Boolean;
     FConnected: Boolean;
     FConnecting: Boolean;
     FConnecting: Boolean;
-    FSocketClass: Integer;
-    FProtocol: Integer;
     FNextSock: TLSocket;
     FNextSock: TLSocket;
     FPrevSock: TLSocket;
     FPrevSock: TLSocket;
     FIgnoreShutdown: Boolean;
     FIgnoreShutdown: Boolean;
@@ -104,6 +102,8 @@ type
     FOnFree: TLSocketEvent;
     FOnFree: TLSocketEvent;
     FBlocking: Boolean;
     FBlocking: Boolean;
     FListenBacklog: Integer;
     FListenBacklog: Integer;
+    FProtocol: Integer;
+    FSocketType: Integer;
     FCreator: TLComponent;
     FCreator: TLComponent;
    protected
    protected
     function DoSend(const TheData; const TheSize: Integer): Integer;
     function DoSend(const TheData; const TheSize: Integer): Integer;
@@ -142,10 +142,10 @@ type
    public
    public
     property Connected: Boolean read FConnected;
     property Connected: Boolean read FConnected;
     property Connecting: Boolean read FConnecting;
     property Connecting: Boolean read FConnecting;
+    property Blocking: Boolean read FBlocking write SetBlocking;
     property ListenBacklog: Integer read FListenBacklog write FListenBacklog;
     property ListenBacklog: Integer read FListenBacklog write FListenBacklog;
     property Protocol: Integer read FProtocol write FProtocol;
     property Protocol: Integer read FProtocol write FProtocol;
-    property SocketType: Integer read FSocketClass write FSocketClass;
-    property Blocking: Boolean read FBlocking write SetBlocking;
+    property SocketType: Integer read FSocketType write FSocketType;
     property PeerAddress: string read GetPeerAddress;
     property PeerAddress: string read GetPeerAddress;
     property PeerPort: Word read GetPeerPort;
     property PeerPort: Word read GetPeerPort;
     property LocalAddress: string read GetLocalAddress;
     property LocalAddress: string read GetLocalAddress;
@@ -200,14 +200,13 @@ type
    protected
    protected
     FHost: string;
     FHost: string;
     FPort: Word;
     FPort: Word;
-    FSocketClass: TLSocketClass;
     FCreator: TLComponent;
     FCreator: TLComponent;
    public
    public
     constructor Create(aOwner: TComponent); override;
     constructor Create(aOwner: TComponent); override;
     procedure Disconnect; virtual; abstract;
     procedure Disconnect; virtual; abstract;
     procedure CallAction; virtual; abstract;
     procedure CallAction; virtual; abstract;
-
-    property SocketClass: TLSocketClass read FSocketClass write FSocketClass;
+   public
+    SocketClass: TLSocketClass;
     property Host: string read FHost write FHost;
     property Host: string read FHost write FHost;
     property Port: Word read FPort write FPort;
     property Port: Word read FPort write FPort;
     property Creator: TLComponent read FCreator write FCreator;
     property Creator: TLComponent read FCreator write FCreator;
@@ -281,8 +280,6 @@ type
     function IterNext: Boolean; virtual; abstract;
     function IterNext: Boolean; virtual; abstract;
     procedure IterReset; virtual; abstract;
     procedure IterReset; virtual; abstract;
    public
    public
-    property Host: string read FHost write FHost;
-    property Port: Word read FPort write FPort;
     property OnError: TLSocketErrorEvent read FOnError write FOnError;
     property OnError: TLSocketErrorEvent read FOnError write FOnError;
     property OnReceive: TLSocketEvent read FOnReceive write FOnReceive;
     property OnReceive: TLSocketEvent read FOnReceive write FOnReceive;
     property OnDisconnect: TLSocketEvent read FOnDisconnect write FOnDisconnect;
     property OnDisconnect: TLSocketEvent read FOnDisconnect write FOnDisconnect;
@@ -293,7 +290,6 @@ type
     property ListenBacklog: Integer read FListenBacklog write FListenBacklog;
     property ListenBacklog: Integer read FListenBacklog write FListenBacklog;
     property Iterator: TLSocket read FIterator;
     property Iterator: TLSocket read FIterator;
     property Timeout: DWord read GetTimeout write SetTimeout;
     property Timeout: DWord read GetTimeout write SetTimeout;
-    property SocketClass: TLSocketClass read FSocketClass write FSocketClass;
     property Eventer: TLEventer read FEventer write SetEventer;
     property Eventer: TLEventer read FEventer write SetEventer;
     property EventerClass: TLEventerClass read FEventerClass write FEventerClass;
     property EventerClass: TLEventerClass read FEventerClass write FEventerClass;
   end;
   end;
@@ -404,7 +400,7 @@ begin
   FConnected := False;
   FConnected := False;
   FConnecting := False;
   FConnecting := False;
   FIgnoreShutdown := False;
   FIgnoreShutdown := False;
-  FSocketClass := SOCK_STREAM;
+  FSocketType := SOCK_STREAM;
   FProtocol := LPROTO_TCP;
   FProtocol := LPROTO_TCP;
 end;
 end;
 
 
@@ -428,8 +424,8 @@ begin
   if FConnected or FConnecting then begin
   if FConnected or FConnecting then begin
     FConnected := False;
     FConnected := False;
     FConnecting := False;
     FConnecting := False;
-    if (FSocketClass = SOCK_STREAM) and (not FIgnoreShutdown) and WasConnected then
-      if ShutDown(FHandle, 2) <> 0 then
+    if (FSocketType = SOCK_STREAM) and (not FIgnoreShutdown) and WasConnected then
+      if fpShutDown(FHandle, 2) <> 0 then
         LogError('Shutdown error', LSocketError);
         LogError('Shutdown error', LSocketError);
     if CloseSocket(FHandle) <> 0 then
     if CloseSocket(FHandle) <> 0 then
       LogError('Closesocket error', LSocketError);
       LogError('Closesocket error', LSocketError);
@@ -457,7 +453,7 @@ end;
 function TLSocket.GetPeerAddress: string;
 function TLSocket.GetPeerAddress: string;
 begin
 begin
   Result := '';
   Result := '';
-  if FSocketClass = SOCK_STREAM then
+  if FSocketType = SOCK_STREAM then
     Result := NetAddrtoStr(FAddress.Addr)
     Result := NetAddrtoStr(FAddress.Addr)
   else
   else
     Result := NetAddrtoStr(FPeerAddress.Addr);
     Result := NetAddrtoStr(FPeerAddress.Addr);
@@ -469,7 +465,7 @@ var
   l: Integer;
   l: Integer;
 begin
 begin
   l := SizeOf(a);
   l := SizeOf(a);
-  GetSocketName(FHandle, a, l);
+  fpGetSockName(FHandle, @a, @l);
   Result := HostAddrToStr(LongWord(a.sin_addr));
   Result := HostAddrToStr(LongWord(a.sin_addr));
 end;
 end;
 
 
@@ -510,10 +506,10 @@ var
 begin
 begin
   Result := 0;
   Result := 0;
   if CanReceive then begin
   if CanReceive then begin
-    if FSocketClass = SOCK_STREAM then
-      Result := sockets.Recv(FHandle, aData, aSize, LMSG)
+    if FSocketType = SOCK_STREAM then
+      Result := sockets.fpRecv(FHandle, @aData, aSize, LMSG)
     else
     else
-      Result := sockets.Recvfrom(FHandle, aData, aSize, LMSG, FPeerAddress, AddressLength);
+      Result := sockets.fpRecvfrom(FHandle, @aData, aSize, LMSG, @FPeerAddress, @AddressLength);
     if Result = 0 then
     if Result = 0 then
       Disconnect;
       Disconnect;
     if Result = SOCKET_ERROR then begin
     if Result = SOCKET_ERROR then begin
@@ -527,11 +523,14 @@ begin
 end;
 end;
 
 
 function TLSocket.DoSend(const TheData; const TheSize: Integer): Integer;
 function TLSocket.DoSend(const TheData; const TheSize: Integer): Integer;
+var
+  AddressLength: Integer;
 begin
 begin
-  if FSocketClass = SOCK_STREAM then
-    Result := sockets.send(FHandle, TheData, TheSize, LMSG)
+  AddressLength := SizeOf(FPeerAddress);
+  if FSocketType = SOCK_STREAM then
+    Result := sockets.fpsend(FHandle, @TheData, TheSize, LMSG)
   else
   else
-    Result := sockets.sendto(FHandle, TheData, TheSize, LMSG, FPeerAddress, SizeOf(FPeerAddress));
+    Result := sockets.fpsendto(FHandle, @TheData, TheSize, LMSG, @FPeerAddress, AddressLength);
 end;
 end;
 
 
 function TLSocket.SetupSocket(const APort: Word; const Address: string): Boolean;
 function TLSocket.SetupSocket(const APort: Word; const Address: string): Boolean;
@@ -542,13 +541,13 @@ begin
   Result := false;
   Result := false;
   if not FConnected and not FConnecting then begin
   if not FConnected and not FConnecting then begin
     Done := true;
     Done := true;
-    FHandle := fpSocket(AF_INET, FSocketClass, FProtocol);
+    FHandle := fpSocket(AF_INET, FSocketType, FProtocol);
     if FHandle = INVALID_SOCKET then
     if FHandle = INVALID_SOCKET then
       Bail('Socket error', LSocketError);
       Bail('Socket error', LSocketError);
     SetOptions;
     SetOptions;
-    if FSocketClass = SOCK_DGRAM then begin
+    if FSocketType = SOCK_DGRAM then begin
       Arg := 1;
       Arg := 1;
-      if SetSocketOptions(FHandle, SOL_SOCKET, SO_BROADCAST, Arg, Sizeof(Arg)) = SOCKET_ERROR then
+      if fpsetsockopt(FHandle, SOL_SOCKET, SO_BROADCAST, @Arg, Sizeof(Arg)) = SOCKET_ERROR then
         Bail('SetSockOpt error', LSocketError);
         Bail('SetSockOpt error', LSocketError);
     end;
     end;
     
     
@@ -579,7 +578,7 @@ begin
       Bail('Error on bind', LSocketError)
       Bail('Error on bind', LSocketError)
     else
     else
       Result := true;
       Result := true;
-    if (FSocketClass = SOCK_STREAM) and Result then
+    if (FSocketType = SOCK_STREAM) and Result then
       if fpListen(FHandle, FListenBacklog) = SOCKET_ERROR then
       if fpListen(FHandle, FListenBacklog) = SOCKET_ERROR then
         Result  :=  Bail('Error on Listen', LSocketError)
         Result  :=  Bail('Error on Listen', LSocketError)
       else
       else
@@ -650,7 +649,7 @@ begin
   FPort := 0;
   FPort := 0;
   FListenBacklog := LDEFAULT_BACKLOG;
   FListenBacklog := LDEFAULT_BACKLOG;
   FTimeout := 0;
   FTimeout := 0;
-  FSocketClass := TLSocket;
+  SocketClass := TLSocket;
   FOnReceive := nil;
   FOnReceive := nil;
   FOnError := nil;
   FOnError := nil;
   FOnDisconnect := nil;
   FOnDisconnect := nil;
@@ -857,7 +856,7 @@ begin
   if Assigned(FRootSock) and FRootSock.Connected then
   if Assigned(FRootSock) and FRootSock.Connected then
     Disconnect;
     Disconnect;
 
 
-  FRootSock := InitSocket(FSocketClass.Create);
+  FRootSock := InitSocket(SocketClass.Create);
   FIterator := FRootSock;
   FIterator := FRootSock;
 
 
   Result := FRootSock.SetupSocket(APort, LADDR_ANY);
   Result := FRootSock.SetupSocket(APort, LADDR_ANY);
@@ -876,7 +875,7 @@ begin
   if Assigned(FRootSock) and FRootSock.Connected then
   if Assigned(FRootSock) and FRootSock.Connected then
     Disconnect;
     Disconnect;
 
 
-  FRootSock := InitSocket(FSocketClass.Create);
+  FRootSock := InitSocket(SocketClass.Create);
   FIterator := FRootSock;
   FIterator := FRootSock;
   
   
   if FRootSock.Listen(APort, AIntf) then begin
   if FRootSock.Listen(APort, AIntf) then begin
@@ -1031,7 +1030,7 @@ begin
   if Assigned(FRootSock) then
   if Assigned(FRootSock) then
     Disconnect;
     Disconnect;
     
     
-  FRootSock := InitSocket(FSocketClass.Create);
+  FRootSock := InitSocket(SocketClass.Create);
   Result := FRootSock.Connect(Address, aPort);
   Result := FRootSock.Connect(Address, aPort);
   
   
   if Result then begin
   if Result then begin
@@ -1051,7 +1050,7 @@ begin
   if Assigned(FRootSock) then
   if Assigned(FRootSock) then
     Disconnect;
     Disconnect;
   
   
-  FRootSock := InitSocket(FSocketClass.Create);
+  FRootSock := InitSocket(SocketClass.Create);
   FRootSock.FIgnoreShutdown := True;
   FRootSock.FIgnoreShutdown := True;
   if FRootSock.Listen(APort, AIntf) then begin
   if FRootSock.Listen(APort, AIntf) then begin
     FRootSock.FConnected := True;
     FRootSock.FConnected := True;
@@ -1139,7 +1138,7 @@ var
 begin
 begin
   with TLSocket(aSocket) do begin
   with TLSocket(aSocket) do begin
     l := SizeOf(a);
     l := SizeOf(a);
-    if Sockets.GetPeerName(FHandle, a, l) <> 0 then
+    if Sockets.fpGetPeerName(FHandle, @a, @l) <> 0 then
       Self.Bail('Error on connect: connection refused', TLSocket(aSocket))
       Self.Bail('Error on connect: connection refused', TLSocket(aSocket))
     else begin
     else begin
       FConnected := True;
       FConnected := True;
@@ -1153,7 +1152,7 @@ procedure TLTcp.AcceptAction(aSocket: TLHandle);
 var
 var
   Tmp: TLSocket;
   Tmp: TLSocket;
 begin
 begin
-  Tmp := InitSocket(FSocketClass.Create);
+  Tmp := InitSocket(SocketClass.Create);
   if Tmp.Accept(FRootSock.FHandle) then begin
   if Tmp.Accept(FRootSock.FHandle) then begin
     if Assigned(FRootSock.FNextSock) then begin
     if Assigned(FRootSock.FNextSock) then begin
       Tmp.FNextSock := FRootSock.FNextSock;
       Tmp.FNextSock := FRootSock.FNextSock;

+ 143 - 25
utils/fppkg/lnet/lsmtp.pp

@@ -93,6 +93,7 @@ type
   TMail = class
   TMail = class
    protected
    protected
     FMailText: string;
     FMailText: string;
+    FMailStream: TStream;
     FRecipients: string;
     FRecipients: string;
     FSender: string;
     FSender: string;
     FSubject: string;
     FSubject: string;
@@ -103,6 +104,7 @@ type
    public
    public
     property Attachments: TAttachmentList read FAttachments;
     property Attachments: TAttachmentList read FAttachments;
     property MailText: string read FMailText write FMailText;
     property MailText: string read FMailText write FMailText;
+    property MailStream: TStream read FMailStream write FMailStream;
     property Sender: string read FSender write FSender;
     property Sender: string read FSender write FSender;
     property Recipients: string read FRecipients write FRecipients;
     property Recipients: string read FRecipients write FRecipients;
     property Subject: string read FSubject write FSubject;
     property Subject: string read FSubject write FSubject;
@@ -148,15 +150,18 @@ type
     FOnSuccess: TLSMTPClientStatusEvent;
     FOnSuccess: TLSMTPClientStatusEvent;
     FOnFailure: TLSMTPClientStatusEvent;
     FOnFailure: TLSMTPClientStatusEvent;
     FOnError: TLSocketErrorEvent;
     FOnError: TLSocketErrorEvent;
+    FOnSent: TLSocketProgressEvent;
 
 
     FSL: TStringList;
     FSL: TStringList;
     FStatusSet: TLSMTPStatusSet;
     FStatusSet: TLSMTPStatusSet;
-    FMessage: string;
+    FBuffer: string;
+    FStream: TStream;
    protected
    protected
     procedure OnEr(const msg: string; aSocket: TLSocket);
     procedure OnEr(const msg: string; aSocket: TLSocket);
     procedure OnRe(aSocket: TLSocket);
     procedure OnRe(aSocket: TLSocket);
     procedure OnCo(aSocket: TLSocket);
     procedure OnCo(aSocket: TLSocket);
     procedure OnDs(aSocket: TLSocket);
     procedure OnDs(aSocket: TLSocket);
+    procedure OnCs(aSocket: TLSocket);
    protected
    protected
     function CanContinue(const aStatus: TLSMTPStatus; const Arg1, Arg2: string): Boolean;
     function CanContinue(const aStatus: TLSMTPStatus; const Arg1, Arg2: string): Boolean;
     
     
@@ -165,6 +170,9 @@ type
     procedure EvaluateAnswer(const Ans: string);
     procedure EvaluateAnswer(const Ans: string);
     
     
     procedure ExecuteFrontCommand;
     procedure ExecuteFrontCommand;
+    
+    procedure InsertCRLFs;
+    procedure SendData(const FromStream: Boolean = False);
    public
    public
     constructor Create(aOwner: TComponent); override;
     constructor Create(aOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -175,7 +183,8 @@ type
     function Get(var aData; const aSize: Integer; aSocket: TLSocket = nil): Integer; virtual;
     function Get(var aData; const aSize: Integer; aSocket: TLSocket = nil): Integer; virtual;
     function GetMessage(out msg: string; aSocket: TLSocket = nil): Integer; virtual;
     function GetMessage(out msg: string; aSocket: TLSocket = nil): Integer; virtual;
 
 
-    procedure SendMail(const From, Recipients, Subject, Msg: string);
+    procedure SendMail(From, Recipients, Subject, Msg: string);
+    procedure SendMail(From, Recipients, Subject: string; aStream: TStream);
     procedure SendMail(aMail: TMail);
     procedure SendMail(aMail: TMail);
     
     
     procedure Helo(aHost: string = '');
     procedure Helo(aHost: string = '');
@@ -198,17 +207,17 @@ type
     property OnSuccess: TLSMTPClientStatusEvent read FOnSuccess write FOnSuccess;
     property OnSuccess: TLSMTPClientStatusEvent read FOnSuccess write FOnSuccess;
     property OnFailure: TLSMTPClientStatusEvent read FOnFailure write FOnFailure;
     property OnFailure: TLSMTPClientStatusEvent read FOnFailure write FOnFailure;
     property OnError: TLSocketErrorEvent read FOnError write FOnError;
     property OnError: TLSocketErrorEvent read FOnError write FOnError;
+    property OnSent: TLSocketProgressEvent read FOnSent write FOnSent;
   end;
   end;
 
 
 implementation
 implementation
 
 
 uses
 uses
-  SysUtils;
+  SysUtils, lMimeStreams;
 
 
 const
 const
   EMPTY_REC: TLSMTPStatusRec = (Status: ssNone; Args: ('', ''));
   EMPTY_REC: TLSMTPStatusRec = (Status: ssNone; Args: ('', ''));
-  SLE                        = #13#10;
-  
+
 {$i lcontainers.inc}
 {$i lcontainers.inc}
 
 
 function StatusToStr(const aStatus: TLSMTPStatus): string;
 function StatusToStr(const aStatus: TLSMTPStatus): string;
@@ -285,14 +294,14 @@ begin
   FPort := 25;
   FPort := 25;
   FStatusSet := []; // empty set for "ok/not-ok" Event
   FStatusSet := []; // empty set for "ok/not-ok" Event
   FSL := TStringList.Create;
   FSL := TStringList.Create;
-  FHost := '';
-  FMessage := '';
 //  {$warning TODO: fix pipelining support when server does it}
 //  {$warning TODO: fix pipelining support when server does it}
   FPipeLine := False;
   FPipeLine := False;
   
   
   FConnection.OnError := @OnEr;
   FConnection.OnError := @OnEr;
+  FConnection.OnCanSend := @OnCs;
   FConnection.OnReceive := @OnRe;
   FConnection.OnReceive := @OnRe;
   FConnection.OnConnect := @OnCo;
   FConnection.OnConnect := @OnCo;
+  FConnection.OnDisconnect := @OnDs;
 
 
   FStatus := TLSMTPStatusFront.Create(EMPTY_REC);
   FStatus := TLSMTPStatusFront.Create(EMPTY_REC);
   FCommandFront := TLSMTPStatusFront.Create(EMPTY_REC);
   FCommandFront := TLSMTPStatusFront.Create(EMPTY_REC);
@@ -332,6 +341,11 @@ begin
     FOnDisconnect(aSocket);
     FOnDisconnect(aSocket);
 end;
 end;
 
 
+procedure TLSMTPClient.OnCs(aSocket: TLSocket);
+begin
+  SendData(FStatus.First.Status = ssData);
+end;
+
 function TLSMTPClient.CanContinue(const aStatus: TLSMTPStatus; const Arg1, Arg2: string): Boolean;
 function TLSMTPClient.CanContinue(const aStatus: TLSMTPStatus; const Arg1, Arg2: string): Boolean;
 begin
 begin
   Result := FPipeLine or FStatus.Empty;
   Result := FPipeLine or FStatus.Empty;
@@ -347,7 +361,7 @@ begin
   if FSL.Count > 0 then
   if FSL.Count > 0 then
     for i := 0 to FSL.Count-1 do
     for i := 0 to FSL.Count-1 do
       if Length(FSL[i]) > 0 then EvaluateAnswer(FSL[i]);
       if Length(FSL[i]) > 0 then EvaluateAnswer(FSL[i]);
-  s := StringReplace(s, SLE, LineEnding, [rfReplaceAll]);
+  s := StringReplace(s, CRLF, LineEnding, [rfReplaceAll]);
   i := Pos('PASS', s);
   i := Pos('PASS', s);
   if i > 0 then
   if i > 0 then
     s := Copy(s, 1, i-1) + 'PASS';
     s := Copy(s, 1, i-1) + 'PASS';
@@ -417,10 +431,7 @@ begin
                             Eventize(FStatus.First.Status, True);
                             Eventize(FStatus.First.Status, True);
                             FStatus.Remove;
                             FStatus.Remove;
                           end;
                           end;
-                300..399: if Length(FMessage) > 0 then begin
-                            FConnection.SendMessage(FMessage);
-                            FMessage := '';
-                          end;
+                300..399: SendData(True);
               else        begin
               else        begin
                             Eventize(FStatus.First.Status, False);
                             Eventize(FStatus.First.Status, False);
                             FStatus.Remove;
                             FStatus.Remove;
@@ -440,6 +451,7 @@ begin
                 Disconnect;
                 Disconnect;
               end;
               end;
     end;
     end;
+    
   if FStatus.Empty and not FCommandFront.Empty then
   if FStatus.Empty and not FCommandFront.Empty then
     ExecuteFrontCommand;
     ExecuteFrontCommand;
 end;
 end;
@@ -459,6 +471,73 @@ begin
   FCommandFront.Remove;
   FCommandFront.Remove;
 end;
 end;
 
 
+procedure TLSMTPClient.InsertCRLFs;
+var
+  i, c: Integer;
+begin
+  c := 0;
+  i := 2;
+  while i <= Length(FBuffer) do begin
+    if (FBuffer[i - 1] = #13) and (FBuffer[i] = #10) then begin
+      c := 0;
+      Inc(i);
+    end else
+      Inc(c);
+      
+    if c >= 74 then begin
+      Insert(CRLF, FBuffer, i);
+      c := 0;
+      Inc(i, 2);
+    end;
+
+    Inc(i);
+  end;
+end;
+
+procedure TLSMTPClient.SendData(const FromStream: Boolean = False);
+const
+  SBUF_SIZE = 65535;
+  
+  procedure FillBuffer;
+  var
+    s: string;
+  begin
+    SetLength(s, SBUF_SIZE - Length(FBuffer));
+    SetLength(s, FStream.Read(s[1], Length(s)));
+    
+    FBuffer := FBuffer + s;
+    
+    if FStream.Position = FStream.Size then begin // we finished the stream
+      FBuffer := FBuffer + CRLF + '.' + CRLF;
+      FStream := nil;
+    end;
+  end;
+
+var
+  n: Integer;
+  Sent: Integer;
+begin
+  if FromStream and Assigned(FStream) then
+    FillBuffer;
+
+  n := 1;
+  Sent := 0;
+  while (Length(FBuffer) > 0) and (n > 0) do begin
+    InsertCRLFs;
+  
+    n := FConnection.SendMessage(FBuffer);
+    Sent := Sent + n;
+    if n > 0 then
+      Delete(FBuffer, 1, n);
+
+    if FromStream and Assigned(FStream) and (Length(FBuffer) < SBUF_SIZE) then
+      FillBuffer;
+  end;
+  
+  if Assigned(FOnSent) and (FStatus.First.Status = ssData) then
+    FOnSent(FConnection.Iterator, Sent);
+end;
+
 function TLSMTPClient.Connect(const aHost: string; const aPort: Word = 25): Boolean;
 function TLSMTPClient.Connect(const aHost: string; const aPort: Word = 25): Boolean;
 begin
 begin
   Result := False;
   Result := False;
@@ -495,24 +574,51 @@ begin
     Result := CleanInput(msg);
     Result := CleanInput(msg);
 end;
 end;
 
 
-procedure TLSMTPClient.SendMail(const From, Recipients, Subject, Msg: string);
+procedure TLSMTPClient.SendMail(From, Recipients, Subject, Msg: string);
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
+  FStream := nil;
+  From := EncodeMimeHeaderText(From);
+  Recipients := EncodeMimeHeaderText(Recipients);
+  Subject := EncodeMimeHeaderText(Subject);
+  
+  if (Length(Recipients) > 0) and (Length(From) > 0) then begin
+    Mail(From);
+    FSL.CommaText := StringReplace(Recipients, ' ', ',', [rfReplaceAll]);
+    for i := 0 to FSL.Count-1 do
+      Rcpt(FSL[i]);
+    Data('From: ' + From + CRLF + 'Subject: ' + Subject + CRLF + 'To: ' + FSL.CommaText + CRLF + Msg);
+    Rset;
+  end;
+end;
+
+procedure TLSMTPClient.SendMail(From, Recipients, Subject: string; aStream: TStream);
+var
+  i: Integer;
+begin
+  From := EncodeMimeHeaderText(From);
+  Recipients := EncodeMimeHeaderText(Recipients);
+  Subject := EncodeMimeHeaderText(Subject);
+  
+  FStream := aStream;
+
   if (Length(Recipients) > 0) and (Length(From) > 0) then begin
   if (Length(Recipients) > 0) and (Length(From) > 0) then begin
     Mail(From);
     Mail(From);
     FSL.CommaText := StringReplace(Recipients, ' ', ',', [rfReplaceAll]);
     FSL.CommaText := StringReplace(Recipients, ' ', ',', [rfReplaceAll]);
     for i := 0 to FSL.Count-1 do
     for i := 0 to FSL.Count-1 do
       Rcpt(FSL[i]);
       Rcpt(FSL[i]);
-    Data('From: ' + From + SLE + 'Subject: ' + Subject + SLE + 'To: ' + FSL.CommaText + SLE + Msg);
+    Data('From: ' + From + CRLF + 'Subject: ' + Subject + CRLF + 'To: ' + FSL.CommaText + CRLF);
     Rset;
     Rset;
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.SendMail(aMail: TMail);
 procedure TLSMTPClient.SendMail(aMail: TMail);
 begin
 begin
-  // TODO: incorporate attachments + encoding
-  SendMail(aMail.Sender, aMail.Recipients, aMail.Subject, aMail.MailText);
+  if Length(aMail.MailText) > 0 then
+    SendMail(aMail.Sender, aMail.Recipients, aMail.Subject, aMail.MailText)
+  else if Assigned(aMail.MailStream) then
+    SendMail(aMail.Sender, aMail.Recipients, aMail.Subject, aMail.MailStream);
 end;
 end;
 
 
 procedure TLSMTPClient.Helo(aHost: string = '');
 procedure TLSMTPClient.Helo(aHost: string = '');
@@ -520,8 +626,9 @@ begin
   if Length(Host) = 0 then
   if Length(Host) = 0 then
     aHost := FHost;
     aHost := FHost;
   if CanContinue(ssHelo, aHost, '') then begin
   if CanContinue(ssHelo, aHost, '') then begin
-    FConnection.SendMessage('HELO ' + aHost + SLE);
+    FBuffer := FBuffer + 'HELO ' + aHost + CRLF;
     FStatus.Insert(MakeStatusRec(ssHelo, '', ''));
     FStatus.Insert(MakeStatusRec(ssHelo, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 
@@ -530,50 +637,61 @@ begin
   if Length(aHost) = 0 then
   if Length(aHost) = 0 then
     aHost := FHost;
     aHost := FHost;
   if CanContinue(ssEhlo, aHost, '') then begin
   if CanContinue(ssEhlo, aHost, '') then begin
-    FConnection.SendMessage('EHLO ' + aHost + SLE);
+    FBuffer := FBuffer + 'EHLO ' + aHost + CRLF;
     FStatus.Insert(MakeStatusRec(ssEhlo, '', ''));
     FStatus.Insert(MakeStatusRec(ssEhlo, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.Mail(const From: string);
 procedure TLSMTPClient.Mail(const From: string);
 begin
 begin
   if CanContinue(ssMail, From, '') then begin
   if CanContinue(ssMail, From, '') then begin
-    FConnection.SendMessage('MAIL FROM:' + '<' + From + '>' + SLE);
+    FBuffer := FBuffer + 'MAIL FROM:' + '<' + From + '>' + CRLF;
     FStatus.Insert(MakeStatusRec(ssMail, '', ''));
     FStatus.Insert(MakeStatusRec(ssMail, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.Rcpt(const RcptTo: string);
 procedure TLSMTPClient.Rcpt(const RcptTo: string);
 begin
 begin
   if CanContinue(ssRcpt, RcptTo, '') then begin
   if CanContinue(ssRcpt, RcptTo, '') then begin
-    FConnection.SendMessage('RCPT TO:' + '<' + RcptTo + '>' + SLE);
+    FBuffer := FBuffer + 'RCPT TO:' + '<' + RcptTo + '>' + CRLF;
     FStatus.Insert(MakeStatusRec(ssRcpt, '', ''));
     FStatus.Insert(MakeStatusRec(ssRcpt, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.Data(const Msg: string);
 procedure TLSMTPClient.Data(const Msg: string);
 begin
 begin
   if CanContinue(ssData, Msg, '') then begin
   if CanContinue(ssData, Msg, '') then begin
-    // TODO: clean SLEs and '.' on line starts
-    FMessage := Msg + SLE + '.' + SLE;
-    FConnection.SendMessage('DATA' + SLE);
+    if Assigned(FStream) then begin
+      if Length(Msg) > 0 then
+        FBuffer := 'DATA ' + Msg
+      else
+        FBuffer := 'DATA ';
+    end else
+      FBuffer := 'DATA ' + Msg + CRLF + '.' + CRLF;
+      
     FStatus.Insert(MakeStatusRec(ssData, '', ''));
     FStatus.Insert(MakeStatusRec(ssData, '', ''));
+    SendData(True);
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.Rset;
 procedure TLSMTPClient.Rset;
 begin
 begin
   if CanContinue(ssRset, '', '') then begin
   if CanContinue(ssRset, '', '') then begin
-    FConnection.SendMessage('RSET' + SLE);
+    FBuffer := FBuffer + 'RSET' + CRLF;
     FStatus.Insert(MakeStatusRec(ssRset, '', ''));
     FStatus.Insert(MakeStatusRec(ssRset, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 
 procedure TLSMTPClient.Quit;
 procedure TLSMTPClient.Quit;
 begin
 begin
   if CanContinue(ssQuit, '', '') then begin
   if CanContinue(ssQuit, '', '') then begin
-    FConnection.SendMessage('QUIT' + SLE);
+    FBuffer := FBuffer + 'QUIT' + CRLF;
     FStatus.Insert(MakeStatusRec(ssQuit, '', ''));
     FStatus.Insert(MakeStatusRec(ssQuit, '', ''));
+    SendData;
   end;
   end;
 end;
 end;
 
 

+ 36 - 8
utils/fppkg/lnet/ltelnet.pp

@@ -87,6 +87,8 @@ type
     FCommandArgs: string[3];
     FCommandArgs: string[3];
     FOrders: TLTelnetControlChars;
     FOrders: TLTelnetControlChars;
     FConnected: Boolean;
     FConnected: Boolean;
+    FBuffer: string;
+
     function Question(const Command: Char; const Value: Boolean): Char;
     function Question(const Command: Char; const Value: Boolean): Char;
     
     
     function GetTimeout: DWord;
     function GetTimeout: DWord;
@@ -104,6 +106,8 @@ type
     procedure React(const Operation, Command: Char); virtual; abstract;
     procedure React(const Operation, Command: Char); virtual; abstract;
     
     
     procedure SendCommand(const Command: Char; const Value: Boolean); virtual; abstract;
     procedure SendCommand(const Command: Char; const Value: Boolean); virtual; abstract;
+
+    procedure OnCs(aSocket: TLSocket);
    public
    public
     constructor Create(aOwner: TComponent); override;
     constructor Create(aOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -136,8 +140,6 @@ type
 
 
   { TLTelnetClient }
   { TLTelnetClient }
 
 
-  { TLTelnetClient }
-
   TLTelnetClient = class(TLTelnet, ILClient)
   TLTelnetClient = class(TLTelnet, ILClient)
    protected
    protected
     FLocalEcho: Boolean;
     FLocalEcho: Boolean;
@@ -145,7 +147,7 @@ type
     procedure OnDs(aSocket: TLSocket);
     procedure OnDs(aSocket: TLSocket);
     procedure OnRe(aSocket: TLSocket);
     procedure OnRe(aSocket: TLSocket);
     procedure OnCo(aSocket: TLSocket);
     procedure OnCo(aSocket: TLSocket);
-    
+
     procedure React(const Operation, Command: Char); override;
     procedure React(const Operation, Command: Char); override;
     
     
     procedure SendCommand(const Command: Char; const Value: Boolean); override;
     procedure SendCommand(const Command: Char; const Value: Boolean); override;
@@ -180,7 +182,10 @@ var
 constructor TLTelnet.Create(aOwner: TComponent);
 constructor TLTelnet.Create(aOwner: TComponent);
 begin
 begin
   inherited Create(aOwner);
   inherited Create(aOwner);
+  
   FConnection := TLTCP.Create(aOwner);
   FConnection := TLTCP.Create(aOwner);
+  FConnection.OnCanSend := @OnCs;
+  
   FOutput := TMemoryStream.Create;
   FOutput := TMemoryStream.Create;
   FCommandCharIndex := 0;
   FCommandCharIndex := 0;
   FStack := TLControlStack.Create;
   FStack := TLControlStack.Create;
@@ -274,6 +279,20 @@ begin
       FOutput.WriteByte(Byte(msg[i]));
       FOutput.WriteByte(Byte(msg[i]));
 end;
 end;
 
 
+procedure TLTelnet.OnCs(aSocket: TLSocket);
+var
+  n: Integer;
+begin
+  n := 1;
+
+  while n > 0 do begin
+    n := FConnection.SendMessage(FBuffer);
+
+    if n > 0 then
+      System.Delete(FBuffer, 1, n);
+  end;
+end;
+
 function TLTelnet.OptionIsSet(const Option: Char): Boolean;
 function TLTelnet.OptionIsSet(const Option: Char): Boolean;
 begin
 begin
   Result := False;
   Result := False;
@@ -315,7 +334,8 @@ begin
   {$ifdef debug}
   {$ifdef debug}
   Writeln('**SENT** ', TNames[Char(How)], ' ', TNames[aCommand]);
   Writeln('**SENT** ', TNames[Char(How)], ' ', TNames[aCommand]);
   {$endif}
   {$endif}
-  FConnection.SendMessage(TS_IAC + Char(How) + aCommand);
+  FBuffer := FBuffer + TS_IAC + Char(How) + aCommand;
+  OnCs(nil);
 end;
 end;
 
 
 //****************************TLTelnetClient*****************************
 //****************************TLTelnetClient*****************************
@@ -327,6 +347,7 @@ begin
   FConnection.OnDisconnect := @OnDs;
   FConnection.OnDisconnect := @OnDs;
   FConnection.OnReceive := @OnRe;
   FConnection.OnReceive := @OnRe;
   FConnection.OnConnect := @OnCo;
   FConnection.OnConnect := @OnCo;
+
   FConnected := False;
   FConnected := False;
   FPossible := [TS_ECHO, TS_HYI, TS_SGA];
   FPossible := [TS_ECHO, TS_HYI, TS_SGA];
   FActive := [];
   FActive := [];
@@ -373,7 +394,8 @@ procedure TLTelnetClient.React(const Operation, Command: Char);
     {$ifdef debug}
     {$ifdef debug}
     Writeln('**SENT** ', TNames[Operation], ' ', TNames[Command]);
     Writeln('**SENT** ', TNames[Operation], ' ', TNames[Command]);
     {$endif}
     {$endif}
-    FConnection.SendMessage(TS_IAC + Operation + Command);
+    FBuffer := FBuffer + TS_IAC + Operation + Command;
+    OnCs(nil);
   end;
   end;
   
   
   procedure Refuse(const Operation, Command: Char);
   procedure Refuse(const Operation, Command: Char);
@@ -382,7 +404,8 @@ procedure TLTelnetClient.React(const Operation, Command: Char);
     {$ifdef debug}
     {$ifdef debug}
     Writeln('**SENT** ', TNames[Operation], ' ', TNames[Command]);
     Writeln('**SENT** ', TNames[Operation], ' ', TNames[Command]);
     {$endif}
     {$endif}
-    FConnection.SendMessage(TS_IAC + Operation + Command);
+    FBuffer := FBuffer + TS_IAC + Operation + Command;
+    OnCs(nil);
   end;
   end;
   
   
 begin
 begin
@@ -411,7 +434,8 @@ begin
     case Question(Command, Value) of
     case Question(Command, Value) of
       TS_WILL : FActive := FActive + [Command];
       TS_WILL : FActive := FActive + [Command];
     end;
     end;
-    FConnection.SendMessage(TS_IAC + Question(Command, Value) + Command);
+    FBuffer := FBuffer + TS_IAC + Question(Command, Value) + Command;
+    OnCs(nil);
   end;
   end;
 end;
 end;
 
 
@@ -459,7 +483,11 @@ begin
     DoubleIAC(Tmp);
     DoubleIAC(Tmp);
     if LocalEcho and (not OptionIsSet(TS_ECHO)) and (not OptionIsSet(TS_HYI)) then
     if LocalEcho and (not OptionIsSet(TS_ECHO)) and (not OptionIsSet(TS_HYI)) then
       FOutput.Write(PChar(Tmp)^, Length(Tmp));
       FOutput.Write(PChar(Tmp)^, Length(Tmp));
-    Result := FConnection.SendMessage(Tmp);
+      
+    FBuffer := FBuffer + Tmp;
+    OnCs(nil);
+    
+    Result := aSize;
   end;
   end;
   {$ifdef debug}
   {$ifdef debug}
   Writeln('**SEND END** ');
   Writeln('**SEND END** ');

+ 57 - 66
utils/fppkg/lnet/lwebserver.pp

@@ -70,11 +70,6 @@ type
     FParsePos: pchar;
     FParsePos: pchar;
     FReadPos: integer;
     FReadPos: integer;
     FParsingHeaders: boolean;
     FParsingHeaders: boolean;
-    FDocumentRoot: string;
-    FExtraPath: string;
-    FEnvPath: string;
-    FScriptFileName: string;
-    FScriptName: string;
    
    
     procedure AddEnvironment(const AName, AValue: string); virtual; abstract;
     procedure AddEnvironment(const AName, AValue: string); virtual; abstract;
     procedure AddHTTPParam(const AName: string; AParam: TLHTTPParameter);
     procedure AddHTTPParam(const AName: string; AParam: TLHTTPParameter);
@@ -83,17 +78,17 @@ type
     procedure WriteCGIBlock;
     procedure WriteCGIBlock;
     function  WriteCGIData: TWriteBlockStatus; virtual; abstract;
     function  WriteCGIData: TWriteBlockStatus; virtual; abstract;
   public
   public
+    FDocumentRoot: string;
+    FExtraPath: string;
+    FEnvPath: string;
+    FScriptFileName: string;
+    FScriptName: string;
+
     constructor Create(ASocket: TLHTTPSocket);
     constructor Create(ASocket: TLHTTPSocket);
     destructor Destroy; override;
     destructor Destroy; override;
 
 
     function  FillBuffer: TWriteBlockStatus; override;
     function  FillBuffer: TWriteBlockStatus; override;
     procedure StartRequest; virtual;
     procedure StartRequest; virtual;
-   
-    property DocumentRoot: string read FDocumentRoot write FDocumentRoot;
-    property EnvPath: string read FEnvPath write FEnvPath;
-    property ExtraPath: string read FExtraPath write FExtraPath;
-    property ScriptFileName: string read FScriptFileName write FScriptFileName;
-    property ScriptName: string read FScriptName write FScriptName;
   end;
   end;
 
 
   TSimpleCGIOutput = class(TCGIOutput)
   TSimpleCGIOutput = class(TCGIOutput)
@@ -142,17 +137,12 @@ type
 
 
   TCGIHandler = class(TURIHandler)
   TCGIHandler = class(TURIHandler)
   protected
   protected
-    FScriptPathPrefix: string;
-    FCGIRoot: string;
-    FDocumentRoot: string;
-    FEnvPath: string;
-
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; override;
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; override;
   public
   public
-    property CGIRoot: string read FCGIRoot write FCGIRoot;
-    property DocumentRoot: string read FDocumentRoot write FDocumentRoot;
-    property EnvPath: string read FEnvPath write FEnvPath;
-    property ScriptPathPrefix: string read FScriptPathPrefix write FScriptPathPrefix;
+    FCGIRoot: string;
+    FEnvPath: string;
+    FDocumentRoot: string;
+    FScriptPathPrefix: string;
   end;
   end;
 
 
   TDocumentRequest = record
   TDocumentRequest = record
@@ -183,8 +173,6 @@ type
   protected
   protected
     FDocHandlerList: TDocumentHandler;
     FDocHandlerList: TDocumentHandler;
     FDirIndexList: TStrings;
     FDirIndexList: TStrings;
-  protected
-    FDocumentRoot: string;
     FMimeTypeFile: string;
     FMimeTypeFile: string;
 
 
     procedure SetMimeTypeFile(const AValue: string);
     procedure SetMimeTypeFile(const AValue: string);
@@ -192,13 +180,14 @@ type
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; override;
     function HandleURI(ASocket: TLHTTPServerSocket): TOutputItem; override;
     procedure RegisterWithEventer(AEventer: TLEventer); override;
     procedure RegisterWithEventer(AEventer: TLEventer); override;
   public
   public
+    DocumentRoot: string;
+
     constructor Create;
     constructor Create;
     destructor Destroy; override;
     destructor Destroy; override;
     
     
     procedure RegisterHandler(AHandler: TDocumentHandler);
     procedure RegisterHandler(AHandler: TDocumentHandler);
 
 
     property DirIndexList: TStrings read FDirIndexList;
     property DirIndexList: TStrings read FDirIndexList;
-    property DocumentRoot: string read FDocumentRoot write FDocumentRoot;
     property MimeTypeFile: string read FMimeTypeFile write SetMimeTypeFile;
     property MimeTypeFile: string read FMimeTypeFile write SetMimeTypeFile;
   end;
   end;
 
 
@@ -321,25 +310,25 @@ var
   lOutput: TSimpleCGIOutput;
   lOutput: TSimpleCGIOutput;
   lExecPath: string;
   lExecPath: string;
 begin
 begin
-  if StrLComp(ASocket.RequestInfo.Argument, PChar(ScriptPathPrefix),
-      Length(ScriptPathPrefix)) = 0 then
+  if StrLComp(ASocket.FRequestInfo.Argument, PChar(FScriptPathPrefix),
+      Length(FScriptPathPrefix)) = 0 then
   begin
   begin
     lOutput := TSimpleCGIOutput.Create(ASocket);
     lOutput := TSimpleCGIOutput.Create(ASocket);
-    lOutput.DocumentRoot := FDocumentRoot;
-    lOutput.EnvPath := FEnvPath;
+    lOutput.FDocumentRoot := FDocumentRoot;
+    lOutput.FEnvPath := FEnvPath;
     lOutput.Process.CurrentDirectory := FCGIRoot;
     lOutput.Process.CurrentDirectory := FCGIRoot;
-    lExecPath := (ASocket.RequestInfo.Argument+Length(ScriptPathPrefix));
+    lExecPath := ASocket.FRequestInfo.Argument+Length(FScriptPathPrefix);
     DoDirSeparators(lExecPath);
     DoDirSeparators(lExecPath);
     lExecPath := FCGIRoot+lExecPath;
     lExecPath := FCGIRoot+lExecPath;
-    if SeparatePath(lExecPath, lOutput.ExtraPath, faAnyFile and not faDirectory) then
+    if SeparatePath(lExecPath, lOutput.FExtraPath, faAnyFile and not faDirectory) then
     begin
     begin
       lOutput.Process.CommandLine := lExecPath;
       lOutput.Process.CommandLine := lExecPath;
-      lOutput.ScriptFileName := lExecPath;
-      lOutput.ScriptName := Copy(lExecPath, Length(FCGIRoot), 
+      lOutput.FScriptFileName := lExecPath;
+      lOutput.FScriptName := Copy(lExecPath, Length(FCGIRoot), 
         Length(lExecPath)-Length(FCGIRoot)+1);
         Length(lExecPath)-Length(FCGIRoot)+1);
       lOutput.StartRequest;
       lOutput.StartRequest;
     end else
     end else
-      ASocket.ResponseInfo.Status := hsNotFound;
+      ASocket.FResponseInfo.Status := hsNotFound;
     Result := lOutput;
     Result := lOutput;
   end else
   end else
     Result := nil;
     Result := nil;
@@ -388,9 +377,9 @@ begin
   Result := nil;
   Result := nil;
   if ARequest.InfoValid then
   if ARequest.InfoValid then
   begin
   begin
-    lReqInfo := @ARequest.Socket.RequestInfo;
-    lRespInfo := @ARequest.Socket.ResponseInfo;
-    lHeaderOut := @ARequest.Socket.HeaderOut;
+    lReqInfo := @ARequest.Socket.FRequestInfo;
+    lRespInfo := @ARequest.Socket.FResponseInfo;
+    lHeaderOut := @ARequest.Socket.FHeaderOut;
     if not (lReqInfo^.RequestType in [hmHead, hmGet]) then
     if not (lReqInfo^.RequestType in [hmHead, hmGet]) then
     begin
     begin
       lRespInfo^.Status := hsNotAllowed;
       lRespInfo^.Status := hsNotAllowed;
@@ -422,10 +411,11 @@ var
 begin
 begin
   Result := nil;
   Result := nil;
   lDocRequest.Socket := ASocket;
   lDocRequest.Socket := ASocket;
-  lDocRequest.URIPath := ASocket.RequestInfo.Argument;
+  lDocRequest.URIPath := ASocket.FRequestInfo.Argument;
   lDocRequest.Document := lDocRequest.URIPath;
   lDocRequest.Document := lDocRequest.URIPath;
   DoDirSeparators(LDocRequest.Document);
   DoDirSeparators(LDocRequest.Document);
-  lDocRequest.Document := IncludeTrailingPathDelimiter(FDocumentRoot)+lDocRequest.Document;
+  lDocRequest.Document := IncludeTrailingPathDelimiter(DocumentRoot)
+    + lDocRequest.Document;
   lDocRequest.InfoValid := SeparatePath(lDocRequest.Document,lDocRequest.ExtraPath, 
   lDocRequest.InfoValid := SeparatePath(lDocRequest.Document,lDocRequest.ExtraPath, 
     faAnyFile, @lDocRequest.Info);
     faAnyFile, @lDocRequest.Info);
   if not lDocRequest.InfoValid then
   if not lDocRequest.InfoValid then
@@ -461,7 +451,7 @@ begin
   begin
   begin
     Result := lHandler.HandleDocument(lDocRequest);
     Result := lHandler.HandleDocument(lDocRequest);
     if Result <> nil then exit;
     if Result <> nil then exit;
-    if ASocket.ResponseInfo.Status <> hsOK then exit;
+    if ASocket.FResponseInfo.Status <> hsOK then exit;
     lHandler := lHandler.FNext;
     lHandler := lHandler.FNext;
   end;
   end;
 
 
@@ -484,12 +474,12 @@ begin
   if ExtractFileExt(ARequest.Document) = '.php' then
   if ExtractFileExt(ARequest.Document) = '.php' then
   begin
   begin
     lOutput := TSimpleCGIOutput.Create(ARequest.Socket);
     lOutput := TSimpleCGIOutput.Create(ARequest.Socket);
-    lOutput.DocumentRoot := FFileHandler.DocumentRoot;
+    lOutput.FDocumentRoot := FFileHandler.DocumentRoot;
     lOutput.Process.CommandLine := FAppName;
     lOutput.Process.CommandLine := FAppName;
-    lOutput.ScriptName := ARequest.URIPath;
-    lOutput.ScriptFileName := ARequest.Document;
-    lOutput.ExtraPath := ARequest.ExtraPath;
-    lOutput.EnvPath := FEnvPath;
+    lOutput.FScriptName := ARequest.URIPath;
+    lOutput.FScriptFileName := ARequest.Document;
+    lOutput.FExtraPath := ARequest.ExtraPath;
+    lOutput.FEnvPath := FEnvPath;
     lOutput.StartRequest;
     lOutput.StartRequest;
     Result := lOutput;
     Result := lOutput;
   end else
   end else
@@ -564,17 +554,17 @@ begin
     if fcgiRequest <> nil then
     if fcgiRequest <> nil then
     begin
     begin
       lOutput := TFastCGIOutput.Create(ARequest.Socket);
       lOutput := TFastCGIOutput.Create(ARequest.Socket);
-      lOutput.DocumentRoot := FFileHandler.DocumentRoot;
-      lOutput.ScriptName := ARequest.URIPath;
-      lOutput.ScriptFileName := ARequest.Document;
-      lOutput.ExtraPath := ARequest.ExtraPath;
-      lOutput.EnvPath := FEnvPath;
+      lOutput.FDocumentRoot := FFileHandler.DocumentRoot;
+      lOutput.FScriptName := ARequest.URIPath;
+      lOutput.FScriptFileName := ARequest.Document;
+      lOutput.FExtraPath := ARequest.ExtraPath;
+      lOutput.FEnvPath := FEnvPath;
       lOutput.Request := fcgiRequest;
       lOutput.Request := fcgiRequest;
       ARequest.Socket.SetupEncoding(lOutput);
       ARequest.Socket.SetupEncoding(lOutput);
       lOutput.StartRequest;
       lOutput.StartRequest;
       Result := lOutput;
       Result := lOutput;
     end else begin
     end else begin
-      ARequest.Socket.ResponseInfo.Status := hsInternalError;
+      ARequest.Socket.FResponseInfo.Status := hsInternalError;
       ARequest.Socket.StartResponse(nil);
       ARequest.Socket.StartResponse(nil);
       Result := nil;
       Result := nil;
     end;
     end;
@@ -666,21 +656,21 @@ begin
     AddEnvironment('SERVER_SOFTWARE', tempStr);
     AddEnvironment('SERVER_SOFTWARE', tempStr);
 
 
   AddEnvironment('GATEWAY_INTERFACE', 'CGI/1.1'); 
   AddEnvironment('GATEWAY_INTERFACE', 'CGI/1.1'); 
-  AddEnvironment('SERVER_PROTOCOL', lServerSocket.RequestInfo.VersionStr);
-  AddEnvironment('REQUEST_METHOD', lServerSocket.RequestInfo.Method);
-  AddEnvironment('REQUEST_URI', '/'+lServerSocket.RequestInfo.Argument);
+  AddEnvironment('SERVER_PROTOCOL', lServerSocket.FRequestInfo.VersionStr);
+  AddEnvironment('REQUEST_METHOD', lServerSocket.FRequestInfo.Method);
+  AddEnvironment('REQUEST_URI', '/'+lServerSocket.FRequestInfo.Argument);
 
 
   if Length(FExtraPath) > 0 then
   if Length(FExtraPath) > 0 then
   begin
   begin
     AddEnvironment('PATH_INFO', FExtraPath);
     AddEnvironment('PATH_INFO', FExtraPath);
     { do not set PATH_TRANSLATED: bug in PHP }
     { do not set PATH_TRANSLATED: bug in PHP }
-//    AddEnvironment('PATH_TRANSLATED', FDocumentRoot+FExtraPath);
+//    AddEnvironment('PATH_TRANSLATED', DocumentRoot+FExtraPath);
   end;
   end;
 
 
   AddEnvironment('SCRIPT_NAME', FScriptName);
   AddEnvironment('SCRIPT_NAME', FScriptName);
   AddEnvironment('SCRIPT_FILENAME', FScriptFileName);
   AddEnvironment('SCRIPT_FILENAME', FScriptFileName);
   
   
-  AddEnvironment('QUERY_STRING', lServerSocket.RequestInfo.QueryParams);
+  AddEnvironment('QUERY_STRING', lServerSocket.FRequestInfo.QueryParams);
   AddHTTPParam('CONTENT_TYPE', hpContentType);
   AddHTTPParam('CONTENT_TYPE', hpContentType);
   AddHTTPParam('CONTENT_LENGTH', hpContentLength);
   AddHTTPParam('CONTENT_LENGTH', hpContentLength);
 
 
@@ -716,7 +706,8 @@ var
 
 
   procedure AddExtraHeader;
   procedure AddExtraHeader;
   begin
   begin
-    AppendString(lServerSocket.HeaderOut.ExtraHeaders, FParsePos + ': ' + pValue + #13#10);
+    AppendString(lServerSocket.FHeaderOut.ExtraHeaders, 
+      FParsePos + ': ' + pValue + #13#10);
   end;
   end;
 
 
 begin
 begin
@@ -745,13 +736,13 @@ begin
     pValue := FParsePos+iEnd+2;
     pValue := FParsePos+iEnd+2;
     if StrIComp(FParsePos, 'Content-type') = 0 then
     if StrIComp(FParsePos, 'Content-type') = 0 then
     begin
     begin
-      lServerSocket.ResponseInfo.ContentType := pValue;
+      lServerSocket.FResponseInfo.ContentType := pValue;
     end else 
     end else 
     if StrIComp(FParsePos, 'Location') = 0 then
     if StrIComp(FParsePos, 'Location') = 0 then
     begin
     begin
       if StrLIComp(pValue, 'http://', 7) = 0 then
       if StrLIComp(pValue, 'http://', 7) = 0 then
       begin
       begin
-        lServerSocket.ResponseInfo.Status := hsMovedPermanently;
+        lServerSocket.FResponseInfo.Status := hsMovedPermanently;
         { add location header as-is to response }
         { add location header as-is to response }
         AddExtraHeader;
         AddExtraHeader;
       end else
       end else
@@ -768,19 +759,19 @@ begin
         break;
         break;
       for lHttpStatus := Low(TLHTTPStatus) to High(TLHTTPStatus) do
       for lHttpStatus := Low(TLHTTPStatus) to High(TLHTTPStatus) do
         if HTTPStatusCodes[lHttpStatus] = lStatus then
         if HTTPStatusCodes[lHttpStatus] = lStatus then
-          lServerSocket.ResponseInfo.Status := lHttpStatus;
+          lServerSocket.FResponseInfo.Status := lHttpStatus;
     end else
     end else
     if StrIComp(FParsePos, 'Content-Length') = 0 then
     if StrIComp(FParsePos, 'Content-Length') = 0 then
     begin
     begin
       Val(pValue, lLength, lCode);
       Val(pValue, lLength, lCode);
       if lCode <> 0 then
       if lCode <> 0 then
         break;
         break;
-      lServerSocket.HeaderOut.ContentLength := lLength;
+      lServerSocket.FHeaderOut.ContentLength := lLength;
     end else
     end else
     if StrIComp(FParsePos, 'Last-Modified') = 0 then
     if StrIComp(FParsePos, 'Last-Modified') = 0 then
     begin
     begin
       if not TryHTTPDateStrToDateTime(pValue, 
       if not TryHTTPDateStrToDateTime(pValue, 
-          lServerSocket.ResponseInfo.LastModified) then
+          lServerSocket.FResponseInfo.LastModified) then
         InternalWrite('WARNING: unable to parse last-modified string from CGI script: ' + pValue);
         InternalWrite('WARNING: unable to parse last-modified string from CGI script: ' + pValue);
     end else
     end else
       AddExtraHeader;
       AddExtraHeader;
@@ -788,7 +779,7 @@ begin
   until false;
   until false;
 
 
   { error happened }
   { error happened }
-  lServerSocket.ResponseInfo.Status := hsInternalError;
+  lServerSocket.FResponseInfo.Status := hsInternalError;
   exit(true);
   exit(true);
 end;
 end;
 
 
@@ -886,9 +877,9 @@ var
   ServerSocket: TLHTTPServerSocket absolute FSocket;
   ServerSocket: TLHTTPServerSocket absolute FSocket;
 begin
 begin
   if FProcess.ExitStatus = 127 then
   if FProcess.ExitStatus = 127 then
-    ServerSocket.ResponseInfo.Status := hsNotFound
+    ServerSocket.FResponseInfo.Status := hsNotFound
   else
   else
-    ServerSocket.ResponseInfo.Status := hsInternalError;
+    ServerSocket.FResponseInfo.Status := hsInternalError;
 end;
 end;
 
 
 procedure TSimpleCGIOutput.CGIProcNeedInput(AHandle: TLHandle);
 procedure TSimpleCGIOutput.CGIProcNeedInput(AHandle: TLHandle);
@@ -939,7 +930,7 @@ end;
 
 
 procedure TFastCGIOutput.CGIOutputError;
 procedure TFastCGIOutput.CGIOutputError;
 begin
 begin
-  TLHTTPServerSocket(FSocket).ResponseInfo.Status := hsInternalError;
+  TLHTTPServerSocket(FSocket).FResponseInfo.Status := hsInternalError;
 end;
 end;
 
 
 procedure TFastCGIOutput.DoneInput;
 procedure TFastCGIOutput.DoneInput;
@@ -1201,7 +1192,7 @@ procedure TFormOutput.SetCookie(const AName, AValue: string; const AExpires: TDa
 var
 var
   headers: PStringBuffer;
   headers: PStringBuffer;
 begin
 begin
-  headers := @TLHTTPServerSocket(FSocket).HeaderOut.ExtraHeaders;
+  headers := @TLHTTPServerSocket(FSocket).FHeaderOut.ExtraHeaders;
   AppendString(headers^, 'Set-Cookie: ' + HTTPEncode(AName) + '=' + HTTPEncode(AValue));
   AppendString(headers^, 'Set-Cookie: ' + HTTPEncode(AName) + '=' + HTTPEncode(AValue));
   AppendString(headers^, ';path=' + APath + ';expires=' + FormatDateTime(HTTPDateFormat, AExpires));
   AppendString(headers^, ';path=' + APath + ';expires=' + FormatDateTime(HTTPDateFormat, AExpires));
   if Length(ADomain) > 0 then
   if Length(ADomain) > 0 then
@@ -1247,7 +1238,7 @@ begin
   if newFormOutput = nil then
   if newFormOutput = nil then
     exit(nil);
     exit(nil);
 
 
-  newFormOutput.AddVariables(ASocket.RequestInfo.QueryParams, -1, URIParamSepChar);
+  newFormOutput.AddVariables(ASocket.FRequestInfo.QueryParams, -1, URIParamSepChar);
   newFormOutput.AddVariables(ASocket.Parameters[hpCookie], -1, CookieSepChar);
   newFormOutput.AddVariables(ASocket.Parameters[hpCookie], -1, CookieSepChar);
   contentType := TLHTTPServerSocket(ASocket).Parameters[hpContentType];
   contentType := TLHTTPServerSocket(ASocket).Parameters[hpContentType];
   if StrIComp(contentType, FormURLContentType) = 0 then
   if StrIComp(contentType, FormURLContentType) = 0 then

+ 24 - 36
utils/fppkg/pkgarchive.pp

@@ -38,33 +38,6 @@ uses
   pkgglobals,
   pkgglobals,
   pkgmessages;
   pkgmessages;
 
 
-Procedure DeleteDir(const ADir:string);
-const
-{$ifdef unix}
-  AllFiles='*';
-{$else}
-  AllFiles='*.*';
-{$endif}
-var
-  Info : TSearchRec;
-begin
-  if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
-    try
-      repeat
-        if (Info.Attr and faDirectory)=faDirectory then
-          begin
-            if (Info.Name<>'.') and (Info.Name<>'..') then
-              DeleteDir(ADir+PathDelim+Info.Name)
-          end
-        else
-          DeleteFile(ADir+PathDelim+Info.Name);
-      until FindNext(Info)<>0;
-    finally
-      FindClose(Info);
-    end;
-end;
-
-
 { TUnzipArchive }
 { TUnzipArchive }
 
 
 Procedure TUnzipArchive.UnzipArchive;
 Procedure TUnzipArchive.UnzipArchive;
@@ -109,15 +82,14 @@ var
   P : TFPPackage;
   P : TFPPackage;
   PS : TFPPackages;
   PS : TFPPackages;
   X : TFPXMLRepositoryHandler;
   X : TFPXMLRepositoryHandler;
-  i : integer;
+  SL : TStringList;
 begin
 begin
   if assigned(CurrentPackage) then
   if assigned(CurrentPackage) then
     Error(SErrOnlyLocalDir);
     Error(SErrOnlyLocalDir);
   { Generate manifest.xml if it doesn't exists yet }
   { Generate manifest.xml if it doesn't exists yet }
   if not FileExists(PackageManifestFile) then
   if not FileExists(PackageManifestFile) then
     ExecuteAction(CurrentPackage,'fpmakemanifest');
     ExecuteAction(CurrentPackage,'fpmakemanifest');
-
-
+  { Load manifest.xml }
   PS:=TFPPackages.Create(TFPPackage);
   PS:=TFPPackages.Create(TFPPackage);
   X:=TFPXMLRepositoryHandler.Create;
   X:=TFPXMLRepositoryHandler.Create;
   With X do
   With X do
@@ -126,13 +98,29 @@ begin
     finally
     finally
       Free;
       Free;
     end;
     end;
-
-  for i:=0 to PS.Count-1 do
-    begin
-      P:=PS[i];
-      Writeln(P.Name);
-      Writeln(P.FileName);
+  { Create archive, currently support only 1 file per package, this
+    can be enhanced in the future if needed }
+  if PS.Count<>1 then
+    Error('Only one package supported per manifest');
+  P:=PS[0];
+  { Unzip Archive }
+  With TZipper.Create do
+    try
+      Log(vCommands,SLogZippping,[P.FileName]);
+{$warning TODO replace with files from manifest}
+      try
+        SL:=TStringList.Create;
+        SearchFiles(SL,AllFiles);
+        if SL.Count=0 then
+          Error('No files found');
+        ZipFiles(P.FileName,SL);
+      finally
+        SL.Free;
+      end;
+    Finally
+      Free;
     end;
     end;
+  P.Free;
 end;
 end;
 
 
 
 

+ 33 - 1
utils/fppkg/pkgcommands.pp

@@ -15,6 +15,20 @@ type
     Function Execute(const Args:TActionArgs):boolean;override;
     Function Execute(const Args:TActionArgs):boolean;override;
   end;
   end;
 
 
+  { TCommandAvail }
+
+  TCommandAvail = Class(TPackagehandler)
+  Public
+    Function Execute(const Args:TActionArgs):boolean;override;
+  end;
+
+  { TCommandScanPackages }
+
+  TCommandScanPackages = Class(TPackagehandler)
+  Public
+    Function Execute(const Args:TActionArgs):boolean;override;
+  end;
+
   { TCommandDownload }
   { TCommandDownload }
 
 
   TCommandDownload = Class(TPackagehandler)
   TCommandDownload = Class(TPackagehandler)
@@ -51,11 +65,27 @@ uses
   pkgmessages,
   pkgmessages,
   pkgglobals,
   pkgglobals,
   pkgoptions,
   pkgoptions,
-  pkgdownload;
+  pkgdownload,
+  pkgrepos;
 
 
 function TCommandUpdate.Execute(const Args:TActionArgs):boolean;
 function TCommandUpdate.Execute(const Args:TActionArgs):boolean;
 begin
 begin
   DownloadFile(Defaults.RemotePackagesFile,Defaults.LocalPackagesFile);
   DownloadFile(Defaults.RemotePackagesFile,Defaults.LocalPackagesFile);
+  LoadLocalRepository;
+end;
+
+
+function TCommandAvail.Execute(const Args:TActionArgs):boolean;
+begin
+  ListRepository;
+end;
+
+
+function TCommandScanPackages.Execute(const Args:TActionArgs):boolean;
+begin
+  RebuildRepository;
+  ListRepository;
+  SaveRepository;
 end;
 end;
 
 
 
 
@@ -96,6 +126,8 @@ end;
 
 
 initialization
 initialization
   RegisterPkgHandler('update',TCommandUpdate);
   RegisterPkgHandler('update',TCommandUpdate);
+  RegisterPkgHandler('avail',TCommandAvail);
+  RegisterPkgHandler('scan',TCommandScanPackages);
   RegisterPkgHandler('download',TCommandDownload);
   RegisterPkgHandler('download',TCommandDownload);
   RegisterPkgHandler('unzip',TCommandUnzip);
   RegisterPkgHandler('unzip',TCommandUnzip);
   RegisterPkgHandler('build',TCommandBuild);
   RegisterPkgHandler('build',TCommandBuild);

+ 0 - 3
utils/fppkg/pkgfpmake.pp

@@ -97,8 +97,6 @@ begin
       { Call compiler }
       { Call compiler }
       C:=Defaults.FPMakeCompiler;
       C:=Defaults.FPMakeCompiler;
       O:='-vi -n -Fu'+Defaults.FPMakeUnitDir+' -Fu'+RTLDir;
       O:='-vi -n -Fu'+Defaults.FPMakeUnitDir+' -Fu'+RTLDir;
-//      if FPPkgDir<>'' then
-//        O:=O+' -Fu'+FPPkgDir+' -Fafpmkpkg';
       O:=O+' '+FPmakeSrc;
       O:=O+' '+FPmakeSrc;
       If ExecuteProcess(C,O)<>0 then
       If ExecuteProcess(C,O)<>0 then
         Error(SErrFailedToCompileFPCMake)
         Error(SErrFailedToCompileFPCMake)
@@ -120,7 +118,6 @@ end;
 
 
 Function TFPMakeRunner.RunFPMake(const Command:string) : Integer;
 Function TFPMakeRunner.RunFPMake(const Command:string) : Integer;
 Var
 Var
-  I : integer;
   FPMakeBin : string;
   FPMakeBin : string;
 begin
 begin
   { Maybe compile fpmake executable? }
   { Maybe compile fpmake executable? }

+ 76 - 4
utils/fppkg/pkgglobals.pp

@@ -11,16 +11,18 @@ uses
 Const
 Const
 {$ifdef unix}
 {$ifdef unix}
   ExeExt = '';
   ExeExt = '';
+  AllFiles='*';
 {$else unix}
 {$else unix}
   ExeExt = '.exe';
   ExeExt = '.exe';
+  AllFiles='*.*';
 {$endif unix}
 {$endif unix}
 
 
 Type
 Type
-  TVerbosity = (vError,vInfo,vCommands,vDebug);
+  TVerbosity = (vError,vWarning,vInfo,vCommands,vDebug);
   TVerbosities = Set of TVerbosity;
   TVerbosities = Set of TVerbosity;
 
 
   EPackagerError = class(Exception);
   EPackagerError = class(Exception);
-  
+
 // Logging
 // Logging
 Function StringToVerbosity (S : String) : TVerbosity;
 Function StringToVerbosity (S : String) : TVerbosity;
 Function VerbosityToString (V : TVerbosity): String;
 Function VerbosityToString (V : TVerbosity): String;
@@ -32,6 +34,9 @@ Procedure Error(Fmt : String; const Args : array of const);
 // Utils
 // Utils
 function maybequoted(const s:string):string;
 function maybequoted(const s:string):string;
 Function FixPath(const S : String) : string;
 Function FixPath(const S : String) : string;
+Procedure DeleteDir(const ADir:string);
+Procedure SearchFiles(SL:TStringList;const APattern:string);
+Function GetCompilerInfo(const ACompiler,AOptions:string):string;
 
 
 var
 var
   Verbosity : TVerbosities;
   Verbosity : TVerbosities;
@@ -41,6 +46,7 @@ Implementation
 
 
 uses
 uses
   typinfo,
   typinfo,
+  process,
   contnrs,
   contnrs,
   uriparser,
   uriparser,
   pkgmessages;
   pkgmessages;
@@ -64,9 +70,15 @@ end;
 
 
 
 
 procedure Log(Level:TVerbosity;Msg: String);
 procedure Log(Level:TVerbosity;Msg: String);
+var
+  Prefix : string;
 begin
 begin
-  if Level in Verbosity then
-    Writeln(stdErr,Msg);
+  if not(Level in Verbosity) then
+    exit;
+  Prefix:='';
+  if Level=vWarning then
+    Prefix:=SWarning;
+  Writeln(stdErr,Prefix,Msg);
 end;
 end;
 
 
 
 
@@ -141,5 +153,65 @@ begin
 end;
 end;
 
 
 
 
+Procedure DeleteDir(const ADir:string);
+var
+  Info : TSearchRec;
+begin
+  if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
+    try
+      repeat
+        if (Info.Attr and faDirectory)=faDirectory then
+          begin
+            if (Info.Name<>'.') and (Info.Name<>'..') then
+              DeleteDir(ADir+PathDelim+Info.Name)
+          end
+        else
+          DeleteFile(ADir+PathDelim+Info.Name);
+      until FindNext(Info)<>0;
+    finally
+      FindClose(Info);
+    end;
+end;
+
+
+Procedure SearchFiles(SL:TStringList;const APattern:string);
+var
+  Info : TSearchRec;
+  ADir : string;
+begin
+  ADir:=ExtractFilePath(APattern);
+  if FindFirst(APattern,faAnyFile, Info)=0 then
+    try
+      repeat
+        if (Info.Attr and faDirectory)=faDirectory then
+          begin
+            if (Info.Name<>'.') and (Info.Name<>'..') then
+              SearchFiles(SL,ADir+Info.Name+PathDelim+ExtractFileName(APattern))
+          end;
+        SL.Add(ADir+Info.Name);
+      until FindNext(Info)<>0;
+    finally
+      FindClose(Info);
+    end;
+end;
+
+
+Function GetCompilerInfo(const ACompiler,AOptions:string):string;
+Const
+  BUFSIZE=1024;
+Var
+  S : TProcess;
+  Buf : Array[0..BUFSIZE-1] of char;
+  Count : longint;
+begin
+  S:=TProcess.Create(Nil);
+  S.Commandline:=ACOmpiler+' '+AOptions;
+  S.Options:=[poUsePipes,poNoConsole];
+  S.execute;
+  Count:=s.output.read(buf,BufSize);
+  SetLength(Result,Count);
+  Move(Buf,Result[1],Count);
+  S.Free;
+end;
 
 
 end.
 end.

+ 1 - 1
utils/fppkg/pkghandler.pp

@@ -173,7 +173,7 @@ end;
 
 
 function TPackageHandler.PackageManifestFile: String;
 function TPackageHandler.PackageManifestFile: String;
 begin
 begin
-  Result:='manifest.xml';
+  Result:=DefaultManifestFile;
 end;
 end;
 
 
 
 

+ 8 - 0
utils/fppkg/pkgmessages.pp

@@ -6,9 +6,12 @@ interface
 
 
 
 
 Resourcestring
 Resourcestring
+  SWarning                   = 'Warning: ';
+
   SErrInValidArgument        = 'Invalid command-line argument at position %d : %s';
   SErrInValidArgument        = 'Invalid command-line argument at position %d : %s';
   SErrNeedArgument           = 'Option at position %d (%s) needs an argument';
   SErrNeedArgument           = 'Option at position %d (%s) needs an argument';
   SErrMissingFPC             = 'Could not find a fpc executable in the PATH';
   SErrMissingFPC             = 'Could not find a fpc executable in the PATH';
+  SErrInvalidFPCInfo         = 'Compiler returns invalid information, check if fpc -iV works';
   SErrMissingFPMake          = 'Missing configuration fpmake.pp';
   SErrMissingFPMake          = 'Missing configuration fpmake.pp';
   SErrMissingMakefilefpc     = 'Missing configuration Makefile.fpc';
   SErrMissingMakefilefpc     = 'Missing configuration Makefile.fpc';
   SErrMissingDirectory       = 'Missing directory "%s"';
   SErrMissingDirectory       = 'Missing directory "%s"';
@@ -34,6 +37,8 @@ Resourcestring
   SErrCWDFailed              = 'FTP CWD "%s" command failed.';
   SErrCWDFailed              = 'FTP CWD "%s" command failed.';
   SErrGETFailed              = 'FTP GET "%s" command failed.';
   SErrGETFailed              = 'FTP GET "%s" command failed.';
 
 
+  SWarnFPMKUnitNotFound      = 'Unit directory of fpmkunit is not found, compiling fpmake may file';
+
   SLogGeneratingFPMake       = 'Generating fpmake.pp';
   SLogGeneratingFPMake       = 'Generating fpmake.pp';
   SLogNotCompilingFPMake     = 'Skipping compiling of fpmake.pp, fpmake executable already exists';
   SLogNotCompilingFPMake     = 'Skipping compiling of fpmake.pp, fpmake executable already exists';
   SLogCommandLineAction      = 'Adding action from commandline: "%s %s"';
   SLogCommandLineAction      = 'Adding action from commandline: "%s %s"';
@@ -42,9 +47,12 @@ Resourcestring
   SLogChangeDir              = 'CurrentDir: "%s"';
   SLogChangeDir              = 'CurrentDir: "%s"';
   SLogDownloading            = 'Downloading "%s" to "%s"';
   SLogDownloading            = 'Downloading "%s" to "%s"';
   SLogUnzippping             = 'Unzipping "%s"';
   SLogUnzippping             = 'Unzipping "%s"';
+  SLogZippping               = 'Zipping "%s"';
   SLogLoadingGlobalConfig    = 'Loading global configuration from "%s"';
   SLogLoadingGlobalConfig    = 'Loading global configuration from "%s"';
   SLogLoadingCompilerConfig  = 'Loading compiler configuration from "%s"';
   SLogLoadingCompilerConfig  = 'Loading compiler configuration from "%s"';
   SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"';
   SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"';
+  SLogDetectedCompiler       = 'Detected compiler "%s" (version %s for %s)';
+  SLogDetectedFPCDIR         = 'Detected FPCDIR "%s" will be used installation';
   SLogGeneratingCompilerConfig  = 'Generating default compiler configuration in "%s"';
   SLogGeneratingCompilerConfig  = 'Generating default compiler configuration in "%s"';
   SLogLoadingPackagesFile    = 'Loading packages information from "%s"';
   SLogLoadingPackagesFile    = 'Loading packages information from "%s"';
   SLogLoadingVersionsFile    = 'Loading local versions information from "%s"';
   SLogLoadingVersionsFile    = 'Loading local versions information from "%s"';

+ 2 - 2
utils/fppkg/pkgmkconv.pp

@@ -77,7 +77,7 @@ end;
 Function IsCPU (S: String) : Boolean;
 Function IsCPU (S: String) : Boolean;
 
 
 begin
 begin
-  Result:=Pos(lowercase(S)+',','i386,powerpc,arm,alpha,sparc,')<>0
+  Result:=Pos(lowercase(S)+',','i386,powerpc,arm,alpha,sparc,x86_64,powerpc64,')<>0
 end;
 end;
 
 
 Function GetOSCPU(L : String; var OS,CPU : String) : String;
 Function GetOSCPU(L : String; var OS,CPU : String) : String;
@@ -123,7 +123,7 @@ begin
     Add('');
     Add('');
     Add(' { Generated automatically by '+ExtractFileName(Paramstr(0))+' on '+DateToStr(Sysutils.Date)+' }');
     Add(' { Generated automatically by '+ExtractFileName(Paramstr(0))+' on '+DateToStr(Sysutils.Date)+' }');
     Add('');
     Add('');
-    Add('uses fpmktype,fpmkunit;');
+    Add('uses fpmkunit;');
     Add('');
     Add('');
     Add('Var');
     Add('Var');
     Add('  T : TTarget;');
     Add('  T : TTarget;');

+ 27 - 8
utils/fppkg/pkgoptions.pp

@@ -16,7 +16,10 @@ unit pkgoptions;
 
 
 interface
 interface
 
 
-uses Classes, Sysutils, Inifiles, fpmktype;
+uses Classes, Sysutils, Inifiles, fprepos;
+
+Const
+  DefaultManifestFile      = 'manifest.xml';
 
 
 Type
 Type
 
 
@@ -34,6 +37,7 @@ Type
     FPackagesDir,
     FPackagesDir,
     FBuildDir : String;
     FBuildDir : String;
     FDefaultVerbosity,
     FDefaultVerbosity,
+    FCurrentCompilerConfig,
     FDefaultCompilerConfig : String;
     FDefaultCompilerConfig : String;
     // Compiler specific options
     // Compiler specific options
     FCompiler : String;
     FCompiler : String;
@@ -80,13 +84,14 @@ Type
     Property CompilerConfigDir : String Index 13 Read GetOptString Write SetOptString;
     Property CompilerConfigDir : String Index 13 Read GetOptString Write SetOptString;
     Property FPMakeCompiler : String Index 14 Read GetOptString Write SetOptString;
     Property FPMakeCompiler : String Index 14 Read GetOptString Write SetOptString;
     Property FPMakeUnitDir : String Index 15 Read GetOptString Write SetOptString;
     Property FPMakeUnitDir : String Index 15 Read GetOptString Write SetOptString;
+    Property CurrentCompilerConfig : String Index 16 Read GetOptString Write SetOptString;
     Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
     Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
     Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
     Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
   end;
   end;
 
 
 var
 var
   Defaults : TPackagerOptions;
   Defaults : TPackagerOptions;
-    
+
 Implementation
 Implementation
 
 
 uses
 uses
@@ -157,6 +162,7 @@ begin
    13 : Result:=FCompilerConfigDir;
    13 : Result:=FCompilerConfigDir;
    14 : Result:=FFPMakeCompiler;
    14 : Result:=FFPMakeCompiler;
    15 : Result:=FFPMakeUnitDir;
    15 : Result:=FFPMakeUnitDir;
+   16 : Result:=FCurrentCompilerConfig;
   end;
   end;
 end;
 end;
 
 
@@ -180,6 +186,7 @@ begin
    13 : FCompilerConfigDir:=FixPath(AValue);
    13 : FCompilerConfigDir:=FixPath(AValue);
    14 : FFPMakeCompiler:=AValue;
    14 : FFPMakeCompiler:=AValue;
    15 : FFPMakeUnitDir:=FixPath(AValue);
    15 : FFPMakeUnitDir:=FixPath(AValue);
+   16 : FCurrentCompilerConfig:=AValue;
   end;
   end;
   FDirty:=True;
   FDirty:=True;
 end;
 end;
@@ -250,19 +257,28 @@ begin
   FRemoteRepository:=DefaultRemoteRepository;
   FRemoteRepository:=DefaultRemoteRepository;
   // Other config
   // Other config
   FDefaultCompilerConfig:='default';
   FDefaultCompilerConfig:='default';
-  FDefaultVerbosity:='error,info,debug,commands';
+  FCurrentCompilerConfig:=FDefaultCompilerConfig;
+  FDefaultVerbosity:='error,warning,info,debug,commands';
 end;
 end;
 
 
 
 
 Procedure TPackagerOptions.InitCompilerDefaults;
 Procedure TPackagerOptions.InitCompilerDefaults;
+var
+  infoSL : TStringList;
 begin
 begin
   FCompiler:=FileSearch('fpc'+ExeExt,GetEnvironmentVariable('PATH'));
   FCompiler:=FileSearch('fpc'+ExeExt,GetEnvironmentVariable('PATH'));
   if FCompiler='' then
   if FCompiler='' then
     Raise EPackagerError.Create(SErrMissingFPC);
     Raise EPackagerError.Create(SErrMissingFPC);
-{$warning TODO detect compiler version/target from -i options }
-  FCompilerVersion:='2.0.4';
-  FCompilerCPU:=StringToCPU({$I %FPCTARGETCPU%});
-  FCompilerOS:=StringToOS({$I %FPCTARGETOS%});
+  // Detect compiler version/target from -i option
+  infosl:=TStringList.Create;
+  infosl.Delimiter:=' ';
+  infosl.DelimitedText:=GetCompilerInfo(FCompiler,'-iVTPTO');
+  if infosl.Count<>3 then
+    Raise EPackagerError.Create(SErrInvalidFPCInfo);
+  FCompilerVersion:=infosl[0];
+  FCompilerCPU:=StringToCPU(infosl[1]);
+  FCompilerOS:=StringToOS(infosl[2]);
+  Log(vDebug,SLogDetectedCompiler,[FCompiler,FCompilerVersion,MakeTargetString(FCompilerCPU,FCompilerOS)]);
   // Use the same algorithm as the compiler, see options.pas
   // Use the same algorithm as the compiler, see options.pas
 {$ifdef Unix}
 {$ifdef Unix}
   FInstallDir:=FixPath(GetEnvironmentVariable('FPCDIR'));
   FInstallDir:=FixPath(GetEnvironmentVariable('FPCDIR'));
@@ -283,9 +299,12 @@ begin
         FInstallDir:=FInstallDir+'../';
         FInstallDir:=FInstallDir+'../';
     end;
     end;
 {$endif unix}
 {$endif unix}
+  Log(vDebug,SLogDetectedFPCDIR,[FInstallDir]);
   // Detect directory where fpmake units are located
   // Detect directory where fpmake units are located
   FFPMakeCompiler:=FCompiler;
   FFPMakeCompiler:=FCompiler;
-  FFPMakeUnitDir:=FInstallDir+'units'+PathDelim+CompilerTarget+PathDelim+'fpmake'+PathDelim;
+  FFPMakeUnitDir:=FInstallDir+'units'+PathDelim+CompilerTarget+PathDelim+'fpmkunit'+PathDelim;
+  if not DirectoryExists(FFPMakeUnitDir) then
+    Log(vWarning,SWarnFPMKUnitNotFound);
 end;
 end;
 
 
 
 

+ 140 - 0
utils/fppkg/pkgrepos.pp

@@ -0,0 +1,140 @@
+unit pkgrepos;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes,SysUtils,
+  fprepos;
+
+procedure LoadLocalRepository;
+procedure SaveRepository;
+procedure ListRepository;
+procedure RebuildRepository;
+
+var
+  CurrentRepository : TFPRepository;
+
+
+implementation
+
+uses
+  zipper,
+  fpxmlrep,
+  pkgglobals,
+  pkgoptions,
+  pkgmessages;
+
+
+procedure LoadLocalRepository;
+var
+  S : String;
+  X : TFPXMLRepositoryHandler;
+begin
+  if assigned(CurrentRepository) then
+    CurrentRepository.Free;
+  CurrentRepository:=TFPRepository.Create(Nil);
+  // Repository
+  Log(vDebug,SLogLoadingPackagesFile,[Defaults.LocalPackagesFile]);
+  if FileExists(Defaults.LocalPackagesFile) then
+    begin
+      X:=TFPXMLRepositoryHandler.Create;
+      With X do
+        try
+          LoadFromXml(CurrentRepository,Defaults.LocalPackagesFile);
+        finally
+          Free;
+        end;
+    end;
+  // Versions
+  S:=Defaults.LocalVersionsFile(Defaults.CurrentCompilerConfig);
+  Log(vDebug,SLogLoadingVersionsFile,[S]);
+  if FileExists(S) then
+    CurrentRepository.LoadStatusFromFile(S);
+end;
+
+
+procedure SaveRepository;
+var
+  X : TFPXMLRepositoryHandler;
+begin
+  // Repository
+  Writeln('Saving repository in packages.xml');
+  X:=TFPXMLRepositoryHandler.Create;
+  With X do
+    try
+      SaveToXml(CurrentRepository,'packages.xml');
+    finally
+      Free;
+    end;
+end;
+
+
+procedure ListRepository;
+var
+  P : TFPPackage;
+  i : integer;
+begin
+  for i:=0 to CurrentRepository.PackageCount-1 do
+    begin
+      P:=CurrentRepository.Packages[i];
+      Writeln(Format('%-20s %-20s',[P.Name,P.FileName]));
+    end;
+end;
+
+
+procedure RebuildRepository;
+var
+  X : TFPXMLRepositoryHandler;
+  i : integer;
+  ArchiveSL : TStringList;
+  ManifestSL : TStringList;
+begin
+  if assigned(CurrentRepository) then
+    CurrentRepository.Free;
+  CurrentRepository:=TFPRepository.Create(Nil);
+  try
+    ManifestSL:=TStringList.Create;
+    ManifestSL.Add(DefaultManifestFile);
+    { Find all archives }
+    ArchiveSL:=TStringList.Create;
+    SearchFiles(ArchiveSL,'*.zip');
+    if ArchiveSL.Count=0 then
+      Error('No archive files found');
+    { Process all archives }
+    for i:=0 to ArchiveSL.Count-1 do
+      begin
+        Writeln('Processing ',ArchiveSL[i]);
+        { Unzip manifest.xml }
+        With TUnZipper.Create do
+          try
+            Log(vCommands,SLogUnzippping,[ArchiveSL[i]]);
+            OutputPath:='.';
+            UnZipFiles(ArchiveSL[i],ManifestSL);
+          Finally
+            Free;
+          end;
+        { Load manifest.xml }
+        if FileExists(DefaultManifestFile) then
+          begin
+            X:=TFPXMLRepositoryHandler.Create;
+            With X do
+              try
+                LoadFromXml(CurrentRepository.PackageCollection,DefaultManifestFile);
+              finally
+                Free;
+              end;
+            DeleteFile(DefaultManifestFile);
+          end
+        else
+          Writeln('No manifest found in archive ',ArchiveSL[i]);
+      end;
+  finally
+    ArchiveSL.Free;
+    ManifestSL.Free;
+  end;
+end;
+
+initialization
+end.

+ 1 - 1
utils/fppkg/reptest.pp

@@ -17,7 +17,7 @@ unit reptest;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, fprepos, fpmktype;
+  Classes, SysUtils, fprepos;
 
 
 // Num restricted to 1 2 3. 4 will create package with unsatisfied dependency.
 // Num restricted to 1 2 3. 4 will create package with unsatisfied dependency.
 Function CreateTestRep(Num : Integer) : TFPRepository;
 Function CreateTestRep(Num : Integer) : TFPRepository;