3 # makepkg - make packages compatable for use with pacman
6 # Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org>
7 # Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
8 # Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
9 # Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
10 # Copyright (c) 2006 by Alex Smith <alex@alex-smith.me.uk>
11 # Copyright (c) 2006 by Andras Voroskoi <voroskoi@frugalware.org>
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # makepkg uses quite a few external programs during its execution. You
28 # need to have at least the following installed for makepkg to function:
29 # awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
30 # getopt (util-linux), gettext, grep, gzip, openssl, sed
32 # gettext initialization
33 export TEXTDOMAIN
='pacman'
34 export TEXTDOMAINDIR
='@localedir@'
36 # file -i does not work on Mac OSX unless legacy mode is set
37 export COMMAND_MODE
='legacy'
39 myver
='@PACKAGE_VERSION@'
40 confdir
='@sysconfdir@'
41 BUILDSCRIPT
='@BUILDSCRIPT@'
43 srcdir
="$startdir/src"
44 pkgdir
="$startdir/pkg"
46 packaging_options
=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
47 other_options
=('ccache' 'distcc' 'makeflags' 'force')
48 splitpkg_overrides
=('pkgdesc' 'license' 'groups' 'depends' 'optdepends' 'provides' \
49 'conflicts' 'replaces' 'backup' 'options' 'install')
50 readonly -a packaging_options other_options splitpkg_overrides
74 # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
75 # when dealing with svn/cvs/etc PKGBUILDs.
84 if [ $COLORMSG -eq 1 ]; then
85 printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
87 printf " ${mesg}\n" "$@" >&2
93 if [ $COLORMSG -eq 1 ]; then
94 printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
96 printf "==> ${mesg}\n" "$@" >&2
102 if [ $COLORMSG -eq 1 ]; then
103 printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
105 printf " -> ${mesg}\n" "$@" >&2
111 if [ $COLORMSG -eq 1 ]; then
112 printf "\033[1;33m==> $(gettext "WARNING
:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
114 printf "==> $(gettext "WARNING
:") ${mesg}\n" "$@" >&2
120 if [ $COLORMSG -eq 1 ]; then
121 printf "\033[1;31m==> $(gettext "ERROR
:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
123 printf "==> $(gettext "ERROR
:") ${mesg}\n" "$@" >&2
129 # Special exit call for traps, Don't print any error messages when inside,
130 # the fakeroot call, the error message will be printed by the main call.
133 if [ "$INFAKEROOT" -eq 0 ]; then
142 # Clean up function. Called automatically when the script exits.
147 if [ "$INFAKEROOT" -eq 1 ]; then
148 # Don't clean up when leaving fakeroot, we're not done yet.
152 if [ $EXIT_CODE -eq 0 -a "$CLEANUP" -eq 1 ]; then
153 # If it's a clean exit and -c/--clean has been passed...
154 msg
"$(gettext "Cleaning up...
")"
155 rm -rf "$pkgdir" "$srcdir"
156 if [ -n "$pkgname" ]; then
157 # Can't do this unless the BUILDSCRIPT has been sourced.
158 rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"*
159 if [ "$PKGFUNC" -eq 1 ]; then
160 rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"*
161 elif [ "$SPLITPKG" -eq 1 ]; then
162 for pkg
in ${pkgname[@]}; do
163 rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"*
177 trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
178 trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
179 trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR
181 # a source entry can have two forms :
182 # 1) "filename::http://path/to/file"
183 # 2) "http://path/to/file"
185 # extract the filename from a source entry
187 # if a filename is specified, use it
188 local filename
=$
(echo $1 |
sed 's|::.*||')
189 # if it is just an url, we only keep the last component
190 echo "$filename" |
sed 's|^.*://.*/||g'
193 # extract the url from a source entry
195 # strip an eventual filename
196 echo $1 |
sed 's|.*::||'
200 # Checks to see if options are present in makepkg.conf or PKGBUILD;
201 # PKGBUILD options always take precedence.
203 # usage : check_option( $option )
204 # return : y - enabled
209 local ret
=$
(in_opt_array
"$1" ${options[@]})
210 if [ "$ret" != '?' ]; then
215 # fall back to makepkg.conf options
216 ret
=$
(in_opt_array
"$1" ${OPTIONS[@]})
217 if [ "$ret" != '?' ]; then
227 # Check if option is present in BUILDENV
229 # usage : check_buildenv( $option )
230 # return : y - enabled
235 echo $
(in_opt_array
"$1" ${BUILDENV[@]})
240 # usage : in_opt_array( $needle, $haystack )
241 # return : y - enabled
246 local needle
=$
(echo $1 |
tr '[:upper:]' '[:lower:]'); shift
250 opt
=$
(echo $opt |
tr '[:upper:]' '[:lower:]')
251 if [ "$opt" = "$needle" ]; then
254 elif [ "$opt" = "!$needle" ]; then
265 # usage : in_array( $needle, $haystack )
270 local needle
=$1; shift
271 [ -z "$1" ] && return 1 # Not Found
274 [ "$item" = "$needle" ] && return 0 # Found
279 get_downloadclient
() {
280 # $1 = url with valid protocol prefix
282 local proto
=$
(echo "$url" |
sed 's|://.*||')
284 # loop through DOWNLOAD_AGENTS variable looking for protocol
286 for i
in "${DLAGENTS[@]}"; do
287 local handler
=$
(echo $i |
sed 's|::.*||')
288 if [ "$proto" = "$handler" ]; then
289 agent
=$
(echo $i |
sed 's|^.*::||')
294 # if we didn't find an agent, return an error
295 if [ -z "$agent" ]; then
296 error
"$(gettext "There is no agent
set up to handle
%s URLs. Check
%s.
")" "$proto" "$MAKEPKG_CONF"
297 plain
"$(gettext "Aborting...
")"
298 exit 1 # $E_CONFIG_ERROR
301 # ensure specified program is installed
302 local program
="$(echo $agent | awk '{print $1 }')"
303 if [ ! -x "$program" ]; then
304 local baseprog
=$
(basename $program)
305 error
"$(gettext "The download program
%s is not installed.
")" "$baseprog"
306 plain
"$(gettext "Aborting...
")"
307 exit 1 # $E_MISSING_PROGRAM
320 # temporary download file, default to last component of the url
321 local dlfile
=$
(echo "$url" |
sed 's|^.*://.*/||g')
323 # replace %o by the temporary dlfile if it exists
324 if echo "$dlcmd" |
grep -q "%o" ; then
325 dlcmd
=${dlcmd//\%o/$file.part}
328 # add the url, either in place of %u or at the end
329 if echo "$dlcmd" |
grep -q "%u" ; then
330 dlcmd
=${dlcmd//\%u/$url}
337 # rename the temporary download file to the final destination
338 if [ "$dlfile" != "$file" ]; then
339 mv -f "$SRCDEST/$dlfile" "$SRCDEST/$file"
344 [ $# -gt 0 ] ||
return
346 pmout
=$
(pacman
$PACMAN_OPTS -T "$@")
348 if [ $ret -eq 127 ]; then #unresolved deps
350 elif [ $ret -ne 0 ]; then
351 error
"$(gettext "Pacman returned a fatal error
(%i
): %s
")" "$ret" "$pmout"
357 local R_DEPS_SATISFIED
=0
358 local R_DEPS_MISSING
=1
360 [ $# -eq 0 ] && return $R_DEPS_SATISFIED
364 if [ "$DEP_BIN" -eq 0 ]; then
365 return $R_DEPS_MISSING
368 if [ "$DEP_BIN" -eq 1 ]; then
369 # install missing deps from binary packages (using pacman -S)
370 msg
"$(gettext "Installing missing dependencies...
")"
373 if [ "$ASROOT" -eq 0 ]; then
374 sudo pacman
$PACMAN_OPTS -S --asdeps $deplist || ret
=$?
376 pacman
$PACMAN_OPTS -S --asdeps $deplist || ret
=$?
379 if [ $ret -ne 0 ]; then
380 error
"$(gettext "Pacman failed to
install missing dependencies.
")"
381 exit 1 # TODO: error code
385 # we might need the new system environment
386 # set -e can cause problems during sourcing profile scripts
388 source /etc
/profile
&>/dev
/null
391 return $R_DEPS_SATISFIED
395 # $pkgdeps is a GLOBAL variable, used by remove_deps()
396 local R_DEPS_SATISFIED
=0
397 local R_DEPS_MISSING
=1
399 local deplist
="$(check_deps $*)"
400 if [ -z "$deplist" ]; then
401 return $R_DEPS_SATISFIED
404 if handledeps
$deplist; then
405 pkgdeps
="$pkgdeps $deplist"
406 # check deps again to make sure they were resolved
407 deplist
="$(check_deps $*)"
408 [ -z "$deplist" ] && return $R_DEPS_SATISFIED
409 elif [ "$DEP_BIN" -eq 1 ]; then
410 error
"$(gettext "Failed to
install all missing dependencies.
")"
413 msg
"$(gettext "Missing Dependencies
:")"
415 for dep
in $deplist; do
419 return $R_DEPS_MISSING
422 # fix flyspray bug #5923
424 # $pkgdeps is a GLOBAL variable, set by resolve_deps()
425 [ "$RMDEPS" -eq 0 ] && return
426 [ -z "$pkgdeps" ] && return
428 local dep depstrip deplist
430 for dep
in $pkgdeps; do
431 depstrip
=$
(echo $dep |
sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')
432 deplist
="$deplist $depstrip"
435 msg
"Removing installed dependencies..."
437 if [ "$ASROOT" -eq 0 ]; then
438 sudo pacman
$PACMAN_OPTS -Rns $deplist || ret
=$?
440 pacman
$PACMAN_OPTS -Rns $deplist || ret
=$?
443 # Fixes FS#10039 - exit cleanly as package has built successfully
444 if [ $ret -ne 0 ]; then
445 warning
"$(gettext "Failed to remove installed dependencies.
")"
451 msg
"$(gettext "Retrieving Sources...
")"
453 if [ ! -w "$SRCDEST" ] ; then
454 error
"$(gettext "You
do not have
write permission to store downloads
in %s.
")" "$SRCDEST"
455 plain
"$(gettext "Aborting...
")"
459 pushd "$SRCDEST" &>/dev
/null
462 for netfile
in "${source[@]}"; do
463 local file=$
(get_filename
"$netfile")
464 local url
=$
(get_url
"$netfile")
465 if [ -f "$startdir/$file" ]; then
466 msg2
"$(gettext "Found
%s
in build dir
")" "$file"
467 rm -f "$srcdir/$file"
468 ln -s "$startdir/$file" "$srcdir/"
470 elif [ -f "$SRCDEST/$file" ]; then
471 msg2
"$(gettext "Using cached copy of
%s
")" "$file"
472 rm -f "$srcdir/$file"
473 ln -s "$SRCDEST/$file" "$srcdir/"
477 # if we get here, check to make sure it was a URL, else fail
478 if [ "$file" = "$url" ]; then
479 error
"$(gettext "%s was not found
in the build directory and is not a URL.
")" "$file"
480 exit 1 # $E_MISSING_FILE
483 # find the client we should use for this URL
484 local dlclient
=$
(get_downloadclient
"$url") ||
exit $?
486 msg2
"$(gettext "Downloading
%s...
")" "$file"
487 # fix flyspray bug #3289
489 download_file
"$dlclient" "$url" "$file" || ret
=$?
490 if [ $ret -gt 0 ]; then
491 error
"$(gettext "Failure
while downloading
%s
")" "$file"
492 plain
"$(gettext "Aborting...
")"
495 rm -f "$srcdir/$file"
496 ln -s "$SRCDEST/$file" "$srcdir/"
502 generate_checksums
() {
503 msg
"$(gettext "Generating checksums
for source files...
")"
506 if [ ! $
(type -p openssl
) ]; then
507 error
"$(gettext "Cannot
find openssl.
")"
508 exit 1 # $E_MISSING_PROGRAM
512 for integ
in ${INTEGRITY_CHECK[@]}; do
513 integ
="$(echo $integ | tr '[:upper:]' '[:lower:]')"
515 md5|sha1|sha256|sha384|sha512
) : ;;
517 error
"$(gettext "Invalid integrity algorithm
'%s' specified.
")" "$integ"
518 exit 1;; # $E_CONFIG_ERROR
522 local numsrc
=${#source[@]}
523 echo -n "${integ}sums=("
527 while [ $i -lt $
((${#integ}+6)) ]; do
533 for netfile
in "${source[@]}"; do
534 local file="$(get_filename "$netfile")"
536 if [ ! -f "$file" ] ; then
537 if [ ! -f "$SRCDEST/$file" ] ; then
538 error
"$(gettext "Unable to
find source file %s to generate checksum.
")" "$file"
539 plain
"$(gettext "Aborting...
")"
542 file="$SRCDEST/$file"
546 local sum="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
547 [ $ct -gt 0 ] && echo -n "$indent"
550 [ $ct -lt $numsrc ] && echo
558 [ ${#source[@]} -eq 0 ] && return 0
560 if [ ! $
(type -p openssl
) ]; then
561 error
"$(gettext "Cannot
find openssl.
")"
562 exit 1 # $E_MISSING_PROGRAM
567 for integ
in md5 sha1 sha256 sha384 sha512
; do
568 local integrity_sums
=($
(eval echo "\${${integ}sums[@]}"))
569 if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
570 msg
"$(gettext "Validating
source files with
%s...
")" "${integ}sums"
575 for file in "${source[@]}"; do
577 file="$(get_filename "$file")"
578 echo -n " $file ... " >&2
580 if [ ! -f "$file" ] ; then
581 if [ ! -f "$SRCDEST/$file" ] ; then
582 echo "$(gettext "NOT FOUND
")" >&2
586 file="$SRCDEST/$file"
590 if [ $found -gt 0 ] ; then
591 local expectedsum
="$(echo ${integrity_sums[$idx]} | tr '[A-F]' '[a-f]')"
592 local realsum
="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
593 if [ "$expectedsum" = "$realsum" ]; then
594 echo "$(gettext "Passed
")" >&2
596 echo "$(gettext "FAILED
")" >&2
604 if [ $errors -gt 0 ]; then
605 error
"$(gettext "One or
more files did not pass the validity check
!")"
606 exit 1 # TODO: error code
608 elif [ ${#integrity_sums[@]} -gt 0 ]; then
609 error
"$(gettext "Integrity checks
(%s
) differ
in size from the
source array.
")" "$integ"
610 exit 1 # TODO: error code
614 if [ $correlation -eq 0 ]; then
615 error
"$(gettext "Integrity checks are missing.
")"
616 exit 1 # TODO: error code
621 msg
"$(gettext "Extracting Sources...
")"
623 for netfile
in "${source[@]}"; do
624 file=$
(get_filename
"$netfile")
625 if in_array
"$file" ${noextract[@]}; then
626 #skip source files in the noextract=() array
627 # these are marked explicitly to NOT be extracted
631 if [ ! -f "$file" ] ; then
632 if [ ! -f "$SRCDEST/$file" ] ; then
633 error
"$(gettext "Unable to
find source file %s
for extraction.
")" "$file"
634 plain
"$(gettext "Aborting...
")"
637 file="$SRCDEST/$file"
642 local file_type
=$
(file -bizL "$file")
645 *application
/x-tar
*|
*application
/zip*|
*application
/x-zip
*|
*application
/x-cpio
*)
646 cmd
="bsdtar -x -f $file" ;;
647 *application
/x-gzip
*)
648 cmd
="gunzip -d -f $file" ;;
649 *application
/x-bzip
*)
650 cmd
="bunzip2 -f $file" ;;
652 # Don't know what to use to extract this file,
653 # skip to the next file
660 if [ $ret -ne 0 ]; then
661 error
"$(gettext "Failed to extract
%s
")" "$file"
662 plain
"$(gettext "Aborting...
")"
667 if [ $EUID -eq 0 ]; then
668 # change perms of all source files to root user & root group
669 chown
-R 0:0 "$srcdir"
674 # use distcc if it is requested (check buildenv and PKGBUILD opts)
675 if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
676 [ -d /usr
/lib
/distcc
/bin
] && export PATH
="/usr/lib/distcc/bin:$PATH"
678 elif [ "$(check_option distcc)" = "n" ]; then
679 # if it is not wanted, clear the makeflags too
683 # use ccache if it is requested (check buildenv and PKGBUILD opts)
684 if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
685 [ -d /usr
/lib
/ccache
/bin
] && export PATH
="/usr/lib/ccache/bin:$PATH"
688 # clear user-specified makeflags if requested
689 if [ "$(check_option makeflags)" = "n" ]; then
693 msg
"$(gettext "Starting build
()...
")"
696 # ensure all necessary build variables are exported
697 export CFLAGS CXXFLAGS MAKEFLAGS LDFLAGS CHOST
698 # save our shell options so build() can't override what we need
699 local shellopts
=$
(shopt -p)
702 if [ "$LOGGING" -eq 1 ]; then
703 BUILDLOG
="${startdir}/${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"
704 if [ -f "$BUILDLOG" ]; then
707 if [ -f "$BUILDLOG.$i" ]; then
713 mv "$BUILDLOG" "$BUILDLOG.$i"
716 build
2>&1 |
tee "$BUILDLOG"; ret
=${PIPESTATUS[0]}
720 # reset our shell options
723 if [ $ret -gt 0 ]; then
724 error
"$(gettext "Build Failed.
")"
725 plain
"$(gettext "Aborting...
")"
727 exit 2 # $E_BUILD_FAILED
740 # clear user-specified makeflags if requested
741 if [ "$(check_option makeflags)" = "n" ]; then
745 msg
"$(gettext "Starting
%s
()...
")" "$pkgfunc"
748 # ensure all necessary build variables are exported
749 export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
752 if [ "$LOGGING" -eq 1 ]; then
753 BUILDLOG
="${startdir}/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"
754 if [ -f "$BUILDLOG" ]; then
757 if [ -f "$BUILDLOG.$i" ]; then
763 mv "$BUILDLOG" "$BUILDLOG.$i"
766 # ensure overridden package variables suvrive tee with split packages
767 logpipe
=$
(mktemp
-u "$startdir/logpipe.XXXXXXXX")
770 tee "$BUILDLOG" < "$logpipe" &
771 exec 1>"$logpipe" 2>"$logpipe"
772 $pkgfunc 2>&1 || ret
=$?
777 $pkgfunc 2>&1 || ret
=$?
780 if [ $ret -gt 0 ]; then
781 error
"$(gettext "Packaging Failed.
")"
782 plain
"$(gettext "Aborting...
")"
784 exit 2 # $E_BUILD_FAILED
790 msg
"$(gettext "Tidying
install...
")"
792 if [ "$(check_option docs)" = "n" -a -n "${DOC_DIRS[*]}" ]; then
793 msg2
"$(gettext "Removing doc files...
")"
794 rm -rf ${DOC_DIRS[@]}
797 if [ "$(check_option purge)" = "y" -a -n "${PURGE_TARGETS[*]}" ]; then
798 msg2
"$(gettext "Purging other files...
")"
800 for pt
in "${PURGE_TARGETS[@]}"; do
801 if [ "${pt}" = "${pt//\/}" ]; then
802 find .
-type f
-name "${pt}" -exec rm -f -- '{}' \
;
809 if [ "$(check_option zipman)" = "y" -a -n "${MAN_DIRS[*]}" ]; then
810 msg2
"$(gettext "Compressing man and info pages...
")"
811 local manpage ext
file link hardlinks hl
812 find ${MAN_DIRS[@]} -type f
2>/dev
/null |
813 while read manpage
; do
814 # check file still exists (potentially compressed with hard link)
815 if [ -f ${manpage} ]; then
817 file="${manpage##*/}"
818 if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
819 # update symlinks to this manpage
820 find ${MAN_DIRS[@]} -lname "$file" 2>/dev
/null |
823 ln -sf "${file}.gz" "${link}.gz"
825 # find hard links and remove them
826 # the '|| true' part keeps the script from bailing if find returned an
827 # error, such as when one of the man directories doesn't exist
828 hardlinks
="$(find ${MAN_DIRS[@]} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
829 for hl
in ${hardlinks}; do
832 # compress the original
834 # recreate hard links removed earlier
835 for hl
in ${hardlinks}; do
836 ln "${manpage}.gz" "${hl}.gz"
844 if [ "$(check_option strip)" = "y" -a -n "${STRIP_DIRS[*]}" ]; then
845 msg2
"$(gettext "Stripping debugging symbols from binaries and libraries...
")"
847 find ${STRIP_DIRS[@]} -type f
2>/dev
/null |
while read binary
; do
848 case "$(file -biz "$binary")" in
849 *compressed-encoding
*) # Skip compressed binarys
851 *application
/x-sharedlib
*) # Libraries (.so)
852 /usr
/bin
/strip
-S "$binary";;
853 *application
/x-archive
*) # Libraries (.a)
854 /usr
/bin
/strip
-S "$binary";;
855 *application
/x-executable
*) # Binaries
856 /usr
/bin
/strip
"$binary";;
861 if [ "$(check_option libtool)" = "n" ]; then
862 msg2
"$(gettext "Removing libtool .la files...
")"
863 find .
! -type d
-name "*.la" -exec rm -f -- '{}' \
;
866 if [ "$(check_option emptydirs)" = "n" ]; then
867 msg2
"$(gettext "Removing empty directories...
")"
868 find .
-depth -type d
-empty -delete
879 if [ ! -d "$pkgdir" ]; then
880 error
"$(gettext "Missing pkg
/ directory.
")"
881 plain
"$(gettext "Aborting...
")"
882 exit 1 # $E_MISSING_PKGDIR
886 msg
"$(gettext "Creating package...
")"
888 local builddate
=$
(date -u "+%s")
889 if [ -n "$PACKAGER" ]; then
890 local packager
="$PACKAGER"
892 local packager
="Unknown Packager"
894 local size
=$
(du
-sk |
awk '{print $1 * 1024}')
896 # write the .PKGINFO file
897 msg2
"$(gettext "Generating .PKGINFO
file...
")"
898 echo "# Generated by makepkg $myver" >.PKGINFO
899 if [ "$INFAKEROOT" -eq 1 ]; then
900 echo "# using $(fakeroot -v)" >>.PKGINFO
902 echo "# $(LC_ALL=C date -u)" >>.PKGINFO
903 echo "pkgname = $nameofpkg" >>.PKGINFO
904 echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
905 echo "pkgdesc = $pkgdesc" >>.PKGINFO
906 echo "url = $url" >>.PKGINFO
907 echo "builddate = $builddate" >>.PKGINFO
908 echo "packager = $packager" >>.PKGINFO
909 echo "size = $size" >>.PKGINFO
910 if [ -n "$CARCH" ]; then
911 echo "arch = $CARCH" >>.PKGINFO
913 if [ "$(check_option force)" = "y" ]; then
914 echo "force = true" >> .PKGINFO
918 for it
in "${license[@]}"; do
919 echo "license = $it" >>.PKGINFO
921 for it
in "${replaces[@]}"; do
922 echo "replaces = $it" >>.PKGINFO
924 for it
in "${groups[@]}"; do
925 echo "group = $it" >>.PKGINFO
927 for it
in "${depends[@]}"; do
928 echo "depend = $it" >>.PKGINFO
930 for it
in "${optdepends[@]}"; do
931 echo "optdepend = $it" >>.PKGINFO
933 for it
in "${conflicts[@]}"; do
934 echo "conflict = $it" >>.PKGINFO
936 for it
in "${provides[@]}"; do
937 echo "provides = $it" >>.PKGINFO
939 for it
in "${backup[@]}"; do
940 echo "backup = $it" >>.PKGINFO
942 for it
in "${packaging_options[@]}"; do
943 local ret
="$(check_option $it)"
944 if [ "$ret" != "?" ]; then
945 if [ "$ret" = "y" ]; then
946 echo "makepkgopt = $it" >>.PKGINFO
948 echo "makepkgopt = !$it" >>.PKGINFO
953 # TODO maybe remove this at some point
954 # warn if license array is not present or empty
955 if [ -z "$license" ]; then
956 warning
"$(gettext "Please add a license line to your
%s
!")" "$BUILDSCRIPT"
957 plain
"$(gettext "Example
for GPL
\'ed software
: license
=('GPL').
")"
960 local comp_files
=".PKGINFO"
962 # check for an install script
963 if [ -n "$install" ]; then
964 msg2
"$(gettext "Adding
install script...
")"
965 cp "$startdir/$install" .INSTALL
966 comp_files
="$comp_files .INSTALL"
969 # do we have a changelog?
970 if [ -f "$startdir/ChangeLog" ]; then
971 msg2
"$(gettext "Adding package changelog...
")"
972 cp "$startdir/ChangeLog" .CHANGELOG
973 comp_files
="$comp_files .CHANGELOG"
977 msg2
"$(gettext "Compressing package...
")"
980 *tar.gz
) EXT
=${PKGEXT%.gz} ;;
981 *tar.bz2
) EXT
=${PKGEXT%.bz2} ;;
982 *) warning
"$(gettext "'%s' is not a valid archive extension.
")" \
983 "$PKGEXT" ; EXT
=$PKGEXT ;;
985 local pkg_file
="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}${EXT}"
989 # when fileglobbing, we want * in an empty directory to expand to
990 # the null string rather than itself
992 bsdtar
-cf - $comp_files * > "$pkg_file" || ret
=$?
995 if [ $ret -eq 0 ]; then
997 *tar.gz
) gzip -f -n "$pkg_file" ;;
998 *tar.bz2
) bzip2 -f "$pkg_file" ;;
1003 if [ $ret -ne 0 ]; then
1004 error
"$(gettext "Failed to create package
file.
")"
1005 exit 1 # TODO: error code
1009 create_srcpackage
() {
1011 if [ "$SOURCEONLY" -eq 2 ]; then
1012 # get back to our src directory so we can begin with sources
1016 # we can only check checksums if we have all files
1020 msg
"$(gettext "Creating
source package...
")"
1021 local srclinks
="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
1022 mkdir
"${srclinks}"/${pkgbase}
1024 msg2
"$(gettext "Adding
%s...
")" "$BUILDSCRIPT"
1025 ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgbase}/"
1027 if [ -n "$install" ]; then
1028 if [ -f $install ]; then
1029 msg2
"$(gettext "Adding
install script...
")"
1030 ln -s "${startdir}/$install" "${srclinks}/${pkgbase}/"
1032 error
"$(gettext "Install
script %s not found.
")" "$install"
1036 if [ -f ChangeLog
]; then
1037 msg2
"$(gettext "Adding
%s...
")" "ChangeLog"
1038 ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgbase}"
1042 for netfile
in "${source[@]}"; do
1043 local file=$
(get_filename
"$netfile")
1044 if [ -f "$netfile" ]; then
1045 msg2
"$(gettext "Adding
%s...
")" "$netfile"
1046 ln -s "${startdir}/$netfile" "${srclinks}/${pkgbase}"
1047 elif [ "$SOURCEONLY" -eq 2 -a -f "$SRCDEST/$file" ]; then
1048 msg2
"$(gettext "Adding
%s...
")" "$file"
1049 ln -s "$SRCDEST/$file" "${srclinks}/${pkgbase}/"
1055 *tar.gz
) TAR_OPT
="z" ;;
1056 *tar.bz2
) TAR_OPT
="j" ;;
1057 *) warning
"$(gettext "'%s' is not a valid archive extension.
")" \
1061 local pkg_file
="$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}"
1064 msg2
"$(gettext "Compressing
source package...
")"
1066 if ! bsdtar
-c${TAR_OPT}Lf
"$pkg_file" ${pkgbase}; then
1067 error
"$(gettext "Failed to create
source package
file.
")"
1068 exit 1 # TODO: error code
1071 rm -rf "${srclinks}"
1075 [ "$INSTALL" -eq 0 ] && return
1077 if [ "$SPLITPKG" -eq 0 ]; then
1078 msg
"$(gettext "Installing package
${pkgname} with pacman
-U...
")"
1080 msg
"$(gettext "Installing
${pkgbase} package group with pacman
-U...
")"
1084 for pkg
in ${pkgname[@]}; do
1085 pkglist
="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
1089 if [ "$ASROOT" -eq 0 ]; then
1090 sudo pacman
$PACMAN_OPTS -U ${pkglist} || ret
=$?
1092 pacman
$PACMAN_OPTS -U ${pkglist} || ret
=$?
1095 if [ $ret -ne 0 ]; then
1096 warning
"$(gettext "Failed to
install built package
(s
).
")"
1104 # Do not update pkgver if --holdver is set, when building a source package,
1105 # or when reading PKGBUILD from pipe
1106 if [ "$HOLDVER" -eq 1 -o "$SOURCEONLY" -ne 0 -o ! -f "./$BUILDSCRIPT" ]; then
1110 if [ -z "$FORCE_VER" ]; then
1111 # Check if this is a svn/cvs/etc PKGBUILD; set $newpkgver if so.
1112 # This will only be used on the first call to makepkg; subsequent
1113 # calls to makepkg via fakeroot will explicitly pass the version
1114 # number to avoid having to determine the version number twice.
1115 # Also do a brief check to make sure we have the VCS tool available.
1117 if [ -n "${_darcstrunk}" -a -n "${_darcsmod}" ] ; then
1118 [ $
(type -p darcs
) ] ||
return 0
1119 msg
"$(gettext "Determining latest darcs revision...
")"
1120 newpkgver
=$
(date +%Y
%m
%d
)
1121 elif [ -n "${_cvsroot}" -a -n "${_cvsmod}" ] ; then
1122 [ $
(type -p cvs
) ] ||
return 0
1123 msg
"$(gettext "Determining latest cvs revision...
")"
1124 newpkgver
=$
(date +%Y
%m
%d
)
1125 elif [ -n "${_gitroot}" -a -n "${_gitname}" ] ; then
1126 [ $
(type -p git
) ] ||
return 0
1127 msg
"$(gettext "Determining latest git revision...
")"
1128 newpkgver
=$
(date +%Y
%m
%d
)
1129 elif [ -n "${_svntrunk}" -a -n "${_svnmod}" ] ; then
1130 [ $
(type -p svn
) ] ||
return 0
1131 msg
"$(gettext "Determining latest svn revision...
")"
1132 newpkgver
=$
(LC_ALL
=C svn info
$_svntrunk |
sed -n 's/^Last Changed Rev: \([0-9]*\)$/\1/p')
1133 elif [ -n "${_bzrtrunk}" -a -n "${_bzrmod}" ] ; then
1134 [ $
(type -p bzr
) ] ||
return 0
1135 msg
"$(gettext "Determining latest bzr revision...
")"
1136 newpkgver
=$
(bzr revno
${_bzrtrunk})
1137 elif [ -n "${_hgroot}" -a -n "${_hgrepo}" ] ; then
1138 [ $
(type -p hg
) ] ||
return 0
1139 msg
"$(gettext "Determining latest hg revision...
")"
1140 if [ -d .
/src
/$_hgrepo ] ; then
1145 [[ ! -d .
/src
/ ]] && mkdir .
/src
/
1146 hg clone
$_hgroot/$_hgrepo .
/src
/$_hgrepo
1149 newpkgver
=$
(hg tip
--template "{rev}")
1153 if [ -n "$newpkgver" ]; then
1154 msg2
"$(gettext "Version found
: %s
")" "$newpkgver"
1158 # Version number retrieved from fakeroot->makepkg argument
1159 newpkgver
=$FORCE_VER
1164 # This is lame, but if we're wanting to use an updated pkgver for
1165 # retrieving svn/cvs/etc sources, we'll update the PKGBUILD with
1166 # the new pkgver and then re-source it. This is the most robust
1167 # method for dealing with PKGBUILDs that use, e.g.:
1173 if [ -n "$newpkgver" ]; then
1174 if [ "$newpkgver" != "$pkgver" ]; then
1175 if [ -f "./$BUILDSCRIPT" ]; then
1176 @SEDINPLACE@
"s/^pkgver=[^ ]*/pkgver=$newpkgver/" "./$BUILDSCRIPT"
1177 @SEDINPLACE@
"s/^pkgrel=[^ ]*/pkgrel=1/" "./$BUILDSCRIPT"
1178 source "$BUILDSCRIPT"
1184 backup_package_variables
() {
1185 for var
in ${splitpkg_overrides[@]}; do
1186 indirect
="${var}_backup"
1187 eval "${indirect}=\"${!var}\""
1191 restore_package_variables
() {
1192 for var
in ${splitpkg_overrides[@]}; do
1193 indirect
="${var}_backup"
1194 if [ -n "${!indirect}" ]; then
1195 eval "${var}=\"${!indirect}\""
1202 # getopt like parser
1204 local short_options
=$1; shift;
1205 local long_options
=$1; shift;
1207 local unused_options
=""
1209 while [ -n "$1" ]; do
1210 if [ ${1:0:2} = '--' ]; then
1211 if [ -n "${1:2}" ]; then
1213 for i
in ${long_options//,/ }; do
1214 if [ ${1:2} = ${i//:} ]; then
1219 if [ -n "$match" ]; then
1220 if [ ${1:2} = $match ]; then
1223 if [ -n "$2" ]; then
1228 echo "makepkg: option '$1' $(gettext "requires an argument
")" >&2
1233 echo "makepkg: $(gettext "unrecognized option
") '$1'" >&2
1240 elif [ ${1:0:1} = '-' ]; then
1241 for ((i
=1; i
<${#1}; i
++)); do
1242 if [[ "$short_options" =~
"${1:i:1}" ]]; then
1243 if [[ "$short_options" =~
"${1:i:1}:" ]]; then
1244 if [ -n "${1:$i+1}" ]; then
1245 printf ' -%s' "${1:i:1}"
1246 printf " '%s'" "${1:$i+1}"
1248 if [ -n "$2" ]; then
1249 printf ' -%s' "${1:i:1}"
1251 printf " '%s'" "${1}"
1253 echo "makepkg: option $(gettext "requires an argument
") -- '${1:i:1}'" >&2
1259 printf ' -%s' "${1:i:1}"
1262 echo "makepkg: $(gettext "invalid option
") -- '${1:i:1}'" >&2
1267 unused_options
="${unused_options} '$1'"
1273 if [ -n "$unused_options" ]; then
1274 for i
in ${unused_options[@]}; do
1278 if [ -n "$1" ]; then
1279 while [ -n "$1" ]; do
1280 printf " '%s'" "${1}"
1290 printf "makepkg (pacman) %s\n" "$myver"
1292 printf "$(gettext "Usage
: %s
[options
]")\n" "$0"
1294 echo "$(gettext "Options
:")"
1295 printf "$(gettext " -A, --ignorearch Ignore incomplete arch field
in %s
")\n" "$BUILDSCRIPT"
1296 echo "$(gettext " -c, --clean Clean up work files after build
")"
1297 echo "$(gettext " -C, --cleancache Clean up
source files from the cache
")"
1298 printf "$(gettext " --config <config
> Use an alternate config
file (instead of
'%s')")\n" "$confdir/makepkg.conf"
1299 echo "$(gettext " -d, --nodeps Skip all dependency checks
")"
1300 echo "$(gettext " -e, --noextract Do not extract
source files
(use existing src
/ dir
)")"
1301 echo "$(gettext " -f, --force Overwrite existing package
")"
1302 echo "$(gettext " -g, --geninteg Generate integrity checks
for source files
")"
1303 echo "$(gettext " -h, --help This
help")"
1304 echo "$(gettext " -i, --install Install package after successful build
")"
1305 echo "$(gettext " -L, --log Log package build process
")"
1306 echo "$(gettext " -m, --nocolor Disable colorized output messages
")"
1307 echo "$(gettext " -o, --nobuild Download and extract files only
")"
1308 printf "$(gettext " -p <buildscript
> Use an alternate build
script (instead of
'%s')")\n" "$BUILDSCRIPT"
1309 echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build
")"
1310 # fix flyspray feature request #2978
1311 echo "$(gettext " -R, --repackage Repackage contents of the package without rebuilding
")"
1312 echo "$(gettext " -s, --syncdeps Install missing dependencies with pacman
")"
1313 echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources
")"
1314 echo "$(gettext " --asroot Allow makepkg to run as root user
")"
1315 echo "$(gettext " --holdver Prevent automatic version bumping
for development PKGBUILDs
")"
1316 echo "$(gettext " --source Generate a source-only tarball without downloaded sources
")"
1318 echo "$(gettext "These options can be passed to pacman
:")"
1320 echo "$(gettext " --noconfirm Do not ask
for confirmation when resolving dependencies
")"
1321 echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files
")"
1323 printf "$(gettext "If
-p is not specified
, makepkg will
look for '%s'")\n" "$BUILDSCRIPT"
1328 printf "makepkg (pacman) %s\n" "$myver"
1329 printf "$(gettext "\
1330 Copyright
(C
) 2002-2007 Judd Vinet
<jvinet@zeroflux.org
>.
\n\n\
1331 This is free software
; see the
source for copying conditions.
\n\
1332 There is NO WARRANTY
, to the extent permitted by law.
\n")"
1337 # determine whether we have gettext; make it a no-op if we do not
1338 if [ ! $
(type -t gettext) ]; then
1346 # Parse Command Line Options.
1347 OPT_SHORT
="AbcCdefFghiLmop:rRsV"
1348 OPT_LONG
="allsource,asroot,ignorearch,builddeps,clean,cleancache,nodeps"
1349 OPT_LONG
="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
1350 OPT_LONG
="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source"
1351 OPT_LONG
="$OPT_LONG,syncdeps,version,config:"
1353 OPT_LONG
="$OPT_LONG,noconfirm,noprogressbar"
1354 OPT_TEMP
="$(parse_options $OPT_SHORT $OPT_LONG "$@
" || echo 'PARSE_OPTIONS FAILED')"
1355 if echo "$OPT_TEMP" |
grep -q 'PARSE_OPTIONS FAILED'; then
1356 # This is a small hack to stop the script bailing with 'set -e'
1357 echo; usage
; exit 1 # E_INVALID_OPTION;
1359 eval set -- "$OPT_TEMP"
1360 unset OPT_SHORT OPT_LONG OPT_TEMP
1365 --noconfirm) PACMAN_OPTS
="$PACMAN_OPTS --noconfirm" ;;
1366 --noprogressbar) PACMAN_OPTS
="$PACMAN_OPTS --noprogressbar" ;;
1369 --allsource) SOURCEONLY
=2 ;;
1370 --asroot) ASROOT
=1 ;;
1371 -A|
--ignorearch) IGNOREARCH
=1 ;;
1372 -c|
--clean) CLEANUP
=1 ;;
1373 -C|
--cleancache) CLEANCACHE
=1 ;;
1374 --config) shift; MAKEPKG_CONF
=$1 ;;
1375 -d|
--nodeps) NODEPS
=1 ;;
1376 -e|
--noextract) NOEXTRACT
=1 ;;
1377 -f|
--force) FORCE
=1 ;;
1378 #hidden opt used by fakeroot call for svn/cvs/etc PKGBUILDs to set pkgver
1379 --forcever) shift; FORCE_VER
=$1;;
1381 -g|
--geninteg) GENINTEG
=1 ;;
1382 --holdver) HOLDVER
=1 ;;
1383 -i|
--install) INSTALL
=1 ;;
1384 -L|
--log) LOGGING
=1 ;;
1385 -m|
--nocolor) USE_COLOR
='n' ;;
1386 -o|
--nobuild) NOBUILD
=1 ;;
1387 -p) shift; BUILDSCRIPT
=$1 ;;
1388 -r|
--rmdeps) RMDEPS
=1 ;;
1389 -R|
--repackage) REPKG
=1 ;;
1390 --source) SOURCEONLY
=1 ;;
1391 -s|
--syncdeps) DEP_BIN
=1 ;;
1393 -h|
--help) usage
; exit 0 ;; # E_OK
1394 -V|
--version) version
; exit 0 ;; # E_OK
1396 --) OPT_IND
=0; shift; break;;
1397 *) usage
; exit 1 ;; # E_INVALID_OPTION
1402 #preserve environment variables
1406 # default config is makepkg.conf
1407 MAKEPKG_CONF
=${MAKEPKG_CONF:-$confdir/makepkg.conf}
1409 # Source the config file; fail if it is not found
1410 if [ -r "$MAKEPKG_CONF" ]; then
1411 source "$MAKEPKG_CONF"
1413 error
"$(gettext "%s not found.
")" "$MAKEPKG_CONF"
1414 plain
"$(gettext "Aborting...
")"
1415 exit 1 # $E_CONFIG_ERROR
1418 # Source user-specific makepkg.conf overrides
1419 if [ -r ~
/.makepkg.conf
]; then
1420 source ~
/.makepkg.conf
1423 # check if messages are to be printed using color
1424 if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
1428 # override settings with an environment variable for batch processing
1429 PKGDEST
=${_PKGDEST:-$PKGDEST}
1430 PKGDEST
=${PKGDEST:-$startdir} #default to $startdir if undefined
1431 SRCDEST
=${_SRCDEST:-$SRCDEST}
1432 SRCDEST
=${SRCDEST:-$startdir} #default to $startdir if undefined
1435 if [ "$HOLDVER" -eq 1 -a -n "$FORCE_VER" ]; then
1436 # The '\\0' is here to prevent gettext from thinking --holdver is an option
1437 error
"$(gettext "\\0--holdver and
--forcever cannot both be specified
" )"
1441 if [ "$CLEANCACHE" -eq 1 ]; then
1442 #fix flyspray feature request #5223
1443 if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then
1444 msg
"$(gettext "Cleaning up ALL files from
%s.
")" "$SRCDEST"
1445 echo -n "$(gettext " Are you sure you wish to
do this?
")"
1446 echo -n "$(gettext "[Y
/n
]")"
1448 answer
=$
(echo $answer |
tr '[:lower:]' '[:upper:]')
1449 if [ "$answer" = "$(gettext "YES
")" -o "$answer" = "$(gettext "Y
")" ]; then
1451 if [ $?
-ne 0 ]; then
1452 error
"$(gettext "Problem removing files
; you may not have correct permissions
in %s
")" "$SRCDEST"
1456 msg
"$(gettext "Source cache cleaned.
")"
1461 msg
"$(gettext "No files have been removed.
")"
1465 # $SRCDEST is $startdir, two possibilities
1466 error
"$(gettext "Source destination must be defined
in %s.
")" "$MAKEPKG_CONF"
1467 plain
"$(gettext "In addition
, please run makepkg
-C outside of your cache directory.
")"
1472 if [ -z "$BUILDSCRIPT" ]; then
1473 error
"$(gettext "BUILDSCRIPT is undefined
! Ensure you have updated
%s.
")" "$MAKEPKG_CONF"
1477 if [ "$INFAKEROOT" -eq 0 ]; then
1478 if [ $EUID -eq 0 -a "$ASROOT" -eq 0 ]; then
1479 # Warn those who like to live dangerously.
1480 error
"$(gettext "Running makepkg as root is a BAD idea and can cause
")"
1481 plain
"$(gettext "permanent
, catastrophic damage to your system. If you
")"
1482 plain
"$(gettext "wish to run as root
, please use the
--asroot option.
")"
1483 exit 1 # $E_USER_ABORT
1484 elif [ $EUID -gt 0 -a "$ASROOT" -eq 1 ]; then
1485 # Warn those who try to use the --asroot option when they are not root
1486 error
"$(gettext "The
--asroot option is meant
for the root user only.
")"
1487 plain
"$(gettext "Please rerun makepkg without the
--asroot flag.
")"
1488 exit 1 # $E_USER_ABORT
1489 elif [ "$(check_buildenv fakeroot)" = "y" -a $EUID -gt 0 ]; then
1490 if [ ! $
(type -p fakeroot
) ]; then
1491 error
"$(gettext "Fakeroot must be installed
if using the
'fakeroot' option
")"
1492 plain
"$(gettext "in the BUILDENV array
in %s.
")" "$MAKEPKG_CONF"
1495 elif [ $EUID -gt 0 ]; then
1496 warning
"$(gettext "Running makepkg as an unprivileged user will result
in non-root
")"
1497 plain
"$(gettext "ownership of the packaged files. Try using the fakeroot environment by
")"
1498 plain
"$(gettext "placing
'fakeroot' in the BUILDENV array
in %s.
")" "$MAKEPKG_CONF"
1502 if [ -z "$FAKEROOTKEY" ]; then
1503 error
"$(gettext "Do not use the
'-F' option. This option is only
for use by makepkg.
")"
1504 exit 1 # TODO: error code
1508 # check for sudo if we will need it during makepkg execution
1509 if [ "$ASROOT" -eq 0 \
1510 -a \
( "$DEP_BIN" -eq 1 -o "$RMDEPS" -eq 1 -o "$INSTALL" -eq 1 \
) ]; then
1511 if [ ! "$(type -p sudo)" ]; then
1512 error
"$(gettext "Cannot
find the sudo binary
! Is sudo installed?
")"
1513 plain
"$(gettext "Missing dependencies cannot be installed or removed as a normal user
")"
1514 plain
"$(gettext "without sudo
; install and configure sudo to auto-resolve dependencies.
")"
1519 unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
1520 unset md5sums replaces depends conflicts backup
source install build
1521 unset makedepends optdepends options noextract
1523 if [ ! -f "$BUILDSCRIPT" ]; then
1525 error
"$(gettext "%s does not exist.
")" "$BUILDSCRIPT"
1528 # PKGBUILD passed through a pipe
1529 BUILDSCRIPT
=/dev
/stdin
1532 crlftest
=$
(file $BUILDSCRIPT |
grep -F 'CRLF' || true
)
1533 if [ -n "$crlftest" ]; then
1534 error
"$(gettext "%s contains CRLF characters and cannot be sourced.
")" "$BUILDSCRIPT"
1539 source "$BUILDSCRIPT"
1541 if [ "$GENINTEG" -eq 1 ]; then
1549 if [ "$(type -t package)" = "function" ]; then
1553 # check for no-no's in the build script
1554 if [ -z "$pkgname" ]; then
1555 error
"$(gettext "%s is not allowed to be empty.
")" "pkgname"
1558 if [ -z "$pkgver" ]; then
1559 error
"$(gettext "%s is not allowed to be empty.
")" "pkgver"
1562 if [ -z "$pkgrel" ]; then
1563 error
"$(gettext "%s is not allowed to be empty.
")" "pkgrel"
1566 if [ "$pkgver" != "${pkgver//-/}" ]; then
1567 error
"$(gettext "%s is not allowed to contain hyphens.
")" "pkgver"
1570 if [ "$pkgrel" != "${pkgrel//-/}" ]; then
1571 error
"$(gettext "%s is not allowed to contain hyphens.
")" "pkgrel"
1575 if [ "$arch" = 'any' ]; then
1579 pkgbase
=${pkgbase:-${pkgname[0]}}
1581 if ! in_array
$CARCH ${arch[@]}; then
1582 if [ "$IGNOREARCH" -eq 0 ]; then
1583 error
"$(gettext "%s is not available
for the
'%s' architecture.
")" "$pkgbase" "$CARCH"
1584 plain
"$(gettext "Note that many packages may need a line added to their
%s
")" "$BUILDSCRIPT"
1585 plain
"$(gettext "such as arch
=('%s').
")" "$CARCH"
1590 for provide
in ${provides[@]}; do
1591 if [ $provide != ${provide//</} -o $provide != ${provide//>/} ]; then
1592 error
"$(gettext "Provides array cannot contain comparison
(< or
>) operators.
")"
1598 if [ "$install" -a ! -f "$install" ]; then
1599 error
"$(gettext "Install scriptlet
(%s
) does not exist.
")" "$install"
1604 for opt
in ${options[@]}; do
1606 # check if option matches a known option or its inverse
1607 for kopt
in ${packaging_options[@]} ${other_options[@]}; do
1608 if [ "${opt}" = "${kopt}" -o "${opt}" = "!${kopt}" ]; then
1612 if [ $known -eq 0 ]; then
1613 error
"$(gettext "options array contains unknown option
'%s'")" "$opt"
1617 if [ $valid_options -eq 0 ]; then
1620 unset valid_options opt known kopt
1622 # We need to run devel_update regardless of whether we are in the fakeroot
1623 # build process so that if the user runs makepkg --forcever manually, we
1624 # 1) output the correct pkgver, and 2) use the correct filename when
1625 # checking if the package file already exists - fixes FS #9194
1629 if [ "${#pkgname[@]}" -gt "1" ]; then
1633 if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
1634 -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then
1635 if [ "$INSTALL" -eq 1 ]; then
1636 warning
"$(gettext "A package has already been built
, installing existing package...
")"
1640 error
"$(gettext "A package has already been built.
(use
-f to overwrite
)")"
1645 # Run the bare minimum in fakeroot
1646 if [ "$INFAKEROOT" -eq 1 ]; then
1647 if [ "$SPLITPKG" -eq 0 ]; then
1648 if [ "$PKGFUNC" -eq 0 ]; then
1649 if [ "$REPKG" -eq 0 ]; then
1659 for pkg
in ${pkgname[@]}; do
1660 pkgdir
="$pkgdir/$pkg"
1662 backup_package_variables
1666 restore_package_variables
1667 pkgdir
="${pkgdir%/*}"
1671 msg
"$(gettext "Leaving fakeroot environment.
")"
1675 msg
"$(gettext "Making package
: %s
")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
1677 # if we are creating a source-only package, go no further
1678 if [ "$SOURCEONLY" -ne 0 ]; then
1679 if [ -f "$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}" \
1680 -a "$FORCE" -eq 0 ]; then
1681 error
"$(gettext "A package has already been built.
(use
-f to overwrite
)")"
1685 msg
"$(gettext "Source package created
: %s
")" "$pkgbase ($(date))"
1689 # fix flyspray bug #5973
1690 if [ "$NODEPS" -eq 1 -o "$NOBUILD" -eq 1 -o "$REPKG" -eq 1 ]; then
1691 # no warning message needed for nobuild, repkg
1692 if [ "$NODEPS" -eq 1 ]; then
1693 warning
"$(gettext "Skipping dependency checks.
")"
1695 elif [ $
(type -p pacman
) ]; then
1696 unset pkgdeps
# Set by resolve_deps() and used by remove_deps()
1699 msg
"$(gettext "Checking Runtime Dependencies...
")"
1700 resolve_deps
${depends[@]} || deperr
=1
1702 msg
"$(gettext "Checking Buildtime Dependencies...
")"
1703 resolve_deps
${makedepends[@]} || deperr
=1
1705 if [ $deperr -eq 1 ]; then
1706 error
"$(gettext "Could not resolve all dependencies.
")"
1710 warning
"$(gettext "pacman was not found
in PATH
; skipping dependency checks.
")"
1713 # ensure we have a sane umask set
1716 # get back to our src directory so we can begin with sources
1720 if [ "$NOEXTRACT" -eq 1 ]; then
1721 warning
"$(gettext "Skipping
source retrieval
-- using existing src
/ tree
")"
1722 warning
"$(gettext "Skipping
source integrity checks
-- using existing src
/ tree
")"
1723 warning
"$(gettext "Skipping
source extraction
-- using existing src
/ tree
")"
1725 if [ "$NOEXTRACT" -eq 1 -a -z "$(ls "$srcdir" 2>/dev/null)" ]; then
1726 error
"$(gettext "The
source directory is empty
, there is nothing to build
!")"
1727 plain
"$(gettext "Aborting...
")"
1730 elif [ "$REPKG" -eq 1 ]; then
1731 if [ "$PKGFUNC" -eq 0 -a "$SPLITPKG" -eq 0 \
1732 -a \
( ! -d "$pkgdir" -o -z "$(ls "$pkgdir" 2>/dev/null)" \
) ]; then
1733 error
"$(gettext "The package directory is empty
, there is nothing to repackage
!")"
1734 plain
"$(gettext "Aborting...
")"
1743 if [ "$NOBUILD" -eq 1 ]; then
1744 msg
"$(gettext "Sources are ready.
")"
1747 # check for existing pkg directory; don't remove if we are repackaging
1749 -a \
( "$REPKG" -eq 0 -o "$PKGFUNC" -eq 1 -o "$SPLITPKG" -eq 1 \
) ]; then
1750 msg
"$(gettext "Removing existing pkg
/ directory...
")"
1756 # if we are root or if fakeroot is not enabled, then we don't use it
1757 if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then
1758 if [ "$REPKG" -eq 0 ]; then
1762 if [ "$SPLITPKG" -eq 0 ]; then
1763 if [ "$PKGFUNC" -eq 1 ]; then
1766 elif [ "$REPKG" -eq 0 ]; then
1771 for pkg
in ${pkgname[@]}; do
1772 pkgdir
="$pkgdir/$pkg"
1774 backup_package_variables
1778 restore_package_variables
1779 pkgdir
="${pkgdir%/*}"
1783 if [ "$REPKG" -eq 0 -a \
( "$PKGFUNC" -eq 1 -o "$SPLITPKG" -eq 1 \
) ]; then
1789 msg
"$(gettext "Entering fakeroot environment...
")"
1791 if [ -n "$newpkgver" ]; then
1792 fakeroot
-- $0 --forcever $newpkgver -F $ARGLIST ||
exit $?
1794 fakeroot
-- $0 -F $ARGLIST ||
exit $?
1799 msg
"$(gettext "Finished making
: %s
")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
1805 # vim: set ts=2 sw=2 noet: