* Numerous mini valgrind fixes.

* Addition of hacky architecture check in the _splitname function
* Removal of libfetch from the archlinux proper - it has been renamed to
  libdownload and can be found at http://phraktured.net/libdownload
* Merge of _some_ of the Frugalware makepkg change - this may still be
  incomplete
* Removal of libftp from cvs proper
* PKGBUILD manpage now says 'PKGBUILD' instead of FrugalBuild (he he)
This commit is contained in:
Aaron Griffin 2006-11-14 07:58:42 +00:00
parent 7e835366f1
commit 4470e5ce01
40 changed files with 548 additions and 7137 deletions

View file

@ -1,4 +1,4 @@
SUBDIRS = lib/libfetch lib/libalpm src/util src/pacman scripts doc doc/hu etc
SUBDIRS = lib/libalpm src/util src/pacman scripts doc doc/hu etc
if HAS_PERL
SUBDIRS += bindings/perl
@ -22,5 +22,4 @@ check: src/pacman
tags:
ctags -a lib/libalpm/*.[ch]
ctags -a lib/libftp/*.[ch]
ctags -a src/pacman/*.[ch]

View file

@ -1,14 +1,14 @@
.TH FrugalBuild 8 "June 13, 2006" "Frugalware Developer Manual" ""
.TH PKGBUILD 8 "June 13, 2006" "Archlinux Developer Manual" ""
.SH NAME
FrugalBuild \- Frugalware package builder descriptor
PKGBUILD \- Archlinux package builder descriptor
.SH DESCRIPTION
This manual page is meant to describe general rules about FrugalBuilds. If
This manual page is meant to describe general rules about PKGBUILDs. If
you're interested in the package builder \fBmakepkg\fP itself, then see its
manual page, not this one.
.TP
.TP
.SH FrugalBuild Example:
.SH PKGBUILD Example:
.RS
.nf
# Last Modified: Sun, 19 Jun 2005 15:24:32 +0000
@ -47,13 +47,13 @@ successful builds, and this SBU value will be equal on anyone's machine.
If you wish to maintain the package, write your name or nick and e-mail
address to the third line. If you don't plan to maintain the package just wrote
the FrugalBuild, then write Contributor instead of Maintainer, and then someone
the PKGBUILD, then write Contributor instead of Maintainer, and then someone
can take it and will add his/her line later. Other lines like "Modified by" are
not allowed. Use the darcs patch comments to mention others if you wish.
pkgname defines the package name. It should not contain any uppercase letters.
The package version defines the upstream version, while the package release
tracks the Frugalware-specific changes. pkgrel should be an integer, pkgrels
tracks the Archlinux-specific changes. pkgrel should be an integer, pkgrels
like 5wanda1 are reserved for security updates. There the rule is the
following: If the original package's pkgrel was 4, then increment it once when
you add a security patch, but then use 5wanda1, 5wanda2 and so on. This way
@ -68,9 +68,9 @@ current one. If the dependency is runtime-only, then use rodepends(), if
buildtime-only then use makedepends().
The next line is a special Finclude commands which allows you to inherit
any directive from a FrugalBuild scheme. They can be found in the FST,
any directive from a PKGBUILD scheme. They can be found in the FST,
under /source/include. The "util" scheme always included, since its
provided functions are used by almost every FrugalBuild. Look at the
provided functions are used by almost every PKGBUILD. Look at the
/source/include/sourceforge.sh, it provides the url, up2date and source()
directives, so we don't have to specify them here. After the Finclude you
can overwrite the inherited directives, for example define a custom up2date
@ -93,7 +93,7 @@ is to prevent compiling from wrong sources, especially when the build is
automatic. Where it is available you can use signatures(), its goal is that
you don't have to update it manually every time.
The last line will be added automatically to the end of the FrugalBuild if the
The last line will be added automatically to the end of the PKGBUILD if the
build() function used your $CFLAGS or $CXXFLAGS. This is handy if you want to
cross-compile on a faster machine for a slower architecture. Until the package
doesn't use our $CFLAGS we can't cross-compile it, so please try to avoid
@ -150,7 +150,7 @@ script is run right after files are removed.
.RE
To use this feature, just create a file (eg, pkgname.install) and put it in
the same directory as the FrugalBuild script. Then use the \fIinstall\fP directive:
the same directory as the PKGBUILD script. Then use the \fIinstall\fP directive:
.RS
.nf
install=pkgname.install
@ -176,7 +176,7 @@ post_upgrade()
}
.fi
.SH FrugalBuild Directives
.SH PKGBUILD Directives
.TP
.B pkgname
The name of the package. This has be a unix-friendly name as it will be
@ -188,7 +188,7 @@ This is the version of the software as released from the author (eg, 2.7.1).
.TP
.B pkgrel
This is the release number specific to Frugalware Linux packages.
This is the release number specific to Archlinux Linux packages.
.TP
.B pkgdesc
@ -214,7 +214,7 @@ option is still in development and may change in the future)
.TP
.B install
Specifies a special install script that is to be included in the package.
This file should reside in the same directory as the FrugalBuild, and will be
This file should reside in the same directory as the PKGBUILD, and will be
copied into the package by makepkg. It does not need to be included in the
\fIsource\fP array. (eg, install=modutils.install)
@ -227,7 +227,7 @@ manually the project's website (see above).
.TP
.B source \fI(array)\fP
The \fIsource\fP line is an array of source files required to build the
package. Source files must reside in the same directory as the FrugalBuild
package. Source files must reside in the same directory as the PKGBUILD
file, unless they have a fully-qualified URL. Then if the source file
does not already exist in /var/cache/pacman/src, the file is downloaded
by wget.
@ -237,8 +237,8 @@ by wget.
If this field is present, it should contain an MD5 hash for every source file
specified in the \fIsource\fP array (in the same order). makepkg will use
this to verify source file integrity during subsequent builds. To easily
generate md5sums, first build using the FrugalBuild then run
\fBmakepkg -G >>FrugalBuild\fP. Then you can edit the FrugalBuild and move the
generate md5sums, first build using the PKGBUILD then run
\fBmakepkg -G >>PKGBUILD\fP. Then you can edit the PKGBUILD and move the
\fImd5sums\fP line from the bottom to an appropriate location.
.TP
@ -246,8 +246,8 @@ generate md5sums, first build using the FrugalBuild then run
If this field is present, it should contain an SHA1 hash for every source file
specified in the \fIsource\fP array (in the same order). makepkg will use
this to verify source file integrity during subsequent builds. To easily
generate sha1sums, first build using the FrugalBuild then run
\fBmakepkg -g >>FrugalBuild\fP. Then you can edit the FrugalBuild and move the
generate sha1sums, first build using the PKGBUILD then run
\fBmakepkg -g >>PKGBUILD\fP. Then you can edit the PKGBUILD and move the
\fIsha1sums\fP line from the bottom to an appropriate location.
.TP
@ -285,7 +285,7 @@ in this list should be surrounded with single quotes and contain at least the
package name. They can also include a version requirement of the form
\fBname<>version\fP, where <> is one of these three comparisons: \fB>=\fP
(greater than equal to), \fB<=\fP (less than or equal to), or \fB=\fP (equal to).
See the FrugalBuild example above for an example of the \fIdepends\fP directive.
See the PKGBUILD example above for an example of the \fIdepends\fP directive.
.TP
.B makedepends \fI(array)\fP
@ -365,7 +365,7 @@ devel-core' should show you the actial list. (We try to change this list rarely
of course.)
When you start building with makepkg -R, pacman will install these packages to
/var/chroot if necessary. This will produce a fully "clean" Frugalware system,
/var/chroot if necessary. This will produce a fully "clean" Archlinux system,
that consits of base packages only. This /var/chroot is fully separated from
the host system so that this will solve the problems mentioned above.
(Linking to a library installed from source, etc.)
@ -380,7 +380,7 @@ installed depends() and makedepends(). This ensures us not to build from
scratch the core chroot.
This way we can prevent lots of dependency problems and it is even possible to
build packages for a different Frugalware version. This is quite efficent when
build packages for a different Archlinux version. This is quite efficent when
building security updates or fixing critical bugs in the -stable tree.
If the build is failed, the working directory will not be deleted, you can find
@ -425,7 +425,7 @@ array of arrays, then quotes are the major separators and spaces are the minor o
Simple example:
.nf
Add the followings to your bottom of your FrugalBuild
Add the followings to your bottom of your PKGBUILD
subpkgs=('foo' 'bar')
subdescs=('desc of foo' 'desc of bar')
subdepends=('foodep1 foodep2' 'bardep1 bardep2')

View file

@ -2,7 +2,6 @@ AUTOMAKE_OPTIONS=foreign
mandir = @mandir@/hu
man_MANS = pacman.8 makepkg.8 PKGBUILD.8
$(man_MANS):
EXTRA_DIST = pacman.8 makepkg.8 PKGBUILD.8

View file

@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pacman\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-10-30 8:14-0600\n"
"POT-Creation-Date: 2006-11-14 13:52-0600\n"
"PO-Revision-Date: 2006-08-26 14:53+0200\n"
"Last-Translator: Hungarian <frugalware-devel@frugalware.org>\n"
"Language-Team: Hungarian <frugalware-devel@frugalware.org>\n"
@ -1012,7 +1012,7 @@ msgid ""
msgstr ""
# type: SH
#: makepkg.8:30
#: makepkg.8:30 PKGBUILD.8:11
#, no-wrap
msgid "PKGBUILD Example:"
msgstr ""
@ -1248,7 +1248,7 @@ msgid "script is run right after files are removed."
msgstr ""
# type: Plain text
#: makepkg.8:149
#: makepkg.8:149 PKGBUILD.8:154
msgid ""
"To use this feature, just create a file (eg, pkgname.install) and put it in "
"the same directory as the PKGBUILD script. Then use the I<install> "
@ -1369,7 +1369,7 @@ msgid ""
msgstr ""
# type: SH
#: makepkg.8:220
#: makepkg.8:220 PKGBUILD.8:179
#, no-wrap
msgid "PKGBUILD Directives"
msgstr ""
@ -1522,7 +1522,7 @@ msgid "B<install>"
msgstr ""
# type: Plain text
#: makepkg.8:285
#: makepkg.8:285 PKGBUILD.8:220
msgid ""
"Specifies a special install script that is to be included in the package. "
"This file should reside in the same directory as the PKGBUILD, and will be "
@ -1537,7 +1537,7 @@ msgid "B<source >I<(array)>"
msgstr ""
# type: Plain text
#: makepkg.8:293
#: makepkg.8:293 PKGBUILD.8:234
msgid ""
"The I<source> line is an array of source files required to build the "
"package. Source files must reside in the same directory as the PKGBUILD "
@ -1600,7 +1600,7 @@ msgid "B<depends >I<(array)>"
msgstr ""
# type: Plain text
#: makepkg.8:325
#: makepkg.8:325 PKGBUILD.8:289
msgid ""
"An array of packages that this package depends on to build and run. "
"Packages in this list should be surrounded with single quotes and contain at "
@ -1938,11 +1938,11 @@ msgid ""
"to contribute packages to the Arch Linux project."
msgstr ""
# type: SH
# type: TH
#: PKGBUILD.8:1
#, fuzzy, no-wrap
msgid "FrugalBuild"
msgstr "FrugalBuild példa:"
#, no-wrap
msgid "PKGBUILD"
msgstr ""
# type: TH
#: PKGBUILD.8:1
@ -1952,29 +1952,23 @@ msgstr "2006. j
# type: TH
#: PKGBUILD.8:1
#, no-wrap
msgid "Frugalware Developer Manual"
#, fuzzy, no-wrap
msgid "Archlinux Developer Manual"
msgstr "Frugalware Fejlesztõi Kézikönyv"
# type: Plain text
#: PKGBUILD.8:4
msgid "FrugalBuild - Frugalware package builder descriptor"
msgid "PKGBUILD - Archlinux package builder descriptor"
msgstr ""
# type: Plain text
#: PKGBUILD.8:8
msgid ""
"This manual page is meant to describe general rules about FrugalBuilds. If "
"This manual page is meant to describe general rules about PKGBUILDs. If "
"you're interested in the package builder B<makepkg> itself, then see its "
"manual page, not this one."
msgstr ""
# type: SH
#: PKGBUILD.8:11
#, no-wrap
msgid "FrugalBuild Example:"
msgstr "FrugalBuild példa:"
# type: Plain text
#: PKGBUILD.8:17
#, no-wrap
@ -2047,8 +2041,8 @@ msgstr ""
msgid ""
"If you wish to maintain the package, write your name or nick and e-mail "
"address to the third line. If you don't plan to maintain the package just "
"wrote the FrugalBuild, then write Contributor instead of Maintainer, and "
"then someone can take it and will add his/her line later. Other lines like "
"wrote the PKGBUILD, then write Contributor instead of Maintainer, and then "
"someone can take it and will add his/her line later. Other lines like "
"\"Modified by\" are not allowed. Use the darcs patch comments to mention "
"others if you wish."
msgstr ""
@ -2058,7 +2052,7 @@ msgstr ""
msgid ""
"pkgname defines the package name. It should not contain any uppercase "
"letters. The package version defines the upstream version, while the "
"package release tracks the Frugalware-specific changes. pkgrel should be an "
"package release tracks the Archlinux-specific changes. pkgrel should be an "
"integer, pkgrels like 5wanda1 are reserved for security updates. There the "
"rule is the following: If the original package's pkgrel was 4, then "
"increment it once when you add a security patch, but then use 5wanda1, "
@ -2086,9 +2080,9 @@ msgstr ""
#: PKGBUILD.8:78
msgid ""
"The next line is a special Finclude commands which allows you to inherit any "
"directive from a FrugalBuild scheme. They can be found in the FST, under /"
"directive from a PKGBUILD scheme. They can be found in the FST, under /"
"source/include. The \"util\" scheme always included, since its provided "
"functions are used by almost every FrugalBuild. Look at the /source/include/"
"functions are used by almost every PKGBUILD. Look at the /source/include/"
"sourceforge.sh, it provides the url, up2date and source() directives, so we "
"don't have to specify them here. After the Finclude you can overwrite the "
"inherited directives, for example define a custom up2date if the inherited "
@ -2128,13 +2122,13 @@ msgstr ""
# type: Plain text
#: PKGBUILD.8:103
msgid ""
"The last line will be added automatically to the end of the FrugalBuild if "
"the build() function used your $CFLAGS or $CXXFLAGS. This is handy if you "
"want to cross-compile on a faster machine for a slower architecture. Until "
"the package doesn't use our $CFLAGS we can't cross-compile it, so please try "
"to avoid creating \"unoptimized\" packages. If the package doesn't contain "
"any architecture-dependent file, then you can add this line manually as "
"makepkg will not detect this."
"The last line will be added automatically to the end of the PKGBUILD if the "
"build() function used your $CFLAGS or $CXXFLAGS. This is handy if you want "
"to cross-compile on a faster machine for a slower architecture. Until the "
"package doesn't use our $CFLAGS we can't cross-compile it, so please try to "
"avoid creating \"unoptimized\" packages. If the package doesn't contain any "
"architecture-dependent file, then you can add this line manually as makepkg "
"will not detect this."
msgstr ""
# type: Plain text
@ -2166,14 +2160,6 @@ msgid ""
"something like name-version-release-arch.fpm. Done!"
msgstr ""
# type: Plain text
#: PKGBUILD.8:154
msgid ""
"To use this feature, just create a file (eg, pkgname.install) and put it in "
"the same directory as the FrugalBuild script. Then use the I<install> "
"directive:"
msgstr ""
# type: Plain text
#: PKGBUILD.8:163
msgid ""
@ -2209,15 +2195,9 @@ msgid ""
"}\n"
msgstr ""
# type: SH
#: PKGBUILD.8:179
#, no-wrap
msgid "FrugalBuild Directives"
msgstr ""
# type: Plain text
#: PKGBUILD.8:192
msgid "This is the release number specific to Frugalware Linux packages."
msgid "This is the release number specific to Archlinux Linux packages."
msgstr ""
# type: TP
@ -2244,15 +2224,6 @@ msgid ""
"option is still in development and may change in the future)"
msgstr ""
# type: Plain text
#: PKGBUILD.8:220
msgid ""
"Specifies a special install script that is to be included in the package. "
"This file should reside in the same directory as the FrugalBuild, and will "
"be copied into the package by makepkg. It does not need to be included in "
"the I<source> array. (eg, install=modutils.install)"
msgstr ""
# type: TP
#: PKGBUILD.8:221
#, no-wrap
@ -2267,24 +2238,15 @@ msgid ""
"without visiting manually the project's website (see above)."
msgstr ""
# type: Plain text
#: PKGBUILD.8:234
msgid ""
"The I<source> line is an array of source files required to build the "
"package. Source files must reside in the same directory as the FrugalBuild "
"file, unless they have a fully-qualified URL. Then if the source file does "
"not already exist in /var/cache/pacman/src, the file is downloaded by wget."
msgstr ""
# type: Plain text
#: PKGBUILD.8:243
msgid ""
"If this field is present, it should contain an MD5 hash for every source "
"file specified in the I<source> array (in the same order). makepkg will use "
"this to verify source file integrity during subsequent builds. To easily "
"generate md5sums, first build using the FrugalBuild then run B<makepkg -G "
"E<gt>E<gt>FrugalBuild>. Then you can edit the FrugalBuild and move the "
"I<md5sums> line from the bottom to an appropriate location."
"generate md5sums, first build using the PKGBUILD then run B<makepkg -G "
"E<gt>E<gt>PKGBUILD>. Then you can edit the PKGBUILD and move the I<md5sums> "
"line from the bottom to an appropriate location."
msgstr ""
# type: TP
@ -2299,8 +2261,8 @@ msgid ""
"If this field is present, it should contain an SHA1 hash for every source "
"file specified in the I<source> array (in the same order). makepkg will use "
"this to verify source file integrity during subsequent builds. To easily "
"generate sha1sums, first build using the FrugalBuild then run B<makepkg -g "
"E<gt>E<gt>FrugalBuild>. Then you can edit the FrugalBuild and move the "
"generate sha1sums, first build using the PKGBUILD then run B<makepkg -g "
"E<gt>E<gt>PKGBUILD>. Then you can edit the PKGBUILD and move the "
"I<sha1sums> line from the bottom to an appropriate location."
msgstr ""
@ -2337,18 +2299,6 @@ msgid ""
"generating package databases."
msgstr ""
# type: Plain text
#: PKGBUILD.8:289
msgid ""
"An array of packages that this package depends on to build and run. "
"Packages in this list should be surrounded with single quotes and contain at "
"least the package name. They can also include a version requirement of the "
"form B<nameE<lt>E<gt>version>, where E<lt>E<gt> is one of these three "
"comparisons: B<E<gt>=> (greater than equal to), B<E<lt>=> (less than or "
"equal to), or B<=> (equal to). See the FrugalBuild example above for an "
"example of the I<depends> directive."
msgstr ""
# type: TP
#: PKGBUILD.8:295
#, no-wrap
@ -2445,7 +2395,7 @@ msgstr ""
#: PKGBUILD.8:372
msgid ""
"When you start building with makepkg -R, pacman will install these packages "
"to /var/chroot if necessary. This will produce a fully \"clean\" Frugalware "
"to /var/chroot if necessary. This will produce a fully \"clean\" Archlinux "
"system, that consits of base packages only. This /var/chroot is fully "
"separated from the host system so that this will solve the problems "
"mentioned above. (Linking to a library installed from source, etc.)"
@ -2472,7 +2422,7 @@ msgstr ""
#: PKGBUILD.8:385
msgid ""
"This way we can prevent lots of dependency problems and it is even possible "
"to build packages for a different Frugalware version. This is quite efficent "
"to build packages for a different Archlinux version. This is quite efficent "
"when building security updates or fixing critical bugs in the -stable tree."
msgstr ""
@ -2559,7 +2509,7 @@ msgstr ""
#: PKGBUILD.8:434
#, no-wrap
msgid ""
"Add the followings to your bottom of your FrugalBuild\n"
"Add the followings to your bottom of your PKGBUILD\n"
"subpkgs=('foo' 'bar')\n"
"subdescs=('desc of foo' 'desc of bar')\n"
"subdepends=('foodep1 foodep2' 'bardep1 bardep2')\n"
@ -2616,6 +2566,15 @@ msgid ""
"and the Frugalware developers E<lt>frugalware-devel@frugalware.orgE<gt>\n"
msgstr ""
# type: SH
#, fuzzy
#~ msgid "FrugalBuild"
#~ msgstr "FrugalBuild példa:"
# type: SH
#~ msgid "FrugalBuild Example:"
#~ msgstr "FrugalBuild példa:"
# type: TH
#~ msgid "Frugalware User Manual"
#~ msgstr "Frugalware Felhasználói Kézikönyv"

View file

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2006-10-30 8:14-0600\n"
"POT-Creation-Date: 2006-11-14 13:52-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1013,7 +1013,7 @@ msgid ""
msgstr ""
# type: SH
#: makepkg.8:30
#: makepkg.8:30 PKGBUILD.8:11
#, no-wrap
msgid "PKGBUILD Example:"
msgstr ""
@ -1242,7 +1242,7 @@ msgid "script is run right after files are removed."
msgstr ""
# type: Plain text
#: makepkg.8:149
#: makepkg.8:149 PKGBUILD.8:154
msgid ""
"To use this feature, just create a file (eg, pkgname.install) and put it in "
"the same directory as the PKGBUILD script. Then use the I<install> "
@ -1361,7 +1361,7 @@ msgid "This template is also available in your ABS tree (/var/abs/install.proto)
msgstr ""
# type: SH
#: makepkg.8:220
#: makepkg.8:220 PKGBUILD.8:179
#, no-wrap
msgid "PKGBUILD Directives"
msgstr ""
@ -1513,7 +1513,7 @@ msgid "B<install>"
msgstr ""
# type: Plain text
#: makepkg.8:285
#: makepkg.8:285 PKGBUILD.8:220
msgid ""
"Specifies a special install script that is to be included in the package. "
"This file should reside in the same directory as the PKGBUILD, and will be "
@ -1528,7 +1528,7 @@ msgid "B<source >I<(array)>"
msgstr ""
# type: Plain text
#: makepkg.8:293
#: makepkg.8:293 PKGBUILD.8:234
msgid ""
"The I<source> line is an array of source files required to build the "
"package. Source files must reside in the same directory as the PKGBUILD "
@ -1591,7 +1591,7 @@ msgid "B<depends >I<(array)>"
msgstr ""
# type: Plain text
#: makepkg.8:325
#: makepkg.8:325 PKGBUILD.8:289
msgid ""
"An array of packages that this package depends on to build and run. "
"Packages in this list should be surrounded with single quotes and contain at "
@ -1932,7 +1932,7 @@ msgstr ""
# type: TH
#: PKGBUILD.8:1
#, no-wrap
msgid "FrugalBuild"
msgid "PKGBUILD"
msgstr ""
# type: TH
@ -1944,28 +1944,22 @@ msgstr ""
# type: TH
#: PKGBUILD.8:1
#, no-wrap
msgid "Frugalware Developer Manual"
msgid "Archlinux Developer Manual"
msgstr ""
# type: Plain text
#: PKGBUILD.8:4
msgid "FrugalBuild - Frugalware package builder descriptor"
msgid "PKGBUILD - Archlinux package builder descriptor"
msgstr ""
# type: Plain text
#: PKGBUILD.8:8
msgid ""
"This manual page is meant to describe general rules about FrugalBuilds. If "
"This manual page is meant to describe general rules about PKGBUILDs. If "
"you're interested in the package builder B<makepkg> itself, then see its "
"manual page, not this one."
msgstr ""
# type: SH
#: PKGBUILD.8:11
#, no-wrap
msgid "FrugalBuild Example:"
msgstr ""
# type: Plain text
#: PKGBUILD.8:17
#, no-wrap
@ -2038,8 +2032,8 @@ msgstr ""
msgid ""
"If you wish to maintain the package, write your name or nick and e-mail "
"address to the third line. If you don't plan to maintain the package just "
"wrote the FrugalBuild, then write Contributor instead of Maintainer, and "
"then someone can take it and will add his/her line later. Other lines like "
"wrote the PKGBUILD, then write Contributor instead of Maintainer, and then "
"someone can take it and will add his/her line later. Other lines like "
"\"Modified by\" are not allowed. Use the darcs patch comments to mention "
"others if you wish."
msgstr ""
@ -2049,7 +2043,7 @@ msgstr ""
msgid ""
"pkgname defines the package name. It should not contain any uppercase "
"letters. The package version defines the upstream version, while the "
"package release tracks the Frugalware-specific changes. pkgrel should be an "
"package release tracks the Archlinux-specific changes. pkgrel should be an "
"integer, pkgrels like 5wanda1 are reserved for security updates. There the "
"rule is the following: If the original package's pkgrel was 4, then "
"increment it once when you add a security patch, but then use 5wanda1, "
@ -2077,9 +2071,9 @@ msgstr ""
#: PKGBUILD.8:78
msgid ""
"The next line is a special Finclude commands which allows you to inherit any "
"directive from a FrugalBuild scheme. They can be found in the FST, under "
"directive from a PKGBUILD scheme. They can be found in the FST, under "
"/source/include. The \"util\" scheme always included, since its provided "
"functions are used by almost every FrugalBuild. Look at the "
"functions are used by almost every PKGBUILD. Look at the "
"/source/include/sourceforge.sh, it provides the url, up2date and source() "
"directives, so we don't have to specify them here. After the Finclude you "
"can overwrite the inherited directives, for example define a custom up2date "
@ -2119,13 +2113,13 @@ msgstr ""
# type: Plain text
#: PKGBUILD.8:103
msgid ""
"The last line will be added automatically to the end of the FrugalBuild if "
"the build() function used your $CFLAGS or $CXXFLAGS. This is handy if you "
"want to cross-compile on a faster machine for a slower architecture. Until "
"the package doesn't use our $CFLAGS we can't cross-compile it, so please try "
"to avoid creating \"unoptimized\" packages. If the package doesn't contain "
"any architecture-dependent file, then you can add this line manually as "
"makepkg will not detect this."
"The last line will be added automatically to the end of the PKGBUILD if the "
"build() function used your $CFLAGS or $CXXFLAGS. This is handy if you want "
"to cross-compile on a faster machine for a slower architecture. Until the "
"package doesn't use our $CFLAGS we can't cross-compile it, so please try to "
"avoid creating \"unoptimized\" packages. If the package doesn't contain any "
"architecture-dependent file, then you can add this line manually as makepkg "
"will not detect this."
msgstr ""
# type: Plain text
@ -2157,14 +2151,6 @@ msgid ""
"something like name-version-release-arch.fpm. Done!"
msgstr ""
# type: Plain text
#: PKGBUILD.8:154
msgid ""
"To use this feature, just create a file (eg, pkgname.install) and put it in "
"the same directory as the FrugalBuild script. Then use the I<install> "
"directive:"
msgstr ""
# type: Plain text
#: PKGBUILD.8:163
msgid ""
@ -2199,15 +2185,9 @@ msgid ""
"}\n"
msgstr ""
# type: SH
#: PKGBUILD.8:179
#, no-wrap
msgid "FrugalBuild Directives"
msgstr ""
# type: Plain text
#: PKGBUILD.8:192
msgid "This is the release number specific to Frugalware Linux packages."
msgid "This is the release number specific to Archlinux Linux packages."
msgstr ""
# type: TP
@ -2233,15 +2213,6 @@ msgid ""
"option is still in development and may change in the future)"
msgstr ""
# type: Plain text
#: PKGBUILD.8:220
msgid ""
"Specifies a special install script that is to be included in the package. "
"This file should reside in the same directory as the FrugalBuild, and will "
"be copied into the package by makepkg. It does not need to be included in "
"the I<source> array. (eg, install=modutils.install)"
msgstr ""
# type: TP
#: PKGBUILD.8:221
#, no-wrap
@ -2256,24 +2227,15 @@ msgid ""
"without visiting manually the project's website (see above)."
msgstr ""
# type: Plain text
#: PKGBUILD.8:234
msgid ""
"The I<source> line is an array of source files required to build the "
"package. Source files must reside in the same directory as the FrugalBuild "
"file, unless they have a fully-qualified URL. Then if the source file does "
"not already exist in /var/cache/pacman/src, the file is downloaded by wget."
msgstr ""
# type: Plain text
#: PKGBUILD.8:243
msgid ""
"If this field is present, it should contain an MD5 hash for every source "
"file specified in the I<source> array (in the same order). makepkg will use "
"this to verify source file integrity during subsequent builds. To easily "
"generate md5sums, first build using the FrugalBuild then run B<makepkg -G "
"E<gt>E<gt>FrugalBuild>. Then you can edit the FrugalBuild and move the "
"I<md5sums> line from the bottom to an appropriate location."
"generate md5sums, first build using the PKGBUILD then run B<makepkg -G "
"E<gt>E<gt>PKGBUILD>. Then you can edit the PKGBUILD and move the I<md5sums> "
"line from the bottom to an appropriate location."
msgstr ""
# type: TP
@ -2288,8 +2250,8 @@ msgid ""
"If this field is present, it should contain an SHA1 hash for every source "
"file specified in the I<source> array (in the same order). makepkg will use "
"this to verify source file integrity during subsequent builds. To easily "
"generate sha1sums, first build using the FrugalBuild then run B<makepkg -g "
"E<gt>E<gt>FrugalBuild>. Then you can edit the FrugalBuild and move the "
"generate sha1sums, first build using the PKGBUILD then run B<makepkg -g "
"E<gt>E<gt>PKGBUILD>. Then you can edit the PKGBUILD and move the "
"I<sha1sums> line from the bottom to an appropriate location."
msgstr ""
@ -2326,18 +2288,6 @@ msgid ""
"generating package databases."
msgstr ""
# type: Plain text
#: PKGBUILD.8:289
msgid ""
"An array of packages that this package depends on to build and run. "
"Packages in this list should be surrounded with single quotes and contain at "
"least the package name. They can also include a version requirement of the "
"form B<nameE<lt>E<gt>version>, where E<lt>E<gt> is one of these three "
"comparisons: B<E<gt>=> (greater than equal to), B<E<lt>=> (less than or "
"equal to), or B<=> (equal to). See the FrugalBuild example above for an "
"example of the I<depends> directive."
msgstr ""
# type: TP
#: PKGBUILD.8:295
#, no-wrap
@ -2437,7 +2387,7 @@ msgstr ""
#: PKGBUILD.8:372
msgid ""
"When you start building with makepkg -R, pacman will install these packages "
"to /var/chroot if necessary. This will produce a fully \"clean\" Frugalware "
"to /var/chroot if necessary. This will produce a fully \"clean\" Archlinux "
"system, that consits of base packages only. This /var/chroot is fully "
"separated from the host system so that this will solve the problems "
"mentioned above. (Linking to a library installed from source, etc.)"
@ -2464,7 +2414,7 @@ msgstr ""
#: PKGBUILD.8:385
msgid ""
"This way we can prevent lots of dependency problems and it is even possible "
"to build packages for a different Frugalware version. This is quite efficent "
"to build packages for a different Archlinux version. This is quite efficent "
"when building security updates or fixing critical bugs in the -stable tree."
msgstr ""
@ -2552,7 +2502,7 @@ msgstr ""
#: PKGBUILD.8:434
#, no-wrap
msgid ""
"Add the followings to your bottom of your FrugalBuild\n"
"Add the followings to your bottom of your PKGBUILD\n"
"subpkgs=('foo' 'bar')\n"
"subdescs=('desc of foo' 'desc of bar')\n"
"subdepends=('foodep1 foodep2' 'bardep1 bardep2')\n"

View file

@ -1,64 +1,71 @@
#
# vim: set ft=sh ts=2 sw=2 et:
# /etc/makepkg.conf
#
# The FTP/HTTP download utility that makepkg should use to acquire sources
export FTPAGENT="/usr/bin/wget -U makepkg --continue --passive-ftp --tries=3 --waitretry=3 --no-check-certificate"
#export FTPAGENT="/usr/bin/snarf"
#export FTPAGENT="/usr/bin/lftpget -c"
#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The FTP/HTTP download utility that makepkg should use to acquire sources
FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3 --no-check-certificate"
#FTPAGENT="/usr/bin/snarf"
#FTPAGENT="/usr/bin/lftpget -c"
export CARCH="@CARCH@"
export CHOST="@CHOST@"
#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="@CARCH@"
CHOST="@CHOST@"
# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon exclusive (binaries
# will use the P6 instruction set and only run on P6+ systems)
export CFLAGS="-@MARCHFLAG@=@CARCHFLAGS@ -O2 -pipe"
export CXXFLAGS="-@MARCHFLAG@=@CARCHFLAGS@ -O2 -pipe"
# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon optimized (but binaries
# will run on any x86 system)
#export CFLAGS="-mcpu=i686 -O2 -pipe"
#export CXXFLAGS="-mcpu=i686 -O2 -pipe"
#-- Exclusive: will only run on i686 or higher (P6, Athlon)
CFLAGS="-@MARCHFLAG@=@CARCHFLAGS@ -O2 -pipe"
CXXFLAGS="-@MARCHFLAG@=@CARCHFLAGS@ -O2 -pipe"
#-- Optimized: will run on any x86, but optimized for i686
#CFLAGS="-mcpu=i686 -O2 -pipe"
#CXXFLAGS="-mcpu=i686 -O2 -pipe"
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
# SMP Systems
#export MAKEFLAGS="-j2"
#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
#-- Fakeroot: for building packages as a non-root user
USE_FAKEROOT="y"
#-- DistCC: a distributed C/C++/ObjC compiler (modify MAKEFLAGS too)
DISTCC="n"
#-- A space-delimited list of hosts running in the DistCC cluster
DISTCC_HOSTS=""
#-- Colorized output messages
USE_COLOR="y"
# Enable fakeroot for building packages as a non-root user
export USE_FAKEROOT="y"
#########################################################################
# GLOBAL PACKAGE OPTIONS
#########################################################################
#
#-- Don't strip symbols from binaries/libraries
NOSTRIP=0
#-- Keep doc and info directories
KEEPDOCS=0
# Specify a directory for the chroot environment.
export CHROOTDIR="/var/chroot"
# Core package list to be installed in the chroot.
export COREPKGS="core chroot-core devel-core"
#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
# Enable distributed C/C++/ObjC compiler
# Don't forget to modify MAKEFLAGS to include -jN, where N is twice the
# number of CPUs +1 available
export DISTCC="n"
# Space-separated list of volunteer host specifications.
export DISTCC_HOSTS=""
#########################################################################
# Functionality Configuration
# Most of this will probably not need to be changed by and end user
#########################################################################
#
BUILDSCRIPT="PKGBUILD"
PKGEXT="pkg.tar.gz"
INTEGRITY_CHECK="sha1"
# Enable colorized output messages
export USE_COLOR="y"
# Specify a fixed directory where all packages will be placed
#export PKGDEST=/home/packages
# If you want your name to show up in the packages you build, change this.
export PACKAGER="Archlinux (http://archlinux.org)"
# Don't strip symbols from binaries/libraries
#export NOSTRIP="1"
# Don't prepare documentation
#export NODOCS="1"
# LOGDIR is the location where you would like to store a
# permanant copy of the build log.
# filename = [LOGDIR_APPEND]-[pkgname]-[pkgver]-[pkgrel]
LOGDIR_APPEND=`date +%Y-%m-%d-%s`
LOGDIR=/var/log/builds
# The Standard Build Unit of this machine
# If 1, then the build time will be displayed in seconds
# Build the "binutils" package, and then write here the result you got,
# so that makepkg will could the right SBU value for you.
SBU="1"
source "/etc/abs/abs.conf"
SRCROOT=$ABSROOT

View file

@ -1,6 +1,6 @@
AUTOMAKE_OPTIONS = gnu
DEFINES = -pedantic -D_GNU_SOURCE
AM_CFLAGS = $(DEFINES) -I$(top_srcdir)/lib/libfetch
AM_CFLAGS = $(DEFINES)
SUBDIRS = po
localedir = $(datadir)/locale
@ -37,8 +37,8 @@ include_HEADERS = alpm.h
libalpm_la_SOURCES = $(TARGETS)
libalpm_la_LDFLAGS = -no-undefined -version-info $(PM_VERSION_INFO) -L$(top_srcdir)/lib/libfetch
libalpm_la_LIBADD = -lfetch
libalpm_la_LDFLAGS = -no-undefined -version-info $(PM_VERSION_INFO)
libalpm_la_LIBADD = -ldownload
if HAS_DOXYGEN
all: doxygen.in

View file

@ -129,7 +129,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
goto error;
}
if(_alpm_pkg_splitname(name, pkgname, pkgver) == -1) {
if(_alpm_pkg_splitname(name, pkgname, pkgver, 1) == -1) {
pm_errno = PM_ERR_PKG_INVALID_NAME;
goto error;
}

View file

@ -346,9 +346,9 @@ int alpm_db_update(int force, PM_DB *db)
pm_errno = 0;
return(1);
} else if(ret == -1) {
/* we use fetchLastErrString and fetchLastErrCode here, error returns from
* libfetch */
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]"), fetchLastErrString, fetchLastErrCode);
/* we use downloadLastErrString and downloadLastErrCode here, error returns from
* libdownload */
_alpm_log(PM_LOG_DEBUG, _("failed to sync db: %s [%d]"), downloadLastErrString, downloadLastErrCode);
RET_ERR(PM_ERR_DB_SYNC, -1);
} else {
if(strlen(newmtime)) {
@ -1109,6 +1109,19 @@ int alpm_list_free(pmlist_t *entry)
return(0);
}
/** Free the outer list, but not the contained data
* @param entry list to free
* @return 0 on success, -1 on error
*/
int alpm_list_free_outer(pmlist_t *entry)
{
ASSERT(entry != NULL, return(-1));
_FREELIST(entry, NULL);
return(0);
}
/** Count the entries in a list.
* @param list the list to count
* @return number of entries on success, NULL on error

View file

@ -72,7 +72,7 @@ int alpm_release(void);
#define PM_LOG_FLOW1 0x08
#define PM_LOG_FLOW2 0x10
#define PM_LOG_FUNCTION 0x20
#define PM_LOG_FETCH 0x40
#define PM_LOG_DOWNLOAD 0x40
int alpm_logaction(char *fmt, ...);
@ -390,6 +390,7 @@ PM_LIST *alpm_list_first(PM_LIST *list);
PM_LIST *alpm_list_next(PM_LIST *entry);
void *alpm_list_getdata(PM_LIST *entry);
int alpm_list_free(PM_LIST *entry);
int alpm_list_free_outer(PM_LIST *entry);
int alpm_list_count(PM_LIST *list);
/* md5sums */

View file

@ -163,7 +163,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
if(pkg == NULL) {
return(NULL);
}
if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version) == -1) {
if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version, 0) == -1) {
_alpm_log(PM_LOG_ERROR, _("invalid name for dabatase entry '%s'"), ent->d_name);
return(NULL);
}
@ -180,9 +180,8 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
struct stat buf;
char path[PATH_MAX+1];
char line[513];
char *lang_tmp;
pmlist_t *tmplist;
char *foo;
char *locale;
if(db == NULL) {
RET_ERR(PM_ERR_DB_NULL, -1);
@ -225,30 +224,26 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
info->desc_localized = _alpm_list_add(info->desc_localized, strdup(line));
}
if (setlocale(LC_ALL, "") == NULL) { /* To fix segfault when locale invalid */
if((locale = setlocale(LC_ALL, "")) == NULL) { /* To fix segfault when locale invalid */
setenv("LC_ALL", "C", 1);
locale = setlocale(LC_ALL, "");
}
if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(lang_tmp, strlen(setlocale(LC_ALL, "")), "%s", setlocale(LC_ALL, ""));
if(info->desc_localized && !info->desc_localized->next) {
snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
} else {
for (tmplist = info->desc_localized; tmplist; tmplist = tmplist->next) {
if (tmplist->data && strncmp(tmplist->data, lang_tmp, strlen(lang_tmp))) {
snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
if (tmplist->data && strncmp(tmplist->data, locale, strlen(locale))) {
strncpy(info->desc, (char *)info->desc_localized->data, sizeof(info->desc));
} else {
foo = strdup(tmplist->data);
snprintf(info->desc, 512, "%s", foo+strlen(lang_tmp)+1);
FREE(foo);
char *p = (char *)tmplist->data;
p += strlen(locale) + 1;
strncpy(info->desc, p, sizeof(info->desc));
break;
}
}
}
_alpm_strtrim(info->desc);
FREE(lang_tmp);
} else if(!strcmp(line, "%GROUPS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
info->groups = _alpm_list_add(info->groups, strdup(line));

View file

@ -435,7 +435,7 @@ pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack)
return(NULL);
}
int _alpm_pkg_splitname(char *target, char *name, char *version)
int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch)
{
char tmp[PKG_FULLNAME_LEN+7];
char *p, *q;
@ -453,7 +453,11 @@ int _alpm_pkg_splitname(char *target, char *name, char *version)
STRNCPY(tmp, p, PKG_FULLNAME_LEN+7);
/* trim file extension (if any) */
if((p = strstr(tmp, PM_EXT_PKG))) {
*p = 0;
*p = '\0';
}
if((p = _alpm_pkgname_has_arch(tmp))) {
*p = '\0';
}
p = tmp + strlen(tmp);
@ -469,7 +473,7 @@ int _alpm_pkg_splitname(char *target, char *name, char *version)
if(version) {
STRNCPY(version, p+1, PKG_VERSION_LEN);
}
*p = 0;
*p = '\0';
if(name) {
STRNCPY(name, tmp, PKG_NAME_LEN);

View file

@ -98,7 +98,7 @@ void _alpm_pkg_free(void *data);
int _alpm_pkg_cmp(const void *p1, const void *p2);
pmpkg_t *_alpm_pkg_load(char *pkgfile);
pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack);
int _alpm_pkg_splitname(char *target, char *name, char *version);
int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch);
#endif /* _ALPM_PACKAGE_H */

View file

@ -52,7 +52,7 @@ pmserver_t *_alpm_server_new(const char *url)
}
memset(server, 0, sizeof(pmserver_t));
u = fetchParseURL(url);
u = downloadParseURL(url);
if(!u) {
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid, ignoring"), url);
return(NULL);
@ -68,7 +68,7 @@ pmserver_t *_alpm_server_new(const char *url)
}
/* This isn't needed... we can actually kill the whole pmserver_t interface
* and replace it with libfetch's 'struct url'
* and replace it with libdownload's 'struct url'
*/
server->s_url = u;
server->path = strdup(u->doc);
@ -86,7 +86,7 @@ void _alpm_server_free(void *data)
/* free memory */
FREE(server->path);
fetchFreeURL(server->s_url);
downloadFreeURL(server->s_url);
FREE(server);
}
@ -165,24 +165,24 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
server->s_url->doc = (char *)malloc(len);
snprintf(server->s_url->doc, len, "%s/%s", server->path, fn);
/* libfetch does not reset the error code, reset it in the case of previous errors */
fetchLastErrCode = 0;
/* libdownload does not reset the error code, reset it in the case of previous errors */
downloadLastErrCode = 0;
/* 10s timeout - TODO make a config option */
fetchTimeout = 10000;
downloadTimeout = 10000;
/* Make libfetch super verbose... worthwhile for testing */
if(pm_logmask & PM_LOG_FETCH) {
fetchDebug = 1;
/* Make libdownload super verbose... worthwhile for testing */
if(pm_logmask & PM_LOG_DOWNLOAD) {
downloadDebug = 1;
}
if(pm_logmask & PM_LOG_DEBUG) {
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "v" : "vp"));
dlf = downloadXGet(server->s_url, &ust, (handle->nopassiveftp ? "v" : "vp"));
} else {
dlf = fetchXGet(server->s_url, &ust, (handle->nopassiveftp ? "" : "p"));
dlf = downloadXGet(server->s_url, &ust, (handle->nopassiveftp ? "" : "p"));
}
if(fetchLastErrCode != 0 || dlf == NULL) {
if(downloadLastErrCode != 0 || dlf == NULL) {
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s://%s: %s"), fn,
server->s_url->scheme, server->s_url->host, fetchLastErrString);
server->s_url->scheme, server->s_url->host, downloadLastErrString);
if(localf != NULL) {
fclose(localf);
}
@ -321,7 +321,7 @@ char *_alpm_fetch_pkgurl(char *target)
struct stat st;
struct url *s_url;
s_url = fetchParseURL(target);
s_url = downloadParseURL(target);
if(!s_url) {
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid, ignoring"), target);
return(NULL);
@ -350,7 +350,7 @@ char *_alpm_fetch_pkgurl(char *target)
}
if(s_url->doc && (p = strrchr(s_url->doc,'/'))) {
*p++ = '\0';
_alpm_log(PM_LOG_DEBUG, _("fetching '%s' from '%s://%s%s"), p, s_url->scheme, s_url->host, s_url->doc);
_alpm_log(PM_LOG_DEBUG, _("downloading '%s' from '%s://%s%s"), p, s_url->scheme, s_url->host, s_url->doc);
server->s_url = s_url;
server->path = strdup(s_url->doc);
@ -366,10 +366,15 @@ char *_alpm_fetch_pkgurl(char *target)
}
}
fetchFreeURL(s_url);
/* dupe before we free the URL struct...*/
if(p) {
p = strdup(p);
}
downloadFreeURL(s_url);
/* return the target with the raw filename, no URL */
return(p ? strdup(p) : NULL);
return(p);
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -24,7 +24,7 @@
#include "list.h"
#include <time.h>
#include <fetch.h>
#include <download.h>
#define FREESERVER(p) \
do { \

View file

@ -451,6 +451,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
}
}
}
FREELISTPTR(k);
FREELISTPTR(trans->packages);
trans->packages = l;

View file

@ -243,6 +243,8 @@ int _alpm_lckmk(char *file)
}
}
free(dir);
return(fd > 0 ? fd : -1);
}
@ -287,9 +289,10 @@ int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
return(1);
}
if (fn)
if(fn) {
break;
}
}
archive_read_finish(_archive);
return(0);
@ -543,9 +546,10 @@ static long long get_freespace()
FILE *fp;
long long ret=0;
fp = setmntent (table, "r");
if(!fp)
if((fp = setmntent(table, "r")) == NULL) {
return(-1);
}
while ((mnt = getmntent(fp)))
{
struct statvfs64 buf;
@ -553,6 +557,9 @@ static long long get_freespace()
statvfs64(mnt->mnt_dir, &buf);
ret += buf.f_bavail * buf.f_bsize;
}
endmntent(fp);
return(ret);
}
@ -634,4 +641,44 @@ void _alpm_time2string(time_t t, char *buffer)
}
}
/* internal */
char *_supported_archs[] = {
"i586",
"i686",
"ppc",
"x86_64",
};
char *_alpm_pkgname_has_arch(char *pkgname)
{
/* TODO remove this when we transfer everything over to -ARCH
*
* this parsing sucks... it's done to support
* two package formats for the time being:
* package-name-foo-1.0.0-1-i686
* and
* package-name-bar-1.2.3-1
*/
int i = 0;
char *arch, *cmp, *p;
if((p = strrchr(pkgname, '-'))) {
for(i=0; i < sizeof(_supported_archs)/sizeof(char*); ++i) {
cmp = p+1;
arch = _supported_archs[i];
/* whee, case insensitive compare */
while(*arch && *cmp && tolower(*arch++) == tolower(*cmp++)) ;
if(*arch || *cmp) continue;
return p;
}
}
return NULL;
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -72,6 +72,7 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data);
#endif
int _alpm_reg_match(char *string, char *pattern);
void _alpm_time2string(time_t t, char *buffer);
char *_alpm_pkgname_has_arch(char *pkgname);
#ifdef __sun__
char* strsep(char** str, const char* delims);
char* mkdtemp(char *template);

View file

@ -1,95 +0,0 @@
prefix = /usr
DESTDIR =
DEBUG = true
ENABLE_HTTPS = true
CFLAGS = -O2 -pipe -I. -DINET6
WARNINGS = -Wall -Wstrict-prototypes -Wsign-compare -Wchar-subscripts \
-Wpointer-arith -Wcast-align -Wsign-compare
CFLAGS += $(WARNINGS)
ifeq ($(strip $(DEBUG)), true)
CFLAGS += -g
else
CFLAGS += -DNDEBUG
endif
ifeq ($(strip $(ENALE_HTTPS)),true)
CFLAGS += -DWITH_SSL
LDFLAGS += -lssl -lcrypto
endif
CC = gcc
LD = gcc
AR = ar
RANLIB = ranlib
INSTALL = install -c -D
OBJS= fetch.o common.o ftp.o http.o file.o
INCS= fetch.h common.h
GEN = ftperr.h httperr.h
MAN = fetch.3
#pretty print!
E = @echo
Q = @
all: libfetch.so libfetch.a
$(E) " built with: " $(CFLAGS)
.PHONY: all
%.o: %.c
$(E) " compile " $@
$(Q) $(CC) $(CFLAGS) -c $<
ftperr.h: ftp.errors
$(E) " generate " $@
@echo "static struct fetcherr _ftp_errlist[] = {" > $@
@cat $< \
| grep -v ^# \
| sort \
| while read NUM CAT STRING; do \
echo " { $${NUM}, FETCH_$${CAT}, \"$${STRING}\" },"; \
done >> $@
@echo -e " { -1, FETCH_UNKNOWN, \"Unknown FTP error\" }\n};" >> $@
httperr.h: http.errors
$(E) " generate " $@
@echo "static struct fetcherr _http_errlist[] = {" > $@
@cat $< \
| grep -v ^# \
| sort \
| while read NUM CAT STRING; do \
echo " { $${NUM}, FETCH_$${CAT}, \"$${STRING}\" },"; \
done >> $@
@echo -e " { -1, FETCH_UNKNOWN, \"Unknown HTTP error\" }\n};" >> $@
libfetch.so: $(GEN) $(INCS) $(OBJS)
$(E) " build " $@
$(Q) rm -f $@
$(Q) $(LD) $(LDFLAGS) *.o -shared -o $@
libfetch.a: $(GEN) $(INCS) $(OBJS)
$(E) " build " $@
$(Q) rm -f $@
$(Q) $(AR) rcs $@ *.o
$(Q) $(RANLIB) $@
clean:
$(E) " clean "
$(Q) rm -f libfetch.so libfetch.a *.o $(GEN)
.PHONY: clean
install: all
$(Q) $(INSTALL) -m 755 libfetch.so $(DESTDIR)$(prefix)/lib/libfetch.so
$(Q) $(INSTALL) -m 644 libfetch.a $(DESTDIR)$(prefix)/lib/libfetch.a
$(Q) $(INSTALL) -m 644 fetch.h $(DESTDIR)$(prefix)/include/fetch.h
$(Q) $(INSTALL) -m 644 fetch.3 $(DESTDIR)$(prefix)/man/man3/fetch.3
.PHONY: install
uninstall:
$(Q) rm -f $(DESTDIR)$(prefix)/lib/libfetch.so
$(Q) rm -f $(DESTDIR)$(prefix)/lib/libfetch.a
$(Q) rm -f $(DESTDIR)$(prefix)/include/fetch.h
$(Q) rm -f $(DESTDIR)$(prefix)/man/man3/fetch.3
.PHONY: uninstall

