I LOVE GIT :D
fakeroot patches in git friendly format.
Andrew
Andrew Fyfe wrote:
Hi,
The last set of patches were made late at night and contain several
bugs. So I've redone them.
I've split the patches up a bit more as well to make the changes
clearer. The *-move.patch files just
move large chunks into functions, the *-cleanup.patch files remove the
fakeroot code. The number at the beginning denotes what order the
patches should be applied in.
I've tested these patches out against my base repo and all works as
expected. It should fix all the fakeroot problems people are having, how
ever I've never encountered the problem described on FS#6208.
Andrew
------------------------------------------------------------------------
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
From c749e646b2f18855acadd90a9757dbb8e522593b Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 09:46:36 +0100
Subject: [PATCH 1/9] Moved commands to create package into create_package().
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 176 ++++++++++++++++++++++++++++---------------------------
1 files changed, 90 insertions(+), 86 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index 5afb285..33678fe 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -348,6 +348,95 @@ removedeps() {
fi
}
+create_package () {
+ # get some package meta info
+ builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y")
+ if [ "$PACKAGER" != "" ]; then
+ packager="$PACKAGER"
+ else
+ packager="Arch Linux (http://www.archlinux.org)"
+ fi
+ size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}')
+
+ # build a filelist - do this first to keep meta files out of the list
+ msg "Generating .FILELIST file..."
+ cd "$startdir/pkg"
+ tar cvf /dev/null * | sort >.FILELIST
+
+ # write the .PKGINFO file
+ msg "Generating .PKGINFO file..."
+ cd "$startdir/pkg"
+ echo "# Generated by makepkg $myver" >.PKGINFO
+ echo -n "# " >>.PKGINFO
+ date >>.PKGINFO
+ echo "pkgname = $pkgname" >>.PKGINFO
+ echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
+ echo "pkgdesc = $pkgdesc" >>.PKGINFO
+ echo "url = $url" >>.PKGINFO
+ echo "builddate = $builddate" >>.PKGINFO
+ echo "packager = $packager" >>.PKGINFO
+ echo "size = $size" >>.PKGINFO
+ if [ "$CARCH" != "" ]; then
+ echo "arch = $CARCH" >>.PKGINFO
+ fi
+
+ for it in "${license[@]}"; do
+ echo "license = $it" >>.PKGINFO
+ done
+ for it in "${replaces[@]}"; do
+ echo "replaces = $it" >>.PKGINFO
+ done
+ for it in "${groups[@]}"; do
+ echo "group = $it" >>.PKGINFO
+ done
+ for it in "${depends[@]}"; do
+ echo "depend = $it" >>.PKGINFO
+ done
+ for it in "${conflicts[@]}"; do
+ echo "conflict = $it" >>.PKGINFO
+ done
+ for it in "${provides[@]}"; do
+ echo "provides = $it" >>.PKGINFO
+ done
+ for it in "${backup[@]}"; do
+ echo "backup = $it" >>.PKGINFO
+ done
+
+ # TODO maybe remove this at some point
+ # warn if license array is not present or empty
+ if [ "$license" = "" ]; then
+ warning "Please add a license line to your $BUILDSCRIPT!"
+ plain "example for GPL'ed software: license=('GPL')."
+ fi
+
+ # check for an install script
+ if [ "$install" != "" ]; then
+ msg "Copying install script..."
+ cp "$startdir/$install" "$startdir/pkg/.INSTALL"
+ fi
+
+ # do we have a changelog?
+ have_changelog=0
+ if [ -f "$startdir/ChangeLog" ]; then
+ msg "Copying package changelog"
+ cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
+ have_changelog=1
+ fi
+
+ # tar it up
+ msg "Compressing package..."
+ cd "$startdir/pkg"
+
+ pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
+ comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
+ [ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
+
+ if ! tar czf $pkg_file $comp_files *; then
+ error "Failed to create package file."
+ exit 1
+ fi
+}
+
installpackage() {
if [ "$INSTALL" = "1" -a "$SUDO" = "1" ]; then
msg "Installing package with pacman -U..."
@@ -974,92 +1063,7 @@ if [ "$(check_option emptydirs)" = "n" ]; then
find -depth -type d -empty -delete;
fi
-# get some package meta info
-builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y")
-if [ "$PACKAGER" != "" ]; then
- packager="$PACKAGER"
-else
- packager="Arch Linux (http://www.archlinux.org)"
-fi
-size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}')
-
-# build a filelist - do this first to keep meta files out of the list
-msg "Generating .FILELIST file..."
-cd "$startdir/pkg"
-tar cvf /dev/null * | sort >.FILELIST
-
-# write the .PKGINFO file
-msg "Generating .PKGINFO file..."
-cd "$startdir/pkg"
-echo "# Generated by makepkg $myver" >.PKGINFO
-echo -n "# " >>.PKGINFO
-date >>.PKGINFO
-echo "pkgname = $pkgname" >>.PKGINFO
-echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
-echo "pkgdesc = $pkgdesc" >>.PKGINFO
-echo "url = $url" >>.PKGINFO
-echo "builddate = $builddate" >>.PKGINFO
-echo "packager = $packager" >>.PKGINFO
-echo "size = $size" >>.PKGINFO
-if [ "$CARCH" != "" ]; then
- echo "arch = $CARCH" >>.PKGINFO
-fi
-
-for it in "${license[@]}"; do
- echo "license = $it" >>.PKGINFO
-done
-for it in "${replaces[@]}"; do
- echo "replaces = $it" >>.PKGINFO
-done
-for it in "${groups[@]}"; do
- echo "group = $it" >>.PKGINFO
-done
-for it in "${depends[@]}"; do
- echo "depend = $it" >>.PKGINFO
-done
-for it in "${conflicts[@]}"; do
- echo "conflict = $it" >>.PKGINFO
-done
-for it in "${provides[@]}"; do
- echo "provides = $it" >>.PKGINFO
-done
-for it in "${backup[@]}"; do
- echo "backup = $it" >>.PKGINFO
-done
-
-# TODO maybe remove this at some point
-# warn if license array is not present or empty
-if [ "$license" = "" ]; then
- warning "Please add a license line to your $BUILDSCRIPT!"
- plain "example for GPL'ed software: license=('GPL')."
-fi
-
-# check for an install script
-if [ "$install" != "" ]; then
- msg "Copying install script..."
- cp "$startdir/$install" "$startdir/pkg/.INSTALL"
-fi
-
-# do we have a changelog?
-have_changelog=0
-if [ -f "$startdir/ChangeLog" ]; then
- msg "Copying package changelog"
- cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
- have_changelog=1
-fi
-
-# tar it up
-msg "Compressing package..."
-cd "$startdir/pkg"
-
-pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
-comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
-[ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
-
-if ! tar czf $pkg_file $comp_files *; then
- error "Failed to create package file."
- exit 1
-fi
+create_package
cd "$startdir"
if [ "$CLEANUP" = "1" ]; then
--
1.5.0.5
From 4944b46ebce602affc6eb8f66dd168ca1c9e8846 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 09:50:34 +0100
Subject: [PATCH 2/9] Cleaned up and simplified create_package().
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 50 ++++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index 33678fe..c91c9c7 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -349,26 +349,26 @@ removedeps() {
}
create_package () {
+ cd "$startdir/pkg"
+ msg "Creating package..."
+
# get some package meta info
- builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y")
+ local builddate=$(LC_ALL= LANG= date -u "+%a %b %e %H:%M:%S %Y")
if [ "$PACKAGER" != "" ]; then
- packager="$PACKAGER"
+ local packager="$PACKAGER"
else
- packager="Arch Linux (http://www.archlinux.org)"
+ local packager="Arch Linux (http://www.archlinux.org)"
fi
- size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}')
+ local size=$(du -sb | awk '{print $1}')
# build a filelist - do this first to keep meta files out of the list
- msg "Generating .FILELIST file..."
- cd "$startdir/pkg"
- tar cvf /dev/null * | sort >.FILELIST
+ msg2 "Generating .FILELIST file..."
+ tar -cvf /dev/null * | sort >.FILELIST
# write the .PKGINFO file
- msg "Generating .PKGINFO file..."
- cd "$startdir/pkg"
+ msg2 "Generating .PKGINFO file..."
echo "# Generated by makepkg $myver" >.PKGINFO
- echo -n "# " >>.PKGINFO
- date >>.PKGINFO
+ echo "# $(LC_ALL= LANG= date -u)" >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
echo "pkgdesc = $pkgdesc" >>.PKGINFO
@@ -380,6 +380,7 @@ create_package () {
echo "arch = $CARCH" >>.PKGINFO
fi
+ local it
for it in "${license[@]}"; do
echo "license = $it" >>.PKGINFO
done
@@ -409,31 +410,32 @@ create_package () {
plain "example for GPL'ed software: license=('GPL')."
fi
+ local comp_files
+
# check for an install script
+ # TODO: should we include ${pkgname}.install if it exists and $install is unset?
if [ "$install" != "" ]; then
- msg "Copying install script..."
- cp "$startdir/$install" "$startdir/pkg/.INSTALL"
+ msg2 "Copying install script..."
+ cp "$startdir/$install" .INSTALL
+ comp_files="$comp_files .INSTALL"
fi
# do we have a changelog?
- have_changelog=0
if [ -f "$startdir/ChangeLog" ]; then
- msg "Copying package changelog"
- cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
- have_changelog=1
+ msg2 "Copying package changelog"
+ cp "$startdir/ChangeLog" .CHANGELOG
+ comp_files="$comp_files .CHANGELOG"
fi
# tar it up
- msg "Compressing package..."
- cd "$startdir/pkg"
+ msg2 "Compressing package..."
- pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
- comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
- [ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
+ local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}"
+ comp_files="$comp_files .PKGINFO .FILELIST"
- if ! tar czf $pkg_file $comp_files *; then
+ if ! tar -czf "$pkg_file" $comp_files *; then
error "Failed to create package file."
- exit 1
+ exit 1 # TODO: error code
fi
}
--
1.5.0.5
From 589979099a2fc5547bcb50e5d15bd952b63ad2ca Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 09:55:53 +0100
Subject: [PATCH 3/9] Moved commands to tidy up package install into tidy_install().
The following sets of commands were moved into tidy_install()
* Remove info/doc files.
* Move usr/share/man to usr/man
* Compress man pages.
* Strip debug symbols from binaries/libraries.
* Remove libtool *.la files.
* Remove empty directories.
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 120 ++++++++++++++++++++++++++++--------------------------
1 files changed, 62 insertions(+), 58 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index c91c9c7..b1d00e4 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -348,6 +348,67 @@ removedeps() {
fi
}
+tidy_install () {
+ if [ "$(check_option docs)" = "n" ]; then
+ # remove info/doc files
+ msg "Removing info/doc files..."
+ cd "$startdir/pkg"
+ #fix flyspray bug #5021
+ rm -rf ${DOC_DIRS[@]}
+ fi
+
+ # move /usr/share/man files to /usr/man
+ if [ -d $startdir/pkg/usr/share/man ]; then
+ cd "$startdir"
+ mkdir -p pkg/usr/man
+ cp -a pkg/usr/share/man/* pkg/usr/man/
+ rm -rf pkg/usr/share/man
+ fi
+
+ # compress man pages
+ msg "Compressing man pages..."
+ find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do
+ ext="${i##*.}"
+ fn="${i##*/}"
+ if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
+ # update symlinks to this manpage
+ find "$startdir"/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2> /dev/null | while read ln ; do
+ rm -f "$ln"
+ ln -sf "${fn}.gz" "${ln}.gz"
+ done
+ # compress the original
+ gzip -9 "$i"
+ fi
+ done
+
+ cd "$startdir"
+
+ # strip binaries
+ if [ "$(check_option strip)" = "y" ]; then
+ msg "Stripping debugging symbols from libraries..."
+ find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
+ -exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
+ | grep -v "No such file" | grep -v "format not recognized"
+ msg "Stripping symbols from binaries..."
+ find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
+ -exec /usr/bin/strip '{}' \; 2>&1 \
+ | grep -v "No such file" | grep -v "format not recognized"
+ fi
+
+ # remove libtool (.la) files
+ if [ "$(check_option libtool)" = "n" ]; then
+ msg "Removing libtool .la files..."
+ find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
+ fi
+
+ # remove empty directories
+ if [ "$(check_option emptydirs)" = "n" ]; then
+ msg "Removing empty directories..."
+ cd "$startdir/pkg"
+ find -depth -type d -empty -delete;
+ fi
+}
+
create_package () {
cd "$startdir/pkg"
msg "Creating package..."
@@ -1006,64 +1067,7 @@ else
fi
fi
-if [ "$(check_option docs)" = "n" ]; then
- # remove info/doc files
- msg "Removing info/doc files..."
- cd "$startdir/pkg"
- #fix flyspray bug #5021
- rm -rf ${DOC_DIRS[@]}
-fi
-
-# move /usr/share/man files to /usr/man
-if [ -d $startdir/pkg/usr/share/man ]; then
- cd "$startdir"
- mkdir -p pkg/usr/man
- cp -a pkg/usr/share/man/* pkg/usr/man/
- rm -rf pkg/usr/share/man
-fi
-
-# compress man pages
-msg "Compressing man pages..."
-find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do
- ext="${i##*.}"
- fn="${i##*/}"
- if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
- # update symlinks to this manpage
- find "$startdir"/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2> /dev/null | while read ln ; do
- rm -f "$ln"
- ln -sf "${fn}.gz" "${ln}.gz"
- done
- # compress the original
- gzip -9 "$i"
- fi
-done
-
-cd "$startdir"
-
-# strip binaries
-if [ "$(check_option strip)" = "y" ]; then
- msg "Stripping debugging symbols from libraries..."
- find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
- -exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
- | grep -v "No such file" | grep -v "format not recognized"
- msg "Stripping symbols from binaries..."
- find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
- -exec /usr/bin/strip '{}' \; 2>&1 \
- | grep -v "No such file" | grep -v "format not recognized"
-fi
-
-# remove libtool (.la) files
-if [ "$(check_option libtool)" = "n" ]; then
- msg "Removing libtool .la files..."
- find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
-fi
-
-# remove empty directories
-if [ "$(check_option emptydirs)" = "n" ]; then
- msg "Removing empty directories..."
- cd "$startdir/pkg"
- find -depth -type d -empty -delete;
-fi
+tidy_install
create_package
--
1.5.0.5
From ac99fa5d97cface6bb21b49e0360b733169aa949 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:02:59 +0100
Subject: [PATCH 4/9] Cleaned up and simplified tidy_install().
Added 'LC_ALL= LANG=' to find commands for stripping symbols from binaries/libraries.
This stops the greps failing if LC_ALL or LANG != en_US|C|POSIX.
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 59 ++++++++++++++++++++++++++----------------------------
1 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index b1d00e4..b8c1f00 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -349,62 +349,59 @@ removedeps() {
}
tidy_install () {
+ cd "$startdir/pkg"
+ msg "Tidying install..."
+
if [ "$(check_option docs)" = "n" ]; then
- # remove info/doc files
- msg "Removing info/doc files..."
- cd "$startdir/pkg"
+ msg2 "Removing info/doc files..."
#fix flyspray bug #5021
rm -rf ${DOC_DIRS[@]}
fi
- # move /usr/share/man files to /usr/man
- if [ -d $startdir/pkg/usr/share/man ]; then
- cd "$startdir"
- mkdir -p pkg/usr/man
- cp -a pkg/usr/share/man/* pkg/usr/man/
- rm -rf pkg/usr/share/man
+ if [ -d usr/share/man ]; then
+ msg2 "Moving usr/share/man files to usr/man"
+ mkdir -p usr/man
+ cp -a usr/share/man/* usr/man/
+ rm -rf usr/share/man
fi
- # compress man pages
- msg "Compressing man pages..."
- find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do
- ext="${i##*.}"
- fn="${i##*/}"
+ msg2 "Compressing man pages..."
+ local manpage ext file link
+ find {usr{,/local},opt/*}/man -type f 2>/dev/null | while read manpage ; do
+ ext="${manpage##*.}"
+ file="${manpage##*/}"
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
# update symlinks to this manpage
- find "$startdir"/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2> /dev/null | while read ln ; do
- rm -f "$ln"
- ln -sf "${fn}.gz" "${ln}.gz"
+ find {usr{,/local},opt/*}/man -lname "$file" 2>/dev/null | while read link ; do
+ rm -f "$link"
+ ln -sf "${file}.gz" "${link}.gz"
done
# compress the original
- gzip -9 "$i"
+ gzip -9 "$manpage"
fi
done
- cd "$startdir"
-
- # strip binaries
if [ "$(check_option strip)" = "y" ]; then
- msg "Stripping debugging symbols from libraries..."
- find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
+ msg2 "Stripping debugging symbols from libraries..."
+ LC_ALL= LANG= \
+ find {.,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
- msg "Stripping symbols from binaries..."
- find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
+
+ msg2 "Stripping symbols from binaries..."
+ LC_ALL= LANG= \
+ find {.,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
fi
- # remove libtool (.la) files
if [ "$(check_option libtool)" = "n" ]; then
- msg "Removing libtool .la files..."
- find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
+ msg2 "Removing libtool .la files..."
+ find -type f -name "*.la" -exec rm -f -- '{}' \;
fi
- # remove empty directories
if [ "$(check_option emptydirs)" = "n" ]; then
- msg "Removing empty directories..."
- cd "$startdir/pkg"
+ msg2 "Removing empty directories..."
find -depth -type d -empty -delete;
fi
}
--
1.5.0.5
From 26eccee4fa70bed95bac6a29e120c92d7bf80a54 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:04:46 +0100
Subject: [PATCH 5/9] Moved commands to setup build environment and run build() into run_build().
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 122 ++++++++++++++++++++++++++++--------------------------
1 files changed, 63 insertions(+), 59 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index b8c1f00..873ae0e 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -348,6 +348,68 @@ removedeps() {
fi
}
+run_build () {
+ # use distcc if it is requested (check buildenv and PKGBUILD opts)
+ if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
+ [ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
+ elif [ "$(check_option distcc)" = "n" ]; then
+ # if it is not wanted, clear the makeflags too
+ export MAKEFLAGS=""
+ fi
+
+ # use ccache if it is requested (check buildenv and PKGBUILD opts)
+ if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
+ [ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
+ fi
+
+ # clear user-specified makeflags if requested
+ if [ "$(check_option makeflags)" = "n" ]; then
+ export MAKEFLAGS=""
+ fi
+
+ # build
+ msg "Starting build()..."
+
+ # some applications (eg, blackbox) will not build with some languages
+ unset LC_ALL LANG
+ umask 0022
+
+ #check for "exit on syntax error" shell option
+ echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
+ set_e=$?
+
+ ret=0
+ 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
+
+ #use 'errexit' to bail on syntax error
+ [ $set_e -eq 1 ] && set -e
+ build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
+ [ $set_e -eq 1 ] && set +e
+ else
+ #use 'errexit' to bail on syntax error
+ [ $set_e -eq 1 ] && set -e
+ build 2>&1 || ret=$?
+ [ $set_e -eq 1 ] && set +e
+ fi
+ if [ $ret -gt 0 ]; then
+ error "Build Failed. Aborting..."
+ removedeps
+ exit 2
+ fi
+}
+
tidy_install () {
cd "$startdir/pkg"
msg "Tidying install..."
@@ -1003,65 +1065,7 @@ else
fi
mkdir -p "$startdir/pkg"
- # use distcc if it is requested (check buildenv and PKGBUILD opts)
- if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
- [ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
- elif [ "$(check_option distcc)" = "n" ]; then
- # if it is not wanted, clear the makeflags too
- export MAKEFLAGS=""
- fi
-
- # use ccache if it is requested (check buildenv and PKGBUILD opts)
- if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
- [ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
- fi
-
- # clear user-specified makeflags if requested
- if [ "$(check_option makeflags)" = "n" ]; then
- export MAKEFLAGS=""
- fi
-
- # build
- msg "Starting build()..."
-
- # some applications (eg, blackbox) will not build with some languages
- unset LC_ALL LANG
- umask 0022
-
- #check for "exit on syntax error" shell option
- echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
- set_e=$?
-
- ret=0
- 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
-
- #use 'errexit' to bail on syntax error
- [ $set_e -eq 1 ] && set -e
- build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
- [ $set_e -eq 1 ] && set +e
- else
- #use 'errexit' to bail on syntax error
- [ $set_e -eq 1 ] && set -e
- build 2>&1 || ret=$?
- [ $set_e -eq 1 ] && set +e
- fi
- if [ $ret -gt 0 ]; then
- error "Build Failed. Aborting..."
- removedeps
- exit 2
- fi
+ run_build
fi
tidy_install
--
1.5.0.5
From 657464037049e300e79da22bde1953ceb27de829 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:10:36 +0100
Subject: [PATCH 6/9] Cleaned up and simplified run_build().
Restore LC_ALL and LANG after running build().
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index 873ae0e..9f3baec 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -351,7 +351,7 @@ removedeps() {
run_build () {
# use distcc if it is requested (check buildenv and PKGBUILD opts)
if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
- [ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
+ [ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH"
elif [ "$(check_option distcc)" = "n" ]; then
# if it is not wanted, clear the makeflags too
export MAKEFLAGS=""
@@ -359,7 +359,7 @@ run_build () {
# use ccache if it is requested (check buildenv and PKGBUILD opts)
if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
- [ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
+ [ -d /usr/lib/ccache/bin ] && export PATH="/usr/lib/ccache/bin:$PATH"
fi
# clear user-specified makeflags if requested
@@ -367,22 +367,23 @@ run_build () {
export MAKEFLAGS=""
fi
- # build
msg "Starting build()..."
+ cd "$startdir/src"
# some applications (eg, blackbox) will not build with some languages
+ local _LC_ALL="$LC_ALL"
+ local _LANG="$LANG"
unset LC_ALL LANG
umask 0022
- #check for "exit on syntax error" shell option
- echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
- set_e=$?
+ # check for "exit on syntax error" shell option
+ echo $SHELLOPTS | grep -q errexit ; local set_e=$?
- ret=0
+ local ret=0
if [ "$LOGGING" = "1" ]; then
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
if [ -f "$BUILDLOG" ]; then
- i=1
+ local i=1
while true; do
if [ -f "$BUILDLOG.$i" ]; then
i=$(($i +1))
@@ -393,7 +394,7 @@ run_build () {
mv "$BUILDLOG" "$BUILDLOG.$i"
fi
- #use 'errexit' to bail on syntax error
+ # use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e
build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
[ $set_e -eq 1 ] && set +e
@@ -403,10 +404,15 @@ run_build () {
build 2>&1 || ret=$?
[ $set_e -eq 1 ] && set +e
fi
+
+ # restore LC_ALL & LANG
+ export LC_ALL="$_LC_ALL"
+ export LANG="$_LANG"
+
if [ $ret -gt 0 ]; then
error "Build Failed. Aborting..."
removedeps
- exit 2
+ exit 2 # $E_BUILD_FAILED # TODO: error code
fi
}
--
1.5.0.5
From d45fec10e569707bd8dbae82f90a33ba4d36760d Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:16:18 +0100
Subject: [PATCH 7/9] Reduced the number of commands run inside fakeroot to the bare minimum.
Only the following functions now run inside fakeroot
* run_build()
* tidy_install()
* create_package ()
Added check for inproper use of '-F' option.
Added yn_question() function. Asks the user a simple yes/no question. Returns 0=Yes 1=No.
Added warning if makepkg is run as root.
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 131 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 93 insertions(+), 38 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index 9f3baec..edccd74 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -41,6 +41,7 @@ DEP_BIN=0
DEP_SRC=0
SUDO=0
FORCE=0
+INFAKEROOT=0
GENINTEG=0
INSTALL=0
NOBUILD=0
@@ -52,14 +53,6 @@ LOGGING=0
PACMAN_OPTS=
-#determine if we are running with fakeroot
-if [ "$1" = "-F" ]; then
- INFAKEROOT=1
- shift
-else
- INFAKEROOT=0
-fi
-
### SUBROUTINES ###
plain() {
@@ -102,6 +95,24 @@ error() {
fi
}
+yn_question () {
+ if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ echo -en " \033[1;1m$1\033[1;0m " >&2
+ else
+ echo -n " $1 " >&2
+ fi
+
+ local answer
+ read answer
+ answer="$(echo $answer | tr [:upper:] [:lower:])"
+
+ if [ "$answer" = 'y' -o "$answer" = 'yes' ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
strip_url() {
echo "$1" | sed 's|^.*://.*/||g'
}
@@ -675,7 +686,7 @@ while [ "$#" -ne "0" ]; do
exit 1
;;
-*)
- while getopts "bcCdefghiLmop:rRsS-" opt; do
+ while getopts "bcCdefFghiLmop:rRsS-" opt; do
case $opt in
b) DEP_SRC=1 ;;
c) CLEANUP=1 ;;
@@ -683,6 +694,7 @@ while [ "$#" -ne "0" ]; do
d) NODEPS=1 ;;
e) NOEXTRACT=1 ;;
f) FORCE=1 ;;
+ F) INFAKEROOT=1 ;;
g) GENINTEG=1 ;;
h)
usage
@@ -751,6 +763,46 @@ if [ "$CLEANCACHE" = "1" ]; then
fi
fi
+if [ "$INFAKEROOT" = "0" ]; then
+ if [ $EUID -eq 0 ]; then
+ # Warn those who like to live dangerously.
+ warning "Running makepkg as root is a \033[1;31mBAD\033[1;37m idea!"
+ plain ""
+ plain "Running makepkg as root can result in permanent, catastropic damage to "
+ plain "your system."
+ plain ""
+ if ! yn_question "Are you sure you want to continue? [N/y]"; then
+ error "Aborting..."
+ exit 1 # $E_USER_ABORT
+ fi
+ elif [ "$(check_buildenv fakeroot)" = "y" ]; then
+ if [ ! $(type -p fakeroot) ]; then
+ warning "Fakeroot is not installed. Building as an unprivileged user"
+ plain "will result in non-root ownership of the packaged files. Install"
+ plain "the fakeroot package to correctly build as a non-root user."
+ plain ""
+ if ! yn_question "Are you sure you want to continue? [N/y]"; then
+ error "Aborting..."
+ exit 1 # $E_USER_ABORT
+ fi
+ fi
+ else
+ warning "Running makepkg as an unprivileged user will result in non-root"
+ plain "ownership of the packaged files. Try using the fakeroot environment by"
+ plain "placing 'fakeroot' in the BUILDENV array in /etc/makepkg.conf"
+ plain ""
+ if ! yn_question "Are you sure you want to continue? [N/y]"; then
+ error "Aborting..."
+ exit 1 # $E_USER_ABORT
+ fi
+ fi
+else
+ if [ "$FAKEROOTKEY" = "" ]; then
+ error "Do not use the '-F' option. This option is only for use by makepkg."
+ exit 1 # TODO: error code
+ fi
+fi
+
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
unset replaces depends conflicts backup source install build makedepends
unset options noextract
@@ -810,29 +862,20 @@ if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}" \
fi
fi
-# 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 [ "$EUID" != "0" ]; then
- if [ "$(check_buildenv fakeroot)" = "y" ]; then
- if [ $(type -p fakeroot) ]; then
- msg "Entering fakeroot environment"
- fakeroot -- $0 -F $ARGLIST
- exit $?
- else
- warning "Fakeroot is not installed. Building as an unprivileged user"
- plain "will result in non-root ownership of the packaged files. Install"
- plain "the fakeroot package to correctly build as a non-root user."
- plain ""
- sleep 1
- fi
+# Run the bear minimum in fakeroot
+# fix flyspray bug 6208 -- using makepkg with fakeroot gives an error
+if [ "$INFAKEROOT" = "1" ]; then
+ if [ "$REPKG" = "1" ]; then
+ warning "Skipping build."
else
- warning "Running makepkg as an unprivileged user will result in non-root"
- plain "ownership of the packaged files. Try using the fakeroot environment"
- plain "by placing 'fakeroot' in the BUILDENV array in makepkg.conf."
- plain ""
- sleep 1
- fi
+ run_build
+ tidy_install
+ fi
+
+ create_package
+
+ msg "Leaveing fakeroot environment."
+ exit 0 # $E_OK
fi
msg "Making package: $pkgname $pkgver-$pkgrel ($(date))"
@@ -1061,22 +1104,34 @@ fi
if [ "$NOBUILD" = "1" ]; then
msg "Sources are ready."
exit 0
-elif [ "$REPKG" = "1" ]; then
- warning "Skipping build"
else
# check for existing pkg directory
- if [ -d "$startdir/pkg" ]; then
+ if [ -d "$startdir/pkg" -a "$REPKG" = "0" ]; then
msg "Removing existing pkg/ directory..."
rm -rf "$startdir/pkg"
fi
mkdir -p "$startdir/pkg"
- run_build
-fi
+ if [ $EUID -eq 0 ]; then
+ if [ "$REPKG" = "1" ]; then
+ warning "Skipping build."
+ else
+ run_build
+ tidy_install
+ fi
+
+ create_package
+ else
+ msg "Entering fakeroot environment..."
+ cd "$startdir"
-tidy_install
+ ret=0
+ fakeroot -- $0 -F $ARGLIST || ret=$?
+ [ $ret -ne 0 ] && exit $ret
-create_package
+ unset ret
+ fi
+fi
cd "$startdir"
if [ "$CLEANUP" = "1" ]; then
--
1.5.0.5
From ee17bac753ce0e1b09dab2f8d28c4cb588911669 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:21:11 +0100
Subject: [PATCH 8/9] Removed fakeroot hacks.
Removed fakeroot hacks from
* handledeps()
* removedeps()
* installpackage()
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 28 +---------------------------
1 files changed, 1 insertions(+), 27 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index edccd74..1befa2e 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -207,7 +207,7 @@ handledeps() {
local depstrip=""
local striplist=""
local haveperm=0
- if [ \( "$EUID" = "0" -a "$INFAKEROOT" != "1" \) -o "$SUDO" = 1 ]; then
+ if [ "$EUID" = "0" -o "$SUDO" = 1 ]; then
haveperm=1
fi
@@ -220,21 +220,11 @@ handledeps() {
if [ "$DEP_BIN" = "1" -a "$SUDO" = "1" ]; then
# install missing deps from binary packages (using pacman -S and sudo)
msg "Installing missing dependencies..."
- if [ "$INFAKEROOT" = "1" ]; then
- # kinda hacky, but we need to make pacman think that we're NOT
- # in fakeroot so it will go ahead and install the dependencies.
- FAKEROOTKEY2=$FAKEROOTKEY
- unset FAKEROOTKEY
- fi
sudo pacman $PACMAN_OPTS -S $striplist
if [ $? -eq 1 ]; then
error "Pacman failed to install missing dependencies."
exit 1
fi
- if [ "$INFAKEROOT" = "1" ]; then
- export FAKEROOTKEY=$FAKEROOTKEY2
- unset FAKEROOTKEY2
- fi
elif [ "$DEP_BIN" = "1" ]; then
# install missing deps from binary packages (using pacman -S)
msg "Installing missing dependencies..."
@@ -344,15 +334,7 @@ removedeps() {
if [ "$RMDEPS" = "1" -a "$SUDO" = "1" -a -n "$deplist" ]; then
msg "Removing installed dependencies..."
- if [ "$INFAKEROOT" = "1" ]; then
- export FAKEROOTKEY2=$FAKEROOTKEY
- unset FAKEROOTKEY
- fi
sudo pacman $PACMAN_OPTS -Rs $striplist
- if [ "$INFAKEROOT" = "1" ]; then
- export FAKEROOTKEY=$FAKEROOTKEY2
- unset FAKEROOTKEY2
- fi
elif [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a -n "$deplist" ]; then
msg "Removing installed dependencies..."
pacman $PACMAN_OPTS -Rs $striplist
@@ -579,16 +561,8 @@ create_package () {
installpackage() {
if [ "$INSTALL" = "1" -a "$SUDO" = "1" ]; then
msg "Installing package with pacman -U..."
- if [ "$INFAKEROOT" = "1" ]; then
- FAKEROOTKEY2=$FAKEROOTKEY
- unset FAKEROOTKEY
- fi
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
local exitcode=$?
- if [ "$INFAKEROOT" = "1" ]; then
- export FAKEROOTKEY=$FAKEROOTKEY2
- unset FAKEROOTKEY2
- fi
exit $exitcode
elif [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
msg "Installing package with pacman -U..."
--
1.5.0.5
From bd8e52575dc94818b29c68999aa930409aeede57 Mon Sep 17 00:00:00 2001
From: Andrew Fyfe
Date: Thu, 29 Mar 2007 10:28:10 +0100
Subject: [PATCH 9/9] Added support for fake_install().
Modified run_build() so it can be used to run other functions.
Added support for fake_install().
If a PKGBUILD contains a fake_install() function, build() will be run as
the user calling makepkg and fake_install() will be called inside
fakeroot. Otherwise build() will be run inside fakeroot as normal.
Signed-off-by: Andrew Fyfe
---
scripts/makepkg | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/scripts/makepkg b/scripts/makepkg
index 1befa2e..dc9038b 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -342,6 +342,12 @@ removedeps() {
}
run_build () {
+ if [ "$(type -t $1)" != "function" ]; then
+ error "Unknown function '${1}'."
+ error "Aborting..."
+ exit 1 # TODO: error code
+ fi
+
# use distcc if it is requested (check buildenv and PKGBUILD opts)
if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
[ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH"
@@ -360,7 +366,7 @@ run_build () {
export MAKEFLAGS=""
fi
- msg "Starting build()..."
+ msg "Starting ${1}()..."
cd "$startdir/src"
# some applications (eg, blackbox) will not build with some languages
@@ -374,7 +380,7 @@ run_build () {
local ret=0
if [ "$LOGGING" = "1" ]; then
- BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
+ BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-${1}.log"
if [ -f "$BUILDLOG" ]; then
local i=1
while true; do
@@ -389,12 +395,12 @@ run_build () {
# use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e
- build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
+ $1 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
[ $set_e -eq 1 ] && set +e
else
#use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e
- build 2>&1 || ret=$?
+ $1 2>&1 || ret=$?
[ $set_e -eq 1 ] && set +e
fi
@@ -842,7 +848,12 @@ if [ "$INFAKEROOT" = "1" ]; then
if [ "$REPKG" = "1" ]; then
warning "Skipping build."
else
- run_build
+ if [ "$(type -t fake_install)" != "function" ]; then
+ run_build build
+ else
+ run_build fake_install
+ fi
+
tidy_install
fi
@@ -1090,12 +1101,17 @@ else
if [ "$REPKG" = "1" ]; then
warning "Skipping build."
else
- run_build
+ run_build build
+ [ "$(type -t fake_install)" = "function" ] && run_build fake_install
tidy_install
fi
create_package
else
+ if [ "$REPKG" = "0" -a "$(type -t fake_install)" = "function" ]; then
+ run_build build
+ fi
+
msg "Entering fakeroot environment..."
cd "$startdir"
@@ -1111,7 +1127,9 @@ cd "$startdir"
if [ "$CLEANUP" = "1" ]; then
msg "Cleaning up..."
rm -rf src pkg
- rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
+ rm -f ${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log*
+ [ "$(type -t fake_install)" = "function" ] &&
+ rm -f ${pkgname}-${pkgver}-${pkgrel}-${CARCH}-fake_install.log*
fi
removedeps
@@ -1122,4 +1140,3 @@ installpackage
exit 0
# vim: set ts=2 sw=2 noet:
-
--
1.5.0.5