View file

@ -1,752 +0,0 @@
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <errno.h>
#include <netdb.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "fetch.h"
#include "common.h"
/*** Local data **************************************************************/
/*
* Error messages for resolver errors
*/
static struct fetcherr _netdb_errlist[] = {
#ifdef EAI_NODATA
{ EAI_NODATA, FETCH_RESOLV, "Host not found" },
#endif
{ EAI_AGAIN, FETCH_TEMP, "Transient resolver failure" },
{ EAI_FAIL, FETCH_RESOLV, "Non-recoverable resolver failure" },
{ EAI_NONAME, FETCH_RESOLV, "No address record" },
{ -1, FETCH_UNKNOWN, "Unknown resolver error" }
};
/* End-of-Line */
static const char ENDL[2] = "\r\n";
/*** Error-reporting functions ***********************************************/
/*
* Map error code to string
*/
static struct fetcherr *
_fetch_finderr(struct fetcherr *p, int e)
{
while (p->num != -1 && p->num != e)
p++;
return (p);
}
/*
* Set error code
*/
void
_fetch_seterr(struct fetcherr *p, int e)
{
p = _fetch_finderr(p, e);
fetchLastErrCode = p->cat;
snprintf(fetchLastErrString, MAXERRSTRING, "%s", p->string);
}
/*
* Set error code according to errno
*/
void
_fetch_syserr(void)
{
switch (errno) {
case 0:
fetchLastErrCode = FETCH_OK;
break;
case EPERM:
case EACCES:
case EROFS:
fetchLastErrCode = FETCH_AUTH;
break;
case ENOENT:
case EISDIR: /* XXX */
fetchLastErrCode = FETCH_UNAVAIL;
break;
case ENOMEM:
fetchLastErrCode = FETCH_MEMORY;
break;
case EBUSY:
case EAGAIN:
fetchLastErrCode = FETCH_TEMP;
break;
case EEXIST:
fetchLastErrCode = FETCH_EXISTS;
break;
case ENOSPC:
fetchLastErrCode = FETCH_FULL;
break;
case EADDRINUSE:
case EADDRNOTAVAIL:
case ENETDOWN:
case ENETUNREACH:
case ENETRESET:
case EHOSTUNREACH:
fetchLastErrCode = FETCH_NETWORK;
break;
case ECONNABORTED:
case ECONNRESET:
fetchLastErrCode = FETCH_ABORT;
break;
case ETIMEDOUT:
fetchLastErrCode = FETCH_TIMEOUT;
break;
case ECONNREFUSED:
case EHOSTDOWN:
fetchLastErrCode = FETCH_DOWN;
break;
default:
fetchLastErrCode = FETCH_UNKNOWN;
}
snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno));
}
/*
* Emit status message
*/
void
_fetch_info(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fputc('\n', stderr);
}
/*** Network-related utility functions ***************************************/
/*
* Return the default port for a scheme
*/
int
_fetch_default_port(const char *scheme)
{
struct servent *se;
if ((se = getservbyname(scheme, "tcp")) != NULL)
return (ntohs(se->s_port));
if (strcasecmp(scheme, SCHEME_FTP) == 0)
return (FTP_DEFAULT_PORT);
if (strcasecmp(scheme, SCHEME_HTTP) == 0)
return (HTTP_DEFAULT_PORT);
return (0);
}
/*
* Return the default proxy port for a scheme
*/
int
_fetch_default_proxy_port(const char *scheme)
{
if (strcasecmp(scheme, SCHEME_FTP) == 0)
return (FTP_DEFAULT_PROXY_PORT);
if (strcasecmp(scheme, SCHEME_HTTP) == 0)
return (HTTP_DEFAULT_PROXY_PORT);
return (0);
}
/*
* Create a connection for an existing descriptor.
*/
conn_t *
_fetch_reopen(int sd)
{
conn_t *conn;
/* allocate and fill connection structure */
if ((conn = calloc(1, sizeof(*conn))) == NULL)
return (NULL);
conn->sd = sd;
++conn->ref;
return (conn);
}
/*
* Bump a connection's reference count.
*/
conn_t *
_fetch_ref(conn_t *conn)
{
++conn->ref;
return (conn);
}
/*
* Bind a socket to a specific local address
*/
int
_fetch_bind(int sd, int af, const char *addr)
{
struct addrinfo hints, *res, *res0;
int err;
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if ((err = getaddrinfo(addr, NULL, &hints, &res0)) != 0)
return (-1);
for (res = res0; res; res = res->ai_next)
if (bind(sd, res->ai_addr, res->ai_addrlen) == 0)
return (0);
return (-1);
}
/*
* Establish a TCP connection to the specified port on the specified host.
*/
conn_t *
_fetch_connect(const char *host, int port, int af, int verbose)
{
conn_t *conn;
char pbuf[10];
const char *bindaddr;
struct addrinfo hints, *res, *res0;
int sd, err;
DEBUG(fprintf(stderr, "---> %s:%d\n", host, port));
if (verbose)
_fetch_info("looking up %s", host);
/* look up host name and set up socket address structure */
snprintf(pbuf, sizeof(pbuf), "%d", port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if ((err = getaddrinfo(host, pbuf, &hints, &res0)) != 0) {
_netdb_seterr(err);
return (NULL);
}
bindaddr = getenv("FETCH_BIND_ADDRESS");
if (verbose)
_fetch_info("connecting to %s:%d", host, port);
/* try to connect */
for (sd = -1, res = res0; res; sd = -1, res = res->ai_next) {
if ((sd = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) == -1)
continue;
if (bindaddr != NULL && *bindaddr != '\0' &&
_fetch_bind(sd, res->ai_family, bindaddr) != 0) {
_fetch_info("failed to bind to '%s'", bindaddr);
close(sd);
continue;
}
if (connect(sd, res->ai_addr, res->ai_addrlen) == 0)
break;
close(sd);
}
freeaddrinfo(res0);
if (sd == -1) {
_fetch_syserr();
return (NULL);
}
if ((conn = _fetch_reopen(sd)) == NULL) {
_fetch_syserr();
close(sd);
}
return (conn);
}
/*
* Enable SSL on a connection.
*/
int
_fetch_ssl(conn_t *conn, int verbose)
{
#ifdef WITH_SSL
/* Init the SSL library and context */
if (!SSL_library_init()){
fprintf(stderr, "SSL library init failed\n");
return (-1);
}
SSL_load_error_strings();
conn->ssl_meth = SSLv23_client_method();
conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth);
SSL_CTX_set_mode(conn->ssl_ctx, SSL_MODE_AUTO_RETRY);
conn->ssl = SSL_new(conn->ssl_ctx);
if (conn->ssl == NULL){
fprintf(stderr, "SSL context creation failed\n");
return (-1);
}
SSL_set_fd(conn->ssl, conn->sd);
if (SSL_connect(conn->ssl) == -1){
ERR_print_errors_fp(stderr);
return (-1);
}
if (verbose) {
X509_NAME *name;
char *str;
fprintf(stderr, "SSL connection established using %s\n",
SSL_get_cipher(conn->ssl));
conn->ssl_cert = SSL_get_peer_certificate(conn->ssl);
name = X509_get_subject_name(conn->ssl_cert);
str = X509_NAME_oneline(name, 0, 0);
printf("Certificate subject: %s\n", str);
free(str);
name = X509_get_issuer_name(conn->ssl_cert);
str = X509_NAME_oneline(name, 0, 0);
printf("Certificate issuer: %s\n", str);
free(str);
}
return (0);
#else
(void)conn;
(void)verbose;
fprintf(stderr, "SSL support disabled\n");
return (-1);
#endif
}
/*
* Read a character from a connection w/ timeout
*/
ssize_t
_fetch_read(conn_t *conn, char *buf, size_t len)
{
struct timeval wait;
fd_set readfds;
ssize_t rlen, total;
int r;
if (fetchTimeout) {
FD_ZERO(&readfds);
/*
gettimeofday(&timeout, NULL);
timeout.tv_sec += fetchTimeout;
*/
}
total = 0;
while (len > 0) {
while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) {
FD_SET(conn->sd, &readfds);
/*gettimeofday(&now, NULL);
wait.tv_sec = timeout.tv_sec - now.tv_sec;
wait.tv_usec = timeout.tv_usec - now.tv_usec;
if (wait.tv_usec < 0) {
wait.tv_usec += 1000000;
wait.tv_sec--;
}
if (wait.tv_sec < 0) {
errno = ETIMEDOUT;
_fetch_syserr();
return (-1);
}
*/
wait.tv_sec = fetchTimeout / 1000;
wait.tv_usec = (fetchTimeout % 1000) * 1000;
errno = 0;
r = select(conn->sd + 1, &readfds, NULL, NULL, &wait);
if (r == -1) {
if (errno == EINTR && fetchRestartCalls)
continue;
_fetch_syserr();
return (-1);
} else if (r == 0) {
errno = ETIMEDOUT;
_fetch_syserr();
return (-1);
}
}
#ifdef WITH_SSL
if (conn->ssl != NULL)
rlen = SSL_read(conn->ssl, buf, len);
else
#endif
rlen = read(conn->sd, buf, len);
if (rlen == 0)
break;
if (rlen < 0) {
if (errno == EINTR && fetchRestartCalls)
continue;
return (-1);
}
len -= rlen;
buf += rlen;
total += rlen;
}
return (total);
}
/*
* Read a line of text from a connection w/ timeout
*/
#define MIN_BUF_SIZE 1024
int
_fetch_getln(conn_t *conn)
{
char *tmp;
size_t tmpsize;
ssize_t len;
char c;
if (conn->buf == NULL) {
if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) {
errno = ENOMEM;
return (-1);
}
conn->bufsize = MIN_BUF_SIZE;
}
conn->buf[0] = '\0';
conn->buflen = 0;
do {
len = _fetch_read(conn, &c, 1);
if (len == -1)
return (-1);
if (len == 0)
break;
conn->buf[conn->buflen++] = c;
if (conn->buflen == conn->bufsize) {
tmp = conn->buf;
tmpsize = conn->bufsize * 2 + 1;
if ((tmp = realloc(tmp, tmpsize)) == NULL) {
errno = ENOMEM;
return (-1);
}
conn->buf = tmp;
conn->bufsize = tmpsize;
}
} while (c != '\n');
conn->buf[conn->buflen] = '\0';
DEBUG(fprintf(stderr, "<<< %s", conn->buf));
return (0);
}
/*
* Write to a connection w/ timeout
*/
ssize_t
_fetch_write(conn_t *conn, const char *buf, size_t len)
{
struct iovec iov;
iov.iov_base = __DECONST(char *, buf);
iov.iov_len = len;
return _fetch_writev(conn, &iov, 1);
}
/*
* Write a vector to a connection w/ timeout
* Note: can modify the iovec.
*/
ssize_t
_fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
{
struct timeval wait;
fd_set writefds;
ssize_t wlen, total;
int r;
if (fetchTimeout) {
FD_ZERO(&writefds);
/*
gettimeofday(&timeout, NULL);
timeout.tv_sec += fetchTimeout;
*/
}
total = 0;
while (iovcnt > 0) {
while (fetchTimeout && !FD_ISSET(conn->sd, &writefds)) {
FD_SET(conn->sd, &writefds);
/*
gettimeofday(&now, NULL);
wait.tv_sec = timeout.tv_sec - now.tv_sec;
wait.tv_usec = timeout.tv_usec - now.tv_usec;
if (wait.tv_usec < 0) {
wait.tv_usec += 1000000;
wait.tv_sec--;
}
if (wait.tv_sec < 0) {
errno = ETIMEDOUT;
_fetch_syserr();
return (-1);
}
*/
wait.tv_sec = fetchTimeout / 1000;
wait.tv_usec = (fetchTimeout % 1000) * 1000;
errno = 0;
r = select(conn->sd + 1, NULL, &writefds, NULL, &wait);
if (r == -1) {
if (errno == EINTR && fetchRestartCalls)
continue;
return (-1);
} else if (r == 0) {
errno = ETIMEDOUT;
_fetch_syserr();
return (-1);
}
}
errno = 0;
#ifdef WITH_SSL
if (conn->ssl != NULL)
wlen = SSL_write(conn->ssl,
iov->iov_base, iov->iov_len);
else
#endif
wlen = writev(conn->sd, iov, iovcnt);
if (wlen == 0) {
/* we consider a short write a failure */
errno = EPIPE;
_fetch_syserr();
return (-1);
}
if (wlen < 0) {
if (errno == EINTR && fetchRestartCalls)
continue;
return (-1);
}
total += wlen;
while (iovcnt > 0 && wlen >= (ssize_t)iov->iov_len) {
wlen -= iov->iov_len;
iov++;
iovcnt--;
}
if (iovcnt > 0) {
iov->iov_len -= wlen;
iov->iov_base = __DECONST(char *, iov->iov_base) + wlen;
}
}
return (total);
}
/*
* Write a line of text to a connection w/ timeout
*/
int
_fetch_putln(conn_t *conn, const char *str, size_t len)
{
struct iovec iov[2];
int ret;
DEBUG(fprintf(stderr, ">>> %s\n", str));
iov[0].iov_base = __DECONST(char *, str);
iov[0].iov_len = len;
iov[1].iov_base = __DECONST(char *, ENDL);
iov[1].iov_len = sizeof(ENDL);
if (len == 0)
ret = _fetch_writev(conn, &iov[1], 1);
else
ret = _fetch_writev(conn, iov, 2);
if (ret == -1)
return (-1);
return (0);
}
/*
* Close connection
*/
int
_fetch_close(conn_t *conn)
{
int ret;
if (--conn->ref > 0)
return (0);
ret = close(conn->sd);
free(conn->buf);
free(conn);
return (ret);
}
/*** Directory-related utility functions *************************************/
int
_fetch_add_entry(struct url_ent **p, int *size, int *len,
const char *name, struct url_stat *us)
{
struct url_ent *tmp;
if (*p == NULL) {
*size = 0;
*len = 0;
}
if (*len >= *size - 1) {
tmp = realloc(*p, (*size * 2 + 1) * sizeof(**p));
if (tmp == NULL) {
errno = ENOMEM;
_fetch_syserr();
return (-1);
}
*size = (*size * 2 + 1);
*p = tmp;
}
tmp = *p + *len;
snprintf(tmp->name, PATH_MAX, "%s", name);
bcopy(us, &tmp->stat, sizeof(*us));
(*len)++;
(++tmp)->name[0] = 0;
return (0);
}
/*** Authentication-related utility functions ********************************/
static const char *
_fetch_read_word(FILE *f)
{
static char word[1024];
if (fscanf(f, " %1024s ", word) != 1)
return (NULL);
return (word);
}
/*
* Get authentication data for a URL from .netrc
*/
int
_fetch_netrc_auth(struct url *url)
{
char fn[PATH_MAX];
const char *word;
char *p;
FILE *f;
if ((p = getenv("NETRC")) != NULL) {
if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) {
_fetch_info("$NETRC specifies a file name "
"longer than PATH_MAX");
return (-1);
}
} else {
if ((p = getenv("HOME")) != NULL) {
struct passwd *pwd;
if ((pwd = getpwuid(getuid())) == NULL ||
(p = pwd->pw_dir) == NULL)
return (-1);
}
if (snprintf(fn, sizeof(fn), "%s/.netrc", p) >= (int)sizeof(fn))
return (-1);
}
if ((f = fopen(fn, "r")) == NULL)
return (-1);
while ((word = _fetch_read_word(f)) != NULL) {
if (strcmp(word, "default") == 0) {
DEBUG(_fetch_info("Using default .netrc settings"));
break;
}
if (strcmp(word, "machine") == 0 &&
(word = _fetch_read_word(f)) != NULL &&
strcasecmp(word, url->host) == 0) {
DEBUG(_fetch_info("Using .netrc settings for %s", word));
break;
}
}
if (word == NULL)
goto ferr;
while ((word = _fetch_read_word(f)) != NULL) {
if (strcmp(word, "login") == 0) {
if ((word = _fetch_read_word(f)) == NULL)
goto ferr;
if (snprintf(url->user, sizeof(url->user),
"%s", word) > (int)sizeof(url->user)) {
_fetch_info("login name in .netrc is too long");
url->user[0] = '\0';
}
} else if (strcmp(word, "password") == 0) {
if ((word = _fetch_read_word(f)) == NULL)
goto ferr;
if (snprintf(url->pwd, sizeof(url->pwd),
"%s", word) > (int)sizeof(url->pwd)) {
_fetch_info("password in .netrc is too long");
url->pwd[0] = '\0';
}
} else if (strcmp(word, "account") == 0) {
if ((word = _fetch_read_word(f)) == NULL)
goto ferr;
/* XXX not supported! */
} else {
break;
}
}
fclose(f);
return (0);
ferr:
fclose(f);
return (-1);
}

View file

@ -1,127 +0,0 @@
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: /repoman/r/ncvs/src/lib/libfetch/common.h,v 1.28 2004/09/21 18:35:20 des Exp $
*/
#ifndef _COMMON_H_INCLUDED
#define _COMMON_H_INCLUDED
/* BSD seems to use this alot - we don't have it */
#define __DECONST(type, v) (type)((uintptr_t)(void *)(v))
#define FTP_DEFAULT_PORT 21
#define HTTP_DEFAULT_PORT 80
#define FTP_DEFAULT_PROXY_PORT 21
#define HTTP_DEFAULT_PROXY_PORT 3128
#ifdef WITH_SSL
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
/* Connection */
typedef struct fetchconn conn_t;
struct fetchconn {
int sd; /* socket descriptor */
char *buf; /* buffer */
size_t bufsize; /* buffer size */
size_t buflen; /* length of buffer contents */
int err; /* last protocol reply code */
#ifdef WITH_SSL
SSL *ssl; /* SSL handle */
SSL_CTX *ssl_ctx; /* SSL context */
X509 *ssl_cert; /* server certificate */
SSL_METHOD *ssl_meth; /* SSL method */
#endif
int ref; /* reference count */
};
/* Structure used for error message lists */
struct fetcherr {
const int num;
const int cat;
const char *string;
};
/* for _fetch_writev */
struct iovec;
void _fetch_seterr(struct fetcherr *, int);
void _fetch_syserr(void);
void _fetch_info(const char *, ...);
int _fetch_default_port(const char *);
int _fetch_default_proxy_port(const char *);
int _fetch_bind(int, int, const char *);
conn_t *_fetch_connect(const char *, int, int, int);
conn_t *_fetch_reopen(int);
conn_t *_fetch_ref(conn_t *);
int _fetch_ssl(conn_t *, int);
ssize_t _fetch_read(conn_t *, char *, size_t);
int _fetch_getln(conn_t *);
ssize_t _fetch_write(conn_t *, const char *, size_t);
ssize_t _fetch_writev(conn_t *, struct iovec *, int);
int _fetch_putln(conn_t *, const char *, size_t);
int _fetch_close(conn_t *);
int _fetch_add_entry(struct url_ent **, int *, int *,
const char *, struct url_stat *);
int _fetch_netrc_auth(struct url *url);
#define _ftp_seterr(n) _fetch_seterr(_ftp_errlist, n)
#define _http_seterr(n) _fetch_seterr(_http_errlist, n)
#define _netdb_seterr(n) _fetch_seterr(_netdb_errlist, n)
#define _url_seterr(n) _fetch_seterr(_url_errlist, n)
#ifndef NDEBUG
#define DEBUG(x) do { if (fetchDebug) { x; } } while (0)
#else
#define DEBUG(x) do { } while (0)
#endif
/*
* I don't really like exporting _http_request() and _ftp_request(),
* but the HTTP and FTP code occasionally needs to cross-call
* eachother, and this saves me from adding a lot of special-case code
* to handle those cases.
*
* Note that _*_request() free purl, which is way ugly but saves us a
* whole lot of trouble.
*/
FILE *_http_request(struct url *, const char *,
struct url_stat *, struct url *, const char *);
FILE *_ftp_request(struct url *, const char *,
struct url_stat *, struct url *, const char *);
/*
* Check whether a particular flag is set
*/
#define CHECK_FLAG(x) (flags && strchr(flags, (x)))
#endif

View file

@ -1,668 +0,0 @@
.\"-
.\" Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libfetch/fetch.3,v 1.61 2005/11/30 04:08:45 tmclaugh Exp $
.\"
.Dd July 1, 1998
.Dt FETCH 3
.Os
.Sh NAME
.Nm fetchMakeURL ,
.Nm fetchParseURL ,
.Nm fetchFreeURL ,
.Nm fetchXGetURL ,
.Nm fetchGetURL ,
.Nm fetchPutURL ,
.Nm fetchStatURL ,
.Nm fetchListURL ,
.Nm fetchXGet ,
.Nm fetchGet ,
.Nm fetchPut ,
.Nm fetchStat ,
.Nm fetchList ,
.Nm fetchXGetFile ,
.Nm fetchGetFile ,
.Nm fetchPutFile ,
.Nm fetchStatFile ,
.Nm fetchListFile ,
.Nm fetchXGetHTTP ,
.Nm fetchGetHTTP ,
.Nm fetchPutHTTP ,
.Nm fetchStatHTTP ,
.Nm fetchListHTTP ,
.Nm fetchXGetFTP ,
.Nm fetchGetFTP ,
.Nm fetchPutFTP ,
.Nm fetchStatFTP ,
.Nm fetchListFTP
.Nd file transfer functions
.Sh LIBRARY
.Lb libfetch
.Sh SYNOPSIS
.In sys/param.h
.In stdio.h
.In fetch.h
.Ft struct url *
.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd"
.Ft struct url *
.Fn fetchParseURL "const char *URL"
.Ft void
.Fn fetchFreeURL "struct url *u"
.Ft FILE *
.Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags"
.Ft FILE *
.Fn fetchGetURL "const char *URL" "const char *flags"
.Ft FILE *
.Fn fetchPutURL "const char *URL" "const char *flags"
.Ft int
.Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags"
.Ft struct url_ent *
.Fn fetchListURL "const char *URL" "const char *flags"
.Ft FILE *
.Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags"
.Ft FILE *
.Fn fetchGet "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchPut "struct url *u" "const char *flags"
.Ft int
.Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags"
.Ft struct url_ent *
.Fn fetchList "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags"
.Ft FILE *
.Fn fetchGetFile "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchPutFile "struct url *u" "const char *flags"
.Ft int
.Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags"
.Ft struct url_ent *
.Fn fetchListFile "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags"
.Ft FILE *
.Fn fetchGetHTTP "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchPutHTTP "struct url *u" "const char *flags"
.Ft int
.Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags"
.Ft struct url_ent *
.Fn fetchListHTTP "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags"
.Ft FILE *
.Fn fetchGetFTP "struct url *u" "const char *flags"
.Ft FILE *
.Fn fetchPutFTP "struct url *u" "const char *flags"
.Ft int
.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags"
.Ft struct url_ent *
.Fn fetchListFTP "struct url *u" "const char *flags"
.Sh DESCRIPTION
These functions implement a high-level library for retrieving and
uploading files using Uniform Resource Locators (URLs).
.Pp
.Fn fetchParseURL
takes a URL in the form of a null-terminated string and splits it into
its components function according to the Common Internet Scheme Syntax
detailed in RFC1738.
A regular expression which produces this syntax is:
.Bd -literal
<scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
.Ed
.Pp
If the URL does not seem to begin with a scheme name, the following
syntax is assumed:
.Bd -literal
((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
.Ed
.Pp
Note that some components of the URL are not necessarily relevant to
all URL schemes.
For instance, the file scheme only needs the <scheme> and <document>
components.
.Pp
.Fn fetchMakeURL
and
.Fn fetchParseURL
return a pointer to a
.Vt url
structure, which is defined as follows in
.In fetch.h :
.Bd -literal
#define URL_SCHEMELEN 16
#define URL_USERLEN 256
#define URL_PWDLEN 256
struct url {
char scheme[URL_SCHEMELEN+1];
char user[URL_USERLEN+1];
char pwd[URL_PWDLEN+1];
char host[MAXHOSTNAMELEN+1];
int port;
char *doc;
off_t offset;
size_t length;
};
.Ed
.Pp
The pointer returned by
.Fn fetchMakeURL
or
.Fn fetchParseURL
should be freed using
.Fn fetchFreeURL .
.Pp
.Fn fetchXGetURL ,
.Fn fetchGetURL ,
and
.Fn fetchPutURL
constitute the recommended interface to the
.Nm fetch
library.
They examine the URL passed to them to determine the transfer
method, and call the appropriate lower-level functions to perform the
actual transfer.
.Fn fetchXGetURL
also returns the remote document's metadata in the
.Vt url_stat
structure pointed to by the
.Fa us
argument.
.Pp
The
.Fa flags
argument is a string of characters which specify transfer options.
The
meaning of the individual flags is scheme-dependent, and is detailed
in the appropriate section below.
.Pp
.Fn fetchStatURL
attempts to obtain the requested document's metadata and fill in the
structure pointed to by its second argument.
The
.Vt url_stat
structure is defined as follows in
.In fetch.h :
.Bd -literal
struct url_stat {
off_t size;
time_t atime;
time_t mtime;
};
.Ed
.Pp
If the size could not be obtained from the server, the
.Fa size
field is set to -1.
If the modification time could not be obtained from the server, the
.Fa mtime
field is set to the epoch.
If the access time could not be obtained from the server, the
.Fa atime
field is set to the modification time.
.Pp
.Fn fetchListURL
attempts to list the contents of the directory pointed to by the URL
provided.
If successful, it returns a malloced array of
.Vt url_ent
structures.
The
.Vt url_ent
structure is defined as follows in
.In fetch.h :
.Bd -literal
struct url_ent {
char name[MAXPATHLEN];
struct url_stat stat;
};
.Ed
.Pp
The list is terminated by an entry with an empty name.
.Pp
The pointer returned by
.Fn fetchListURL
should be freed using
.Fn free .
.Pp
.Fn fetchXGet ,
.Fn fetchGet ,
.Fn fetchPut
and
.Fn fetchStat
are similar to
.Fn fetchXGetURL ,
.Fn fetchGetURL ,
.Fn fetchPutURL
and
.Fn fetchStatURL ,
except that they expect a pre-parsed URL in the form of a pointer to
a
.Vt struct url
rather than a string.
.Pp
All of the
.Fn fetchXGetXXX ,
.Fn fetchGetXXX
and
.Fn fetchPutXXX
functions return a pointer to a stream which can be used to read or
write data from or to the requested document, respectively.
Note that
although the implementation details of the individual access methods
vary, it can generally be assumed that a stream returned by one of the
.Fn fetchXGetXXX
or
.Fn fetchGetXXX
functions is read-only, and that a stream returned by one of the
.Fn fetchPutXXX
functions is write-only.
.Sh FILE SCHEME
.Fn fetchXGetFile ,
.Fn fetchGetFile
and
.Fn fetchPutFile
provide access to documents which are files in a locally mounted file
system.
Only the <document> component of the URL is used.
.Pp
.Fn fetchXGetFile
and
.Fn fetchGetFile
do not accept any flags.
.Pp
.Fn fetchPutFile
accepts the
.Ql a
(append to file) flag.
If that flag is specified, the data written to
the stream returned by
.Fn fetchPutFile
will be appended to the previous contents of the file, instead of
replacing them.
.Sh FTP SCHEME
.Fn fetchXGetFTP ,
.Fn fetchGetFTP
and
.Fn fetchPutFTP
implement the FTP protocol as described in RFC959.
.Pp
If the
.Ql p
(passive) flag is specified, a passive (rather than active) connection
will be attempted.
.Pp
If the
.Ql l
(low) flag is specified, data sockets will be allocated in the low (or
default) port range instead of the high port range (see
.Xr ip 4 ) .
.Pp
If the
.Ql d
(direct) flag is specified,
.Fn fetchXGetFTP ,
.Fn fetchGetFTP
and
.Fn fetchPutFTP
will use a direct connection even if a proxy server is defined.
.Pp
If no user name or password is given, the
.Nm fetch
library will attempt an anonymous login, with user name "anonymous"
and password "anonymous@<hostname>".
.Sh HTTP SCHEME
The
.Fn fetchXGetHTTP ,
.Fn fetchGetHTTP
and
.Fn fetchPutHTTP
functions implement the HTTP/1.1 protocol.
With a little luck, there is
even a chance that they comply with RFC2616 and RFC2617.
.Pp
If the
.Ql d
(direct) flag is specified,
.Fn fetchXGetHTTP ,
.Fn fetchGetHTTP
and
.Fn fetchPutHTTP
will use a direct connection even if a proxy server is defined.
.Pp
Since there seems to be no good way of implementing the HTTP PUT
method in a manner consistent with the rest of the
.Nm fetch
library,
.Fn fetchPutHTTP
is currently unimplemented.
.Sh AUTHENTICATION
Apart from setting the appropriate environment variables and
specifying the user name and password in the URL or the
.Vt struct url ,
the calling program has the option of defining an authentication
function with the following prototype:
.Pp
.Ft int
.Fn myAuthMethod "struct url *u"
.Pp
The callback function should fill in the
.Fa user
and
.Fa pwd
fields in the provided
.Vt struct url
and return 0 on success, or any other value to indicate failure.
.Pp
To register the authentication callback, simply set
.Va fetchAuthMethod
to point at it.
The callback will be used whenever a site requires authentication and
the appropriate environment variables are not set.
.Pp
This interface is experimental and may be subject to change.
.Sh RETURN VALUES
.Fn fetchParseURL
returns a pointer to a
.Vt struct url
containing the individual components of the URL.
If it is
unable to allocate memory, or the URL is syntactically incorrect,
.Fn fetchParseURL
returns a NULL pointer.
.Pp
The
.Fn fetchStat
functions return 0 on success and -1 on failure.
.Pp
All other functions return a stream pointer which may be used to
access the requested document, or NULL if an error occurred.
.Pp
The following error codes are defined in
.In fetch.h :
.Bl -tag -width 18n
.It Bq Er FETCH_ABORT
Operation aborted
.It Bq Er FETCH_AUTH
Authentication failed
.It Bq Er FETCH_DOWN
Service unavailable
.It Bq Er FETCH_EXISTS
File exists
.It Bq Er FETCH_FULL
File system full
.It Bq Er FETCH_INFO
Informational response
.It Bq Er FETCH_MEMORY
Insufficient memory
.It Bq Er FETCH_MOVED
File has moved
.It Bq Er FETCH_NETWORK
Network error
.It Bq Er FETCH_OK
No error
.It Bq Er FETCH_PROTO
Protocol error
.It Bq Er FETCH_RESOLV
Resolver error
.It Bq Er FETCH_SERVER
Server error
.It Bq Er FETCH_TEMP
Temporary error
.It Bq Er FETCH_TIMEOUT
Operation timed out
.It Bq Er FETCH_UNAVAIL
File is not available
.It Bq Er FETCH_UNKNOWN
Unknown error
.It Bq Er FETCH_URL
Invalid URL
.El
.Pp
The accompanying error message includes a protocol-specific error code
and message, e.g.\& "File is not available (404 Not Found)"
.Sh ENVIRONMENT
.Bl -tag -width ".Ev FETCH_BIND_ADDRESS"
.It Ev FETCH_BIND_ADDRESS
Specifies a hostname or IP address to which sockets used for outgoing
connections will be bound.
.It Ev FTP_LOGIN
Default FTP login if none was provided in the URL.
.It Ev FTP_PASSIVE_MODE
If set to anything but
.Ql no ,
forces the FTP code to use passive mode.
.It Ev FTP_PASSWORD
Default FTP password if the remote server requests one and none was
provided in the URL.
.It Ev FTP_PROXY
URL of the proxy to use for FTP requests.
The document part is ignored.
FTP and HTTP proxies are supported; if no scheme is specified, FTP is
assumed.
If the proxy is an FTP proxy,
.Nm libfetch
will send
.Ql user@host
as user name to the proxy, where
.Ql user
is the real user name, and
.Ql host
is the name of the FTP server.
.Pp
If this variable is set to an empty string, no proxy will be used for
FTP requests, even if the
.Ev HTTP_PROXY
variable is set.
.It Ev ftp_proxy
Same as
.Ev FTP_PROXY ,
for compatibility.
.It Ev HTTP_AUTH
Specifies HTTP authorization parameters as a colon-separated list of
items.
The first and second item are the authorization scheme and realm
respectively; further items are scheme-dependent.
Currently, only basic authorization is supported.
.Pp
Basic authorization requires two parameters: the user name and
password, in that order.
.Pp
This variable is only used if the server requires authorization and
no user name or password was specified in the URL.
.It Ev HTTP_PROXY
URL of the proxy to use for HTTP requests.
The document part is ignored.
Only HTTP proxies are supported for HTTP requests.
If no port number is specified, the default is 3128.
.Pp
Note that this proxy will also be used for FTP documents, unless the
.Ev FTP_PROXY
variable is set.
.It Ev http_proxy
Same as
.Ev HTTP_PROXY ,
for compatibility.
.It Ev HTTP_PROXY_AUTH
Specifies authorization parameters for the HTTP proxy in the same
format as the
.Ev HTTP_AUTH
variable.
.Pp
This variable is used if and only if connected to an HTTP proxy, and
is ignored if a user and/or a password were specified in the proxy
URL.
.It Ev HTTP_REFERER
Specifies the referrer URL to use for HTTP requests.
If set to
.Dq auto ,
the document URL will be used as referrer URL.
.It Ev HTTP_USER_AGENT
Specifies the User-Agent string to use for HTTP requests.
This can be useful when working with HTTP origin or proxy servers that
differentiate between user agents.
.It Ev NETRC
Specifies a file to use instead of
.Pa ~/.netrc
to look up login names and passwords for FTP sites.
See
.Xr ftp 1
for a description of the file format.
This feature is experimental.
.El
.Sh EXAMPLES
To access a proxy server on
.Pa proxy.example.com
port 8080, set the
.Ev HTTP_PROXY
environment variable in a manner similar to this:
.Pp
.Dl HTTP_PROXY=http://proxy.example.com:8080
.Pp
If the proxy server requires authentication, there are
two options available for passing the authentication data.
The first method is by using the proxy URL:
.Pp
.Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080
.Pp
The second method is by using the
.Ev HTTP_PROXY_AUTH
environment variable:
.Bd -literal -offset indent
HTTP_PROXY=http://proxy.example.com:8080
HTTP_PROXY_AUTH=basic:*:<user>:<pwd>
.Ed
.Sh SEE ALSO
.Xr fetch 1 ,
.Xr ftpio 3 ,
.Xr ip 4
.Rs
.%A J. Postel
.%A J. K. Reynolds
.%D October 1985
.%B File Transfer Protocol
.%O RFC959
.Re
.Rs
.%A P. Deutsch
.%A A. Emtage
.%A A. Marine.
.%D May 1994
.%T How to Use Anonymous FTP
.%O RFC1635
.Re
.Rs
.%A T. Berners-Lee
.%A L. Masinter
.%A M. McCahill
.%D December 1994
.%T Uniform Resource Locators (URL)
.%O RFC1738
.Re
.Rs
.%A R. Fielding
.%A J. Gettys
.%A J. Mogul
.%A H. Frystyk
.%A L. Masinter
.%A P. Leach
.%A T. Berners-Lee
.%D January 1999
.%B Hypertext Transfer Protocol -- HTTP/1.1
.%O RFC2616
.Re
.Rs
.%A J. Franks
.%A P. Hallam-Baker
.%A J. Hostetler
.%A S. Lawrence
.%A P. Leach
.%A A. Luotonen
.%A L. Stewart
.%D June 1999
.%B HTTP Authentication: Basic and Digest Access Authentication
.%O RFC2617
.Re
.Sh HISTORY
The
.Nm fetch
library first appeared in
.Fx 3.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm fetch
library was mostly written by
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
with numerous suggestions from
.An Jordan K. Hubbard Aq jkh@FreeBSD.org ,
.An Eugene Skepner Aq eu@qub.com
and other
.Fx
developers.
It replaces the older
.Nm ftpio
library written by
.An Poul-Henning Kamp Aq phk@FreeBSD.org
and
.An Jordan K. Hubbard Aq jkh@FreeBSD.org .
.Pp
This manual page was written by
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
.Sh BUGS
Some parts of the library are not yet implemented.
The most notable
examples of this are
.Fn fetchPutHTTP ,
.Fn fetchListHTTP ,
.Fn fetchListFTP
and FTP proxy support.
.Pp
There is no way to select a proxy at run-time other than setting the
.Ev HTTP_PROXY
or
.Ev FTP_PROXY
environment variables as appropriate.
.Pp
.Nm libfetch
does not understand or obey 305 (Use Proxy) replies.
.Pp
Error numbers are unique only within a certain context; the error
codes used for FTP and HTTP overlap, as do those used for resolver and
system errors.
For instance, error code 202 means "Command not
implemented, superfluous at this site" in an FTP context and
"Accepted" in an HTTP context.
.Pp
.Fn fetchStatFTP
does not check that the result of an MDTM command is a valid date.
.Pp
The man page is incomplete, poorly written and produces badly
formatted text.
.Pp
The error reporting mechanism is unsatisfactory.
.Pp
Some parts of the code are not fully reentrant.

View file

@ -1,437 +0,0 @@
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fetch.h"
#include "common.h"
auth_t fetchAuthMethod;
int fetchLastErrCode;
char fetchLastErrString[MAXERRSTRING];
int fetchTimeout;
int fetchRestartCalls = 1;
int fetchDebug;
/*** Local data **************************************************************/
/*
* Error messages for parser errors
*/
#define URL_MALFORMED 1
#define URL_BAD_SCHEME 2
#define URL_BAD_PORT 3
static struct fetcherr _url_errlist[] = {
{ URL_MALFORMED, FETCH_URL, "Malformed URL" },
{ URL_BAD_SCHEME, FETCH_URL, "Invalid URL scheme" },
{ URL_BAD_PORT, FETCH_URL, "Invalid server port" },
{ -1, FETCH_UNKNOWN, "Unknown parser error" }
};
/*** Public API **************************************************************/
/*
* Select the appropriate protocol for the URL scheme, and return a
* read-only stream connected to the document referenced by the URL.
* Also fill out the struct url_stat.
*/
FILE *
fetchXGet(struct url *URL, struct url_stat *us, const char *flags)
{
int direct;
direct = CHECK_FLAG('d');
if (us != NULL) {
us->size = -1;
us->atime = us->mtime = 0;
}
if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
return (fetchXGetFile(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
return (fetchXGetFTP(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
return (fetchXGetHTTP(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
return (fetchXGetHTTP(URL, us, flags));
_url_seterr(URL_BAD_SCHEME);
return (NULL);
}
/*
* Select the appropriate protocol for the URL scheme, and return a
* read-only stream connected to the document referenced by the URL.
*/
FILE *
fetchGet(struct url *URL, const char *flags)
{
return (fetchXGet(URL, NULL, flags));
}
/*
* Select the appropriate protocol for the URL scheme, and return a
* write-only stream connected to the document referenced by the URL.
*/
FILE *
fetchPut(struct url *URL, const char *flags)
{
int direct;
direct = CHECK_FLAG('d');
if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
return (fetchPutFile(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
return (fetchPutFTP(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
return (fetchPutHTTP(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
return (fetchPutHTTP(URL, flags));
_url_seterr(URL_BAD_SCHEME);
return (NULL);
}
/*
* Select the appropriate protocol for the URL scheme, and return the
* size of the document referenced by the URL if it exists.
*/
int
fetchStat(struct url *URL, struct url_stat *us, const char *flags)
{
int direct;
direct = CHECK_FLAG('d');
if (us != NULL) {
us->size = -1;
us->atime = us->mtime = 0;
}
if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
return (fetchStatFile(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
return (fetchStatFTP(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
return (fetchStatHTTP(URL, us, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
return (fetchStatHTTP(URL, us, flags));
_url_seterr(URL_BAD_SCHEME);
return (-1);
}
/*
* Select the appropriate protocol for the URL scheme, and return a
* list of files in the directory pointed to by the URL.
*/
struct url_ent *
fetchList(struct url *URL, const char *flags)
{
int direct;
direct = CHECK_FLAG('d');
if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
return (fetchListFile(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
return (fetchListFTP(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
return (fetchListHTTP(URL, flags));
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
return (fetchListHTTP(URL, flags));
_url_seterr(URL_BAD_SCHEME);
return (NULL);
}
/*
* Attempt to parse the given URL; if successful, call fetchXGet().
*/
FILE *
fetchXGetURL(const char *URL, struct url_stat *us, const char *flags)
{
struct url *u;
FILE *f;
if ((u = fetchParseURL(URL)) == NULL)
return (NULL);
f = fetchXGet(u, us, flags);
fetchFreeURL(u);
return (f);
}
/*
* Attempt to parse the given URL; if successful, call fetchGet().
*/
FILE *
fetchGetURL(const char *URL, const char *flags)
{
return (fetchXGetURL(URL, NULL, flags));
}
/*
* Attempt to parse the given URL; if successful, call fetchPut().
*/
FILE *
fetchPutURL(const char *URL, const char *flags)
{
struct url *u;
FILE *f;
if ((u = fetchParseURL(URL)) == NULL)
return (NULL);
f = fetchPut(u, flags);
fetchFreeURL(u);
return (f);
}
/*
* Attempt to parse the given URL; if successful, call fetchStat().
*/
int
fetchStatURL(const char *URL, struct url_stat *us, const char *flags)
{
struct url *u;
int s;
if ((u = fetchParseURL(URL)) == NULL)
return (-1);
s = fetchStat(u, us, flags);
fetchFreeURL(u);
return (s);
}
/*
* Attempt to parse the given URL; if successful, call fetchList().
*/
struct url_ent *
fetchListURL(const char *URL, const char *flags)
{
struct url *u;
struct url_ent *ue;
if ((u = fetchParseURL(URL)) == NULL)
return (NULL);
ue = fetchList(u, flags);
fetchFreeURL(u);
return (ue);
}
/*
* Make a URL
*/
struct url *
fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
const char *user, const char *pwd)
{
struct url *u;
if (!scheme || (!host && !doc)) {
_url_seterr(URL_MALFORMED);
return (NULL);
}
if (port < 0 || port > 65535) {
_url_seterr(URL_BAD_PORT);
return (NULL);
}
/* allocate struct url */
if ((u = calloc(1, sizeof(*u))) == NULL) {
_fetch_syserr();
return (NULL);
}
if ((u->doc = strdup(doc ? doc : "/")) == NULL) {
_fetch_syserr();
free(u);
return (NULL);
}
#define seturl(x) snprintf(u->x, sizeof(u->x), "%s", x)
seturl(scheme);
seturl(host);
seturl(user);
seturl(pwd);
#undef seturl
u->port = port;
return (u);
}
/*
* Split an URL into components. URL syntax is:
* [method:/][/[user[:pwd]@]host[:port]/][document]
* This almost, but not quite, RFC1738 URL syntax.
*/
struct url *
fetchParseURL(const char *URL)
{
char *doc;
const char *p, *q;
struct url *u;
int i;
/* allocate struct url */
if ((u = calloc(1, sizeof(*u))) == NULL) {
_fetch_syserr();
return (NULL);
}
/* scheme name */
if ((p = strstr(URL, ":/"))) {
snprintf(u->scheme, URL_SCHEMELEN+1,
"%.*s", (int)(p - URL), URL);
URL = ++p;
/*
* Only one slash: no host, leave slash as part of document
* Two slashes: host follows, strip slashes
*/
if (URL[1] == '/')
URL = (p += 2);
} else {
p = URL;
}
if (!*URL || *URL == '/' || *URL == '.' ||
(u->scheme[0] == '\0' &&
strchr(URL, '/') == NULL && strchr(URL, ':') == NULL))
goto nohost;
p = strpbrk(URL, "/@");
if (p && *p == '@') {
/* username */
for (q = URL, i = 0; (*q != ':') && (*q != '@'); q++)
if (i < URL_USERLEN)
u->user[i++] = *q;
/* password */
if (*q == ':')
for (q++, i = 0; (*q != ':') && (*q != '@'); q++)
if (i < URL_PWDLEN)
u->pwd[i++] = *q;
p++;
} else {
p = URL;
}
/* hostname */
#ifdef INET6
if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&
(*++q == '\0' || *q == '/' || *q == ':')) {
if ((i = q - p - 2) > MAXHOSTNAMELEN)
i = MAXHOSTNAMELEN;
strncpy(u->host, ++p, i);
p = q;
} else
#endif
for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
if (i < MAXHOSTNAMELEN)
u->host[i++] = *p;
/* port */
if (*p == ':') {
for (q = ++p; *q && (*q != '/'); q++)
if (isdigit(*q))
u->port = u->port * 10 + (*q - '0');
else {
/* invalid port */
_url_seterr(URL_BAD_PORT);
goto ouch;
}
p = q;
}
nohost:
/* document */
if (!*p)
p = "/";
if (strcasecmp(u->scheme, SCHEME_HTTP) == 0 ||
strcasecmp(u->scheme, SCHEME_HTTPS) == 0) {
const char hexnums[] = "0123456789abcdef";
/* percent-escape whitespace. */
if ((doc = malloc(strlen(p) * 3 + 1)) == NULL) {
_fetch_syserr();
goto ouch;
}
u->doc = doc;
while (*p != '\0') {
if (!isspace(*p)) {
*doc++ = *p++;
} else {
*doc++ = '%';
*doc++ = hexnums[((unsigned int)*p) >> 4];
*doc++ = hexnums[((unsigned int)*p) & 0xf];
p++;
}
}
*doc = '\0';
} else if ((u->doc = strdup(p)) == NULL) {
_fetch_syserr();
goto ouch;
}
DEBUG(fprintf(stderr,
"scheme: [%s]\n"
"user: [%s]\n"
"password: [%s]\n"
"host: [%s]\n"
"port: [%d]\n"
"document: [%s]\n",
u->scheme, u->user, u->pwd,
u->host, u->port, u->doc));
return (u);
ouch:
free(u);
return (NULL);
}
/*
* Free a URL
*/
void
fetchFreeURL(struct url *u)
{
free(u->doc);
free(u);
}

View file

@ -1,153 +0,0 @@
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: /repoman/r/ncvs/src/lib/libfetch/fetch.h,v 1.26 2004/09/21 18:35:20 des Exp $
*/
#ifndef _FETCH_H_INCLUDED
#define _FETCH_H_INCLUDED
#include <stdio.h>
#include <sys/param.h> /* MAXHOSTNAMELEN */
#define _LIBFETCH_VER "libfetch/2.0"
#define URL_SCHEMELEN 16
#define URL_USERLEN 256
#define URL_PWDLEN 256
struct url {
char scheme[URL_SCHEMELEN+1];
char user[URL_USERLEN+1];
char pwd[URL_PWDLEN+1];
char host[MAXHOSTNAMELEN+1];
int port;
char *doc;
off_t offset;
size_t length;
};
struct url_stat {
off_t size;
time_t atime;
time_t mtime;
};
struct url_ent {
char name[PATH_MAX];
struct url_stat stat;
};
/* Recognized schemes */
#define SCHEME_FTP "ftp"
#define SCHEME_HTTP "http"
#define SCHEME_HTTPS "https"
#define SCHEME_FILE "file"
/* Error codes */
#define FETCH_ABORT 1
#define FETCH_AUTH 2
#define FETCH_DOWN 3
#define FETCH_EXISTS 4
#define FETCH_FULL 5
#define FETCH_INFO 6
#define FETCH_MEMORY 7
#define FETCH_MOVED 8
#define FETCH_NETWORK 9
#define FETCH_OK 10
#define FETCH_PROTO 11
#define FETCH_RESOLV 12
#define FETCH_SERVER 13
#define FETCH_TEMP 14
#define FETCH_TIMEOUT 15
#define FETCH_UNAVAIL 16
#define FETCH_UNKNOWN 17
#define FETCH_URL 18
#define FETCH_VERBOSE 19
__BEGIN_DECLS
/* FILE-specific functions */
FILE *fetchXGetFile(struct url *, struct url_stat *, const char *);
FILE *fetchGetFile(struct url *, const char *);
FILE *fetchPutFile(struct url *, const char *);
int fetchStatFile(struct url *, struct url_stat *, const char *);
struct url_ent *fetchListFile(struct url *, const char *);
/* HTTP-specific functions */
FILE *fetchXGetHTTP(struct url *, struct url_stat *, const char *);
FILE *fetchGetHTTP(struct url *, const char *);
FILE *fetchPutHTTP(struct url *, const char *);
int fetchStatHTTP(struct url *, struct url_stat *, const char *);
struct url_ent *fetchListHTTP(struct url *, const char *);
/* FTP-specific functions */
FILE *fetchXGetFTP(struct url *, struct url_stat *, const char *);
FILE *fetchGetFTP(struct url *, const char *);
FILE *fetchPutFTP(struct url *, const char *);
int fetchStatFTP(struct url *, struct url_stat *, const char *);
struct url_ent *fetchListFTP(struct url *, const char *);
/* Generic functions */
FILE *fetchXGetURL(const char *, struct url_stat *, const char *);
FILE *fetchGetURL(const char *, const char *);
FILE *fetchPutURL(const char *, const char *);
int fetchStatURL(const char *, struct url_stat *, const char *);
struct url_ent *fetchListURL(const char *, const char *);
FILE *fetchXGet(struct url *, struct url_stat *, const char *);
FILE *fetchGet(struct url *, const char *);
FILE *fetchPut(struct url *, const char *);
int fetchStat(struct url *, struct url_stat *, const char *);
struct url_ent *fetchList(struct url *, const char *);
/* URL parsing */
struct url *fetchMakeURL(const char *, const char *, int,
const char *, const char *, const char *);
struct url *fetchParseURL(const char *);
void fetchFreeURL(struct url *);
__END_DECLS
/* Authentication */
typedef int (*auth_t)(struct url *);
extern auth_t fetchAuthMethod;
/* Last error code */
extern int fetchLastErrCode;
#define MAXERRSTRING 256
extern char fetchLastErrString[MAXERRSTRING];
/* I/O timeout */
extern int fetchTimeout;
/* Restart interrupted syscalls */
extern int fetchRestartCalls;
/* Extra verbosity */
extern int fetchDebug;
#endif

View file

@ -1,145 +0,0 @@
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include "fetch.h"
#include "common.h"
FILE *
fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
{
FILE *f;
if (us && fetchStatFile(u, us, flags) == -1)
return (NULL);
f = fopen(u->doc, "r");
if (f == NULL)
_fetch_syserr();
if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
fclose(f);
_fetch_syserr();
}
return (f);
}
FILE *
fetchGetFile(struct url *u, const char *flags)
{
return (fetchXGetFile(u, NULL, flags));
}
FILE *
fetchPutFile(struct url *u, const char *flags)
{
FILE *f;
if (CHECK_FLAG('a'))
f = fopen(u->doc, "a");
else
f = fopen(u->doc, "w+");
if (f == NULL)
_fetch_syserr();
if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
fclose(f);
_fetch_syserr();
}
return (f);
}
static int
_fetch_stat_file(const char *fn, struct url_stat *us)
{
struct stat sb;
us->size = -1;
us->atime = us->mtime = 0;
if (stat(fn, &sb) == -1) {
_fetch_syserr();
return (-1);
}
us->size = sb.st_size;
us->atime = sb.st_atime;
us->mtime = sb.st_mtime;
return (0);
}
int
fetchStatFile(struct url *u, struct url_stat *us, const char *flags)
{
return (_fetch_stat_file(u->doc, us));
}
struct url_ent *
fetchListFile(struct url *u, const char *flags)
{
struct dirent *de;
struct url_stat us;
struct url_ent *ue;
int size, len;
char fn[PATH_MAX], *p;
DIR *dir;
int l;
if ((dir = opendir(u->doc)) == NULL) {
_fetch_syserr();
return (NULL);
}
ue = NULL;
strncpy(fn, u->doc, sizeof(fn) - 2);
fn[sizeof(fn) - 2] = 0;
strcat(fn, "/");
p = strchr(fn, 0);
l = sizeof(fn) - strlen(fn) - 1;
while ((de = readdir(dir)) != NULL) {
strncpy(p, de->d_name, l - 1);
p[l - 1] = 0;
if (_fetch_stat_file(fn, &us) == -1)
/* should I return a partial result, or abort? */
break;
_fetch_add_entry(&ue, &size, &len, de->d_name, &us);
}
return (ue);
}

File diff suppressed because it is too large Load diff

View file

@ -1,47 +0,0 @@
# $FreeBSD: /repoman/r/ncvs/src/lib/libfetch/ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $
#
# This list is taken from RFC 959.
# It probably needs a going over.
#
110 OK Restart marker reply
120 TEMP Service ready in a few minutes
125 OK Data connection already open; transfer starting
150 OK File status okay; about to open data connection
200 OK Command okay
202 PROTO Command not implemented, superfluous at this site
211 INFO System status, or system help reply
212 INFO Directory status
213 INFO File status
214 INFO Help message
215 INFO Set system type
220 OK Service ready for new user
221 OK Service closing control connection
225 OK Data connection open; no transfer in progress
226 OK Requested file action successful
227 OK Entering Passive Mode
229 OK Entering Extended Passive Mode
230 OK User logged in, proceed
250 OK Requested file action okay, completed
257 OK File/directory created
331 AUTH User name okay, need password
332 AUTH Need account for login
350 OK Requested file action pending further information
421 DOWN Service not available, closing control connection
425 NETWORK Can't open data connection
426 ABORT Connection closed; transfer aborted
450 UNAVAIL File unavailable (e.g., file busy)
451 SERVER Requested action aborted: local error in processing
452 FULL Insufficient storage space in system
500 PROTO Syntax error, command unrecognized
501 PROTO Syntax error in parameters or arguments
502 PROTO Command not implemented
503 PROTO Bad sequence of commands
504 PROTO Command not implemented for that parameter
530 AUTH Not logged in
532 AUTH Need account for storing files
535 PROTO Bug in MediaHawk Video Kernel FTP server
550 UNAVAIL File unavailable (e.g., file not found, no access)
551 PROTO Requested action aborted. Page type unknown
552 FULL Exceeded storage allocation
553 EXISTS File name not allowed
999 PROTO Protocol error

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
# $FreeBSD: /repoman/r/ncvs/src/lib/libfetch/http.errors,v 1.5 2001/05/23 18:52:02 des Exp $
#
# This list is taken from RFC 2068.
#
100 OK Continue
101 OK Switching Protocols
200 OK OK
201 OK Created
202 OK Accepted
203 INFO Non-Authoritative Information
204 OK No Content
205 OK Reset Content
206 OK Partial Content
300 MOVED Multiple Choices
301 MOVED Moved Permanently
302 MOVED Moved Temporarily
303 MOVED See Other
304 OK Not Modified
305 INFO Use Proxy
307 MOVED Temporary Redirect
400 PROTO Bad Request
401 AUTH Unauthorized
402 AUTH Payment Required
403 AUTH Forbidden
404 UNAVAIL Not Found
405 PROTO Method Not Allowed
406 PROTO Not Acceptable
407 AUTH Proxy Authentication Required
408 TIMEOUT Request Time-out
409 EXISTS Conflict
410 UNAVAIL Gone
411 PROTO Length Required
412 SERVER Precondition Failed
413 PROTO Request Entity Too Large
414 PROTO Request-URI Too Large
415 PROTO Unsupported Media Type
416 UNAVAIL Requested Range Not Satisfiable
417 SERVER Expectation Failed
500 SERVER Internal Server Error
501 PROTO Not Implemented
502 SERVER Bad Gateway
503 TEMP Service Unavailable
504 TIMEOUT Gateway Time-out
505 PROTO HTTP Version not supported
999 PROTO Protocol error

View file

@ -1,6 +0,0 @@
.deps
.libs
Makefile
Makefile.in
*.lo
*.la

View file

@ -1,17 +0,0 @@
AUTOMAKE_OPTIONS = gnu
DEFINES = -DFTPLIB_DEFMODE=FTPLIB_PORT -D_REENTRANT
AM_CFLAGS = $(DEFINES)
#SOMAJOR = 3
#SOMINOR = 1
#SOMICRO = 1
#SOVER = `expr $(SOMAJOR) + $(SOMINOR)`:$(SOMICRO):$(SOMINOR)
noinst_LTLIBRARIES = libftp.la
#lib_LTLIBRARIES = libftp.la
libftp_la_SOURCES = \
ftplib.h \
ftplib.c
#libftp_la_LDFLAGS = -L. -version-info $(SOVER)

File diff suppressed because it is too large Load diff

View file

@ -1,132 +0,0 @@
/***************************************************************************/
/* */
/* ftplib.h - header file for callable ftp access routines */
/* Copyright (C) 1996, 1997 Thomas Pfau, pfau@cnj.digex.net */
/* 73 Catherine Street, South Bound Brook, NJ, 08880 */
/* */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public */
/* License as published by the Free Software Foundation; either */
/* version 2 of the License, or (at your option) any later version. */
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Library General Public License for more details. */
/* */
/* You should have received a copy of the GNU Library General Public */
/* License along with this progam; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/* */
/***************************************************************************/
#if !defined(__FTPLIB_H)
#define __FTPLIB_H
#if defined(__unix__) || defined(VMS) || defined(__APPLE__)
#define GLOBALDEF
#define GLOBALREF extern
#elif defined(_WIN32)
#if defined BUILDING_LIBRARY
#define GLOBALDEF __declspec(dllexport)
#define GLOBALREF __declspec(dllexport)
#else
#define GLOBALREF __declspec(dllimport)
#endif
#endif
/* FtpAccess() type codes */
#define FTPLIB_DIR 1
#define FTPLIB_DIR_VERBOSE 2
#define FTPLIB_FILE_READ 3
#define FTPLIB_FILE_WRITE 4
/* FtpAccess() mode codes */
#define FTPLIB_ASCII 'A'
#define FTPLIB_IMAGE 'I'
#define FTPLIB_TEXT FTPLIB_ASCII
#define FTPLIB_BINARY FTPLIB_IMAGE
/* connection modes */
#define FTPLIB_PASSIVE 1
#define FTPLIB_PORT 2
/* connection option names */
#define FTPLIB_CONNMODE 1
#define FTPLIB_CALLBACK 2
#define FTPLIB_IDLETIME 3
#define FTPLIB_CALLBACKARG 4
#define FTPLIB_CALLBACKBYTES 5
#ifdef __cplusplus
extern "C" {
#endif
typedef struct NetBuf netbuf;
typedef int (*FtpCallback)(netbuf *nControl, int xfered, void *arg);
/* v1 compatibility stuff */
#if !defined(_FTPLIB_NO_COMPAT)
netbuf *DefaultNetbuf;
#define ftplib_lastresp FtpLastResponse(DefaultNetbuf)
#define ftpInit FtpInit
#define ftpOpen(x) FtpConnect(x, &DefaultNetbuf)
#define ftpLogin(x,y) FtpLogin(x, y, DefaultNetbuf)
#define ftpSite(x) FtpSite(x, DefaultNetbuf)
#define ftpMkdir(x) FtpMkdir(x, DefaultNetbuf)
#define ftpChdir(x) FtpChdir(x, DefaultNetbuf)
#define ftpRmdir(x) FtpRmdir(x, DefaultNetbuf)
#define ftpNlst(x, y) FtpNlst(x, y, DefaultNetbuf)
#define ftpDir(x, y) FtpDir(x, y, DefaultNetbuf)
#define ftpGet(x, y, z) FtpGet(x, y, z, DefaultNetbuf)
#define ftpPut(x, y, z) FtpPut(x, y, z, DefaultNetbuf)
#define ftpRename(x, y) FtpRename(x, y, DefaultNetbuf)
#define ftpDelete(x) FtpDelete(x, DefaultNetbuf)
#define ftpQuit() FtpQuit(DefaultNetbuf)
#endif /* (_FTPLIB_NO_COMPAT) */
/* end v1 compatibility stuff */
GLOBALREF int ftplib_debug;
GLOBALREF void FtpInit(void);
GLOBALREF char *FtpLastResponse(netbuf *nControl);
GLOBALREF int FtpConnect(const char *host, netbuf **nControl);
GLOBALREF int FtpOptions(int opt, long val, netbuf *nControl);
GLOBALREF int FtpLogin(const char *user, const char *pass, netbuf *nControl);
GLOBALREF int FtpAccess(const char *path, int typ, int mode, netbuf *nControl,
netbuf **nData);
GLOBALREF int FtpRead(void *buf, int max, netbuf *nData);
GLOBALREF int FtpWrite(void *buf, int len, netbuf *nData);
GLOBALREF int FtpClose(netbuf *nData);
GLOBALREF int FtpSite(const char *cmd, netbuf *nControl);
GLOBALREF int FtpSysType(char *buf, int max, netbuf *nControl);
GLOBALREF int FtpMkdir(const char *path, netbuf *nControl);
GLOBALREF int FtpChdir(const char *path, netbuf *nControl);
GLOBALREF int FtpCDUp(netbuf *nControl);
GLOBALREF int FtpRmdir(const char *path, netbuf *nControl);
GLOBALREF int FtpPwd(char *path, int max, netbuf *nControl);
GLOBALREF int FtpNlst(const char *output, const char *path, netbuf *nControl);
GLOBALREF int FtpDir(const char *output, const char *path, netbuf *nControl);
GLOBALREF int FtpSize(const char *path, int *size, char mode, netbuf *nControl);
GLOBALREF int FtpRestart(int offset, netbuf *nControl);
GLOBALREF int FtpModDate(const char *path, char *dt, int max, netbuf *nControl);
GLOBALREF int FtpGet(const char *output, const char *path, char mode,
netbuf *nControl);
GLOBALREF int FtpPut(const char *input, const char *path, char mode,
netbuf *nControl);
GLOBALREF int FtpRename(const char *src, const char *dst, netbuf *nControl);
GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl);
GLOBALREF void FtpQuit(netbuf *nControl);
GLOBALREF int HttpConnect(const char *host, unsigned short port, netbuf **nControl);
GLOBALREF int HttpGet(const char *host, const char *output, const char *path,
int *size, netbuf *nControl, unsigned int offset,
const struct tm *mtime1, struct tm *mtime2);
GLOBALREF void HttpQuit(netbuf *nControl);
#ifdef __cplusplus
};
#endif
#endif /* __FTPLIB_H */

View file

@ -3,7 +3,11 @@
# makepkg
#
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
# Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
# Copyright (c) 2006 by Alex Smith <alex@alex-smith.me.uk>
# Copyright (c) 2006 by Andras Voroskoi <voroskoi@frugalware.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -27,15 +31,15 @@ PKGDEST=$startdir
USE_COLOR="n"
# Options
BUILDSCRIPT="./PKGBUILD"
CLEANUP=0
CLEANCACHE=0
DEP_BIN=0
DEP_SRC=0
DEP_SUDO=0
FORCE=0
GENMD5=0
GENINTEG=0
INSTALL=0
DOWNLOAD=""
KEEPDOCS=0
NOBUILD=0
NOCCACHE=0
@ -43,15 +47,10 @@ NODEPS=0
NOEXTRACT=0
NOSTRIP=0
RMDEPS=0
LOGGING=0
PACMAN_OPTS=
# source Arch's abs.conf if it's present
[ -f /etc/abs/abs.conf ] && source /etc/abs/abs.conf
# makepkg configuration
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
INFAKEROOT=
if [ "$1" = "-F" ]; then
INFAKEROOT=1
@ -74,6 +73,15 @@ msg() {
echo "==> $1" >&2
fi
}
msg2() {
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
echo -e " \033[1;34m->\033[1;0m \033[1;1m$1\033[1;0m" >&2
else
echo " -> $1" >&2
fi
}
warning() {
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2
@ -90,7 +98,7 @@ error() {
}
strip_url() {
echo $1 | sed 's|^.*://.*/||g'
echo "$1" | sed 's|^.*://.*/||g'
}
check_option() {
@ -105,6 +113,16 @@ check_option() {
done
}
in_array() {
needle=$1
shift 1
[ -z "$1" ] && return 1
for i in $*; do
[ "$i" == "$needle" ] && return 0
done
return 1
}
checkdeps() {
local missdep=""
local deplist=""
@ -166,32 +184,32 @@ handledeps() {
unset FAKEROOTKEY
fi
sudo pacman $PACMAN_OPTS -D $deplist
if [ "$INFAKEROOT" = "1" ]; then
export FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
if [ "$?" = "127" ]; then
error "Failed to install missing dependencies."
exit 1
fi
if [ "$INFAKEROOT" = "1" ]; then
export FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
elif [ "$DEP_SRC" = "1" ]; then
# install missing deps by building them from source.
# we look for each package name in $ABSROOT and build it.
if [ "$ABSROOT" = "" ]; then
error "The ABSROOT environment variable is not defined."
# we look for each package name in $SRCROOT and build it.
if [ "$SRCROOT" = "" ]; then
error "Source root cannot be found - please make sure it is specified in /etc/makepkg.conf"
exit 1
fi
# TODO: handle version comparators (eg, glibc>=2.2.5)
msg "Building missing dependencies..."
for dep in $deplist; do
candidates=`find $ABSROOT -type d -name "$dep"`
candidates=$(find $SRCROOT -type d -name "$dep")
if [ "$candidates" = "" ]; then
error "Could not find \"$dep\" under $ABSROOT"
error "Could not find \"$dep\" under $SRCROOT"
exit 1
fi
success=0
for pkgdir in $candidates; do
if [ -f $pkgdir/PKGBUILD ]; then
if [ -f $pkgdir/$BUILDSCRIPT ]; then
cd $pkgdir
if [ "$RMDEPS" = "1" ]; then
makepkg -i -c -b -r -w $PKGDEST
@ -219,6 +237,16 @@ handledeps() {
fi
missingdeps=1
fi
# rerun any additional sh scripts found in /etc/profile.d/
for i in /etc/profile.d/*.sh
do
if [ -x $i ]; then
. $i &>/dev/null
fi
done
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
return $missingdeps
}
@ -235,14 +263,15 @@ usage() {
echo " -d, --nodeps Skip all dependency checks"
echo " -e, --noextract Do not extract source files (use existing src/ dir)"
echo " -f, --force Overwrite existing package"
echo " -g, --genmd5 Generate MD5sums for source files"
echo " -g, --geninteg Generate integrity checks for source files"
echo " -h, --help This help"
echo " -i, --install Install package after successful build"
echo " -j <jobs> Set MAKEFLAGS to \"-j<jobs>\" before building"
echo " -L, --log Log package build process"
echo " -m, --nocolor Disable colorized output messages"
echo " -n, --nostrip Do not strip binaries/libraries"
echo " -o, --nobuild Download and extract files only"
echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)"
echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')"
echo " -r, --rmdeps Remove installed dependencies after a successful build"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -S, --sudosync Install missing dependencies with pacman and sudo"
@ -253,12 +282,22 @@ usage() {
echo " --noconfirm Do not ask for confirmation when resolving dependencies"
echo " --noprogressbar Do not show a progress bar when downloading files"
echo
echo "If -p is not specified, makepkg will look for ./PKGBUILD"
echo "If -p is not specified, makepkg will look for './$BUILDSCRIPT'"
echo
}
ARGLIST=$@
if [ -f /etc//makepkg.conf ]; then
source /etc/makepkg.conf
else
error "/etc/makepkg.conf not found. cannot continue"
exit 1
fi
#Let's be courteous and support frugalware's extensions
[ -e /usr/lib/frugalware/fwmakepkg ] && . /usr/lib/frugalware/fwmakepkg
while [ "$#" -ne "0" ]; do
case $1 in
# pacman
@ -278,8 +317,9 @@ while [ "$#" -ne "0" ]; do
--nostrip) NOSTRIP=1 ;;
--nobuild) NOBUILD=1 ;;
--nocolor) USE_COLOR="n" ;;
--genmd5) GENMD5=1 ;;
--geninteg) GENINTEG=1 ;;
--rmdeps) RMDEPS=1 ;;
--log) LOGGING=1 ;;
--help)
usage
exit 0
@ -289,7 +329,7 @@ while [ "$#" -ne "0" ]; do
exit 1
;;
-*)
while getopts "bBcCdefghij:mnop:rsSw:-" opt; do
while getopts "bBcCdefghij:Lmnop:rsSw:-" opt; do
case $opt in
b) DEP_SRC=1 ;;
B) NOCCACHE=1 ;;
@ -298,13 +338,14 @@ while [ "$#" -ne "0" ]; do
d) NODEPS=1 ;;
e) NOEXTRACT=1 ;;
f) FORCE=1 ;;
g) GENMD5=1 ;;
g) GENINTEG=1 ;;
h)
usage
exit 0
;;
i) INSTALL=1 ;;
j) export MAKEFLAGS="-j$OPTARG" ;;
L) LOGGING=1 ;;
m) USE_COLOR="n" ;;
n) NOSTRIP=1 ;;
o) NOBUILD=1 ;;
@ -360,6 +401,8 @@ fi
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
unset replaces depends conflicts backup source install build makedepends
unset options
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
umask 0022
@ -367,29 +410,47 @@ umask 0022
if [ ! -f $BUILDSCRIPT ]; then
error "$BUILDSCRIPT does not exist."
exit 1
else
#this is fun.... we'll unset
for var in $(grep "=" $BUILDSCRIPT | sed "s|.*\(\<.*\>\)=.*|\1|g"); do
unset $var
done
fi
source $BUILDSCRIPT
# check for no-no's
if [ `echo $pkgver | grep '-'` ]; then
if [ -z "$pkgver" ]; then
error "pkgver is not allowed to be empty."
exit 1
fi
if [ -z "$pkgrel" ]; then
error "pkgrel is not allowed to be empty."
exit 1
fi
if [ $(echo $pkgver | grep '-') ]; then
error "pkgver is not allowed to contain hyphens."
exit 1
fi
if [ `echo $pkgrel | grep '-'` ]; then
if [ $(echo $pkgrel | grep '-') ]; then
error "pkgrel is not allowed to contain hyphens."
exit 1
fi
if ! in_array $CARCH ${arch[@]}; then
error "$pkgname is not available for the '$CARCH' architecture."
exit 1
fi
if [ "$install" -a ! -f "$install" ]; then
error "install scriptlet ($install) does not exist."
exit 1
fi
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT} -a "$FORCE" = "0" -a "$GENINTEG" = "0" ]; then
if [ "$INSTALL" = "1" ]; then
warning "a package has already been built, installing existing package."
echo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
echo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
exit $?
else
error "a package has already been built. (use -f to overwrite)"
@ -397,6 +458,9 @@ if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a
fi
fi
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
# Enter the fakeroot environment if necessary. This will call the makepkg script again
# as the fake root user. We detect this by passing a sentinel option (-F) to makepkg
if [ "`id -u`" != "0" ]; then
@ -498,23 +562,59 @@ for netfile in ${source[@]}; do
fi
done
if [ "$GENMD5" = "0" ]; then
if [ "$NOEXTRACT" = "1" ]; then
warning "Skipping source extraction -- using existing src/ tree"
warning "Skipping source integrity checks -- using existing src/ tree"
else
# MD5 validation
if [ ${#md5sums[@]} -ne ${#source[@]} ]; then
warning "MD5sums are missing or incomplete. Cannot verify source integrity."
#sleep 1
elif [ `type -p md5sum` ]; then
msg "Validating source files with MD5sums"
integ="$(echo $INTEGRITY_CHECK | tr A-Z a-z)"
case "$integ" in
md5) integrity_name="md5sum" ;;
sha1) integrity_name="sha1sum" ;;
*) error "Invalid integrity algorithm '$integ' specified"; exit 1;;
esac
if [ ! $(type -p $integrity_name) ]; then
error "Cannot find the $integrity_name program."
exit 1
fi
if [ "$GENINTEG" = "1" ]; then
msg "Generating ${integrity_name}s for source files"
plain ""
ct=0
newline=0
numsrc=${#source[@]}
for netfile in "${source[@]}"; do
file=`strip_url "$netfile"`
sum=$(eval "$integrity_name '$file' | cut -d' ' -f 1")
if [ $ct -eq 0 ]; then
echo -n "${integrity_name}s=("
else
echo -ne "\t "
fi
echo -n "'$sum'"
ct=$(($ct+1))
if [ $ct -eq $numsrc ]; then
echo ')'
else
echo ' \'
newline=0
fi
done
plain ""
exit 0
else #validation
integrity_sums=($(eval echo \${${integrity_name}s[@]}))
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
msg "Validating source files with ${integrity_name}s"
errors=0
idx=0
for netfile in ${source[@]}; do
file=`strip_url $netfile`
for netfile in "${source[@]}"; do
file=$(strip_url "$netfile")
echo -n " $file ... " >&2
echo "${md5sums[$idx]} $file" | md5sum -c - >/dev/null 2>&1
echo "${integrity_sums[$idx]} $file" | $integrity_name -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED" >&2
errors=1
@ -528,17 +628,16 @@ if [ "$GENMD5" = "0" ]; then
exit 1
fi
else
warning "The md5sum program is missing. Cannot verify source files!"
sleep 1
warning "Integrity checks ($INTEGRITY_CHECK) are missing or incomplete."
fi
# extract sources
msg "Extracting Sources..."
for netfile in ${source[@]}; do
for netfile in "${source[@]}"; do
unziphack=0
file=`strip_url $netfile`
file=`strip_url "$netfile"`
unset cmd
case $file in
*.tar.gz|*.tar.Z|*.tgz)
case "`echo $file |tr "A-Z" "a-z"`" in
*.tar.gz|*.tar.z|*.tgz)
cmd="tar --use-compress-program=gzip -xf $file" ;;
*.tar.bz2|*.tbz2)
cmd="tar --use-compress-program=bzip2 -xf $file" ;;
@ -547,10 +646,14 @@ if [ "$GENMD5" = "0" ]; then
*.zip)
unziphack=1
cmd="unzip -qqo $file" ;;
*.cpio.gz)
cmd="bsdtar -x -f $file" ;;
*.cpio.bz2)
cmd="bsdtar -x -f $file" ;;
*.gz)
cmd="gunzip $file" ;;
cmd="gunzip -f $file" ;;
*.bz2)
cmd="bunzip2 $file" ;;
cmd="bunzip2 -f $file" ;;
esac
if [ "$cmd" != "" ]; then
msg " $cmd"
@ -566,43 +669,6 @@ if [ "$GENMD5" = "0" ]; then
fi
done
fi
else
# generate md5 hashes
if [ ! `type -p md5sum` ]; then
error "Cannot find the md5sum program."
exit 1
fi
msg "Generating MD5sums for source files"
plain ""
ct=0
newline=0
numsrc=${#source[@]}
for netfile in ${source[@]}; do
file=`strip_url $netfile`
sum=`md5sum $file | cut -d' ' -f 1`
if [ $ct -eq 0 ]; then
echo -n "md5sums=("
else
if [ $newline -eq 0 ]; then
echo -n " "
fi
fi
echo -n "'$sum'"
ct=$(($ct+1))
if [ $ct -eq $numsrc ]; then
echo ')'
else
if [ $newline -eq 1 ]; then
echo '\'
newline=0
else
echo -n ' '
newline=1
fi
fi
done
plain ""
exit 0
fi
if [ "`id -u`" = "0" ]; then
@ -625,10 +691,6 @@ fi
# use distcc if requested
if [ "$DISTCC" = "y" ]; then
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
if [ "$INCHROOT" = "1" ]; then
[ -d /var/tmp/fst/.distcc ] || mkdir /var/tmp/fst/.distcc
export DISTCC_DIR=/var/tmp/fst/.distcc
fi
fi
# use ccache if it's available
@ -638,11 +700,31 @@ fi
# build
msg "Starting build()..."
if [ "$LOGGING" = "1" ]; then
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
if [ -f "$BUILDLOG" ]; then
i=1
while true; do
if [ -f "$BUILDLOG.$i" ]; then
i=$(($i +1))
else
break
fi
done
mv "$BUILDLOG" "$BUILDLOG.$i"
fi
build 2>&1 | tee "$BUILDLOG"
if [ ${PIPESTATUS[0]} -gt 0 ]; then
error "Build Failed. Aborting..."
exit 2
fi
else
build 2>&1
if [ $? -gt 0 ]; then
error "Build Failed. Aborting..."
exit 2
fi
fi
if [ ! "`check_option KEEPDOCS`" -a "$KEEPDOCS" = "0" ]; then
# remove info/doc files
@ -772,9 +854,9 @@ tar cvf /dev/null * | sort >.FILELIST
msg "Compressing package..."
cd $startdir/pkg
if [ -f $startdir/pkg/.INSTALL ]; then
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO .FILELIST .INSTALL *"
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT} .PKGINFO .FILELIST .INSTALL *"
else
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO .FILELIST *"
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT} .PKGINFO .FILELIST *"
fi
$cmd | sort >../filelist
@ -782,6 +864,7 @@ cd $startdir
if [ "$CLEANUP" = "1" ]; then
msg "Cleaning up..."
rm -rf src pkg filelist
rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
fi
if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
@ -804,7 +887,7 @@ msg "Finished making: $pkgname (`date`)"
if [ "$INSTALL" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
msg "Installing package with pacman -U..."
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
exit $?
elif [ "$INSTALL" = "1" -a "$DEP_SUDO" = "1" ]; then
msg "Installing package with pacman -U..."
@ -812,7 +895,7 @@ elif [ "$INSTALL" = "1" -a "$DEP_SUDO" = "1" ]; then
FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY
fi
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
if [ "$INFAKEROOT" = "1" ]; then
export FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2

View file

@ -6,20 +6,17 @@ localedir = $(datadir)/locale
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
AM_CFLAGS = $(CFLAGS) -D_GNU_SOURCE \
-I$(top_srcdir)/lib/libalpm \
-I$(top_srcdir)/lib/libfetch
-I$(top_srcdir)/lib/libalpm
pacman_SOURCES = util.c log.c list.c package.c download.c trans.c add.c \
pacman_SOURCES = util.c log.c list.c package.c downloadprog.c trans.c add.c \
remove.c upgrade.c query.c sync.c conf.c deptest.c pacman.c
pacman_static_SOURCES = $(pacman_SOURCES)
pacman_LDADD = -L$(top_srcdir)/lib/libalpm/.libs \
-L$(top_srcdir)/lib/libfetch -lfetch \
-larchive -lm -lalpm -lssl -lcrypto
-ldownload -larchive -lm -lalpm -lssl -lcrypto
pacman_static_LDADD = -L$(top_srcdir)/lib/libalpm/.libs/ \
-L$(top_srcdir)/lib/libfetch -lfetch \
-larchive -lm -lalpm -lssl -lcrypto
-ldownload -larchive -lm -lalpm -lssl -lcrypto
pacman_static_LDFLAGS = $(LDFLAGS) -all-static

View file

@ -28,7 +28,7 @@
/* pacman */
#include "log.h"
#include "list.h"
#include "download.h"
#include "downloadprog.h"
#include "trans.h"
#include "add.h"
#include "conf.h"

View file

@ -31,7 +31,7 @@
#include "log.h"
#include "list.h"
#include "sync.h"
#include "download.h"
#include "downloadprog.h"
#include "conf.h"
extern list_t *pmc_syncs;

View file

@ -46,7 +46,7 @@
#include "list.h"
#include "util.h"
#include "log.h"
#include "download.h"
#include "downloadprog.h"
#include "conf.h"
#include "package.h"
#include "add.h"
@ -187,8 +187,8 @@ static void cleanup(int signum)
fprintf(stderr, "Internal pacman error: Segmentation fault\n"
"Please submit a full bug report, with the given package if appropriate.\n");
exit(signum);
} else if((signum == SIGINT) && (alpm_trans_release() == -1) && (pm_errno ==
PM_ERR_TRANS_COMMITING)) {
} else if((signum == SIGINT) && (alpm_trans_release() == -1)
&& (pm_errno == PM_ERR_TRANS_COMMITING)) {
return;
}
if(signum != 0 && config->op_d_vertest == 0) {
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
list_t *lp;
#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
setenv("MALLOC_TRACE","pacman.mtrace", 0);
/*setenv("MALLOC_TRACE","pacman.mtrace", 0);*/
mtrace();
#endif
cenv = getenv("COLUMNS");

View file

@ -119,6 +119,7 @@ int pacman_query(list_t *targets)
indentprint((char *)alpm_pkg_getinfo(pkg, PM_PKG_DESC), 4);
printf("\n");
}
alpm_list_free_outer(ret);
return(0);
}

View file

@ -37,11 +37,11 @@
#endif
#include <alpm.h>
#include <fetch.h> /* fetchLastErrString */
#include <download.h> /* downloadLastErrString */
/* pacman */
#include "util.h"
#include "log.h"
#include "download.h"
#include "downloadprog.h"
#include "list.h"
#include "package.h"
#include "trans.h"
@ -168,8 +168,8 @@ static int sync_synctree(int level, list_t *syncs)
ret = alpm_db_update((level < 2 ? 0 : 1), sync->db);
if(ret < 0) {
if(pm_errno == PM_ERR_DB_SYNC) {
/* use libfetch error */
ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, fetchLastErrString);
/* use libdownload error */
ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, downloadLastErrString);
} else {
ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno));
}
@ -216,6 +216,7 @@ static int sync_search(list_t *syncs, list_t *targets)
indentprint((char *)alpm_pkg_getinfo(pkg, PM_PKG_DESC), 4);
printf("\n");
}
alpm_list_free_outer(ret);
} else {
PM_LIST *lp;
@ -546,7 +547,6 @@ int pacman_sync(list_t *targets)
}
MSG(CL, "\n");
}
alpm_list_free(data);
break;
case PM_ERR_CONFLICTING_DEPS:
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
@ -555,7 +555,6 @@ int pacman_sync(list_t *targets)
MSG(NL, _(":: %s: conflicts with %s"),
alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME));
}
alpm_list_free(data);
break;
case PM_ERR_DISK_FULL:
lp = alpm_list_first(data);
@ -564,7 +563,6 @@ int pacman_sync(list_t *targets)
freespace = alpm_list_getdata(lp);
MSG(NL, _(":: %.1f MB required, have %.1f MB"),
(double)(*pkgsize / 1048576.0), (double)(*freespace / 1048576.0));
alpm_list_free(data);
break;
default:
break;
@ -712,6 +710,10 @@ int pacman_sync(list_t *targets)
/* Step 4: release transaction resources
*/
cleanup:
if(data) {
alpm_list_free(data);
data = NULL;
}
if(alpm_trans_release() == -1) {
ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno));
retval = 1;