aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pkg
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 14:53:38 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 11:51:24 +0200
commit4bcb5a84fd7d1ee1da85376a866057b1a2fda1c9 (patch)
tree76d2e0ec73975d45b559089d4bb716e550d9423b /scripts/pkg
parent[RELEASE] flxutils-0.1.21 (diff)
downloadflxutils-4bcb5a84fd7d1ee1da85376a866057b1a2fda1c9.tar.gz
[RELEASE] flxutils-0.1.22v0.1.22
Diffstat (limited to 'scripts/pkg')
-rwxr-xr-xscripts/pkg299
1 files changed, 267 insertions, 32 deletions
diff --git a/scripts/pkg b/scripts/pkg
index 460b8f7..271fc81 100755
--- a/scripts/pkg
+++ b/scripts/pkg
@@ -1,6 +1,6 @@
#!/bin/bash
-# pkg - Formilux package builder - version 0.3.18 - 2003-11-11
+# pkg - Formilux package builder - version 0.4.3 - 2004-01-23
#
# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
# mailto: benoit@ant-computing.com,willy@ant-computing.com
@@ -15,6 +15,7 @@
# pkg <action> [ pkg [ pkg2 ] ]
#
# pkg newpkg [ new_pkg [ old_pkg ] ]
+# [new_pkg]=[old_pkg]
# ex: pkg newpkg openssl-0.9.6g-flx0.1 openssl-0.9.6d-flx0.1
# pkg newpkg apache apache-1.3
# pkg newpkg bash
@@ -511,11 +512,17 @@ function do_newpkg {
if [ $# -gt 0 ]; then
# the user has specified an explicit version string
- new_name=$1
+ # either it's the complete name, or it's the complete name followed
+ # by an '=' sign preceding the old name.
+ new_name=${1%%=*}
if [ $# -gt 1 ]; then
pkg_name=$2
+ elif [ "$new_name" != "$1" ]; then
+ pkg_name=${1##*=}
fi
- else
+ fi
+
+ if [ -z "$new_name" ]; then
# the user has not specified any version string, we'll use the directory
# name.
new_name=$(basename $(pwd))
@@ -554,9 +561,12 @@ function do_newpkg {
local i=0
echo; echo ">>> Please select the name of the package to create :";echo
while [ $i -lt ${#sort_list[*]} ]; do
- # we'll display an 'R' in front of released names, or a 'D' for dev.
- if [ "${rel_list[*]/${sort_list[$i]}/}" != "${rel_list[*]}" ]; then
+ # we'll display an 'R' in front of released names, 'P'
+ # in front of packaged ones, or a 'D' for dev.
+ if [ -e "$PKGROOT/${sort_list[$i]}/RELEASED" ]; then
printf " %5d : [R] %s\n" $[$i+1] ${sort_list[$i]}
+ elif [ "${rel_list[*]/${sort_list[$i]}/}" != "${rel_list[*]}" ]; then
+ printf " %5d : [P] %s\n" $[$i+1] ${sort_list[$i]}
else
printf " %5d : [D] %s\n" $[$i+1] ${sort_list[$i]}
fi
@@ -636,9 +646,11 @@ function do_newpkg {
fi
rm -f ${LINKNAME} && mkdir -p $new_name && ln -s $new_name ${LINKNAME} && \
- tar -C $pkg_name --exclude='./compiled/*' --exclude='./released.*' --exclude='./pkg.*' \
+ tar -C $pkg_name --exclude='./compiled/*' --exclude='./RELEASED*' --exclude='./pkg.*' \
--exclude='./CFLAGS' --exclude='./.dep' --exclude='./.lst' --exclude='./.tgz' \
-cplf - . | tar -C $new_name -xf - || (rmdir $new_name ; rm -f ${LINKNAME})
+ chmod u+rw $new_name/build.cfg
+
echo "A new package '$(basename $new_name)' has been created as '$new_name', based on '$(basename $pkg_name)'."
echo "The link '${LINKNAME}' now points to it."
echo
@@ -652,8 +664,13 @@ function do_newpkg {
function do_edit {
- echo "Editing $CFGFILE..."
- vi $CFGFILE
+ if [ -e "$PKGDIR/RELEASED" ]; then
+ echo "Editing $CFGFILE in read-only mode..."
+ vi -R $CFGFILE
+ else
+ echo "Editing $CFGFILE..."
+ vi $CFGFILE
+ fi
}
function do_cat {
@@ -685,7 +702,24 @@ function pre_info {
else
echo "does not exist yet."
fi
- [ -n "${PATCH_LIST}" ] && echo " Patches list : ${PATCH_LIST}"
+ if [ -n "${PATCH_LIST}" ]; then
+ echo " Patches list : ${PATCH_LIST}"
+ else
+ echo " Empty patch list."
+ fi
+
+ if [ -e "$PKGDIR/ChangeLog" ]; then
+ echo " Last ChangeLog : $(grep -m 1 '^[0-9]\{4\}' $PKGDIR/ChangeLog)"
+ else
+ echo " No ChangeLog."
+ fi
+
+ if [ -e "$PKGDIR/RELEASED" ]; then
+ echo " Tagged as RELEASED"
+ else
+ echo " UNRELEASED."
+ fi
+
return 0
}
@@ -909,7 +943,7 @@ function _do_pack_files {
get_perl_depend $REPLY
;;
*:\ symbolic\ link*)
- echo "$REPLY $(echo $flr | cut -f5 -d' ')" >> $DEP_FILE
+ echo "$REPLY $(readlink $REPLY)" >> $DEP_FILE
;;
*\ ELF\ [0-9][0-9]-bit\ *dynamically\ linked*)
echo "$REPLY $(ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' ')" >> $DEP_FILE
@@ -1057,7 +1091,7 @@ function do_pack {
get_perl_depend $REPLY
;;
*:\ symbolic\ link*)
- echo "$REPLY $(echo $flr | cut -f5 -d' ')" >> $DEP_FILE
+ echo "$REPLY $(readlink $REPLY)" >> $DEP_FILE
;;
*\ ELF\ [0-9][0-9]-bit\ *dynamically\ linked*)
echo "$REPLY $(ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' ')" >> $DEP_FILE
@@ -1090,20 +1124,133 @@ function do_pack {
return 0
}
+# this function sets all needed compiler options
+function set_compiler_options {
+ # now we'll set default ARCH and CPU for the current FLXARCH if none is set.
+ case "$FLXARCH" in
+ i686) arch=${arch:-i686} cpu=${cpu:-i686} basearch=${basearch:-i386} ;;
+ i586) arch=${arch:-i586} cpu=${cpu:-i686} basearch=${basearch:-i386} ;;
+ i486) arch=${arch:-i486} cpu=${cpu:-i486} basearch=${basearch:-i386} ;;
+ i386) arch=${arch:-i386} cpu=${cpu:-i386} basearch=${basearch:-i386} ;;
+ ev[456]*) arch=${arch:-$FLXARCH} cpu=${cpu:-$FLXARCH} basearch=${basearch:-$FLXARCH} ;;
+ parisc) arch=${arch:-1.1} cpu=${cpu:-7100LC} basearch=${basearch:-1.1} ;;
+ sparc) arch=${arch:-sparc} cpu=${cpu:-sparc} basearch=${basearch:-sparc} ;;
+ sparc64) arch=${arch:-ultrasparc} cpu=${cpu:-ultrasparc} basearch=${basearch:-ultrasparc} ;;
+ *) arch=${arch:-i586} cpu=${cpu:-i686} basearch=${basearch:-i386} ;;
+ esac
+
+ case "$FLXARCH" in
+ *86)
+ CC=${CC:-gcc}
+ FLX_ARCH_CURRENT="$FLXARCH"
+ FLX_ARCH_COMMON="i586"
+ FLX_ARCH_SMALL="$basearch"
+ GCC_ARCH_CURRENT="-march=$arch"
+ GCC_ARCH_COMMON="-march=$FLX_ARCH_COMMON"
+ GCC_ARCH_SMALL="-march=$FLX_ARCH_SMALL"
+ GCC_CPU_CURRENT="-mcpu=$cpu"
+ GCC_CPU_COMMON="-mcpu=$FLX_ARCH_COMMON"
+ GCC_CPU_SMALL="-mcpu=$FLX_ARCH_SMALL"
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -malign-jumps=0"
+ GCC_OPT_SMALL="-Os -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -malign-jumps=0 -malign-loops=0 -malign-functions=0"
+ if [ $TESTGCC -gt 0 ] && $CC -falign-loops=0 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -falign-jumps=0"
+ GCC_OPT_SMALL="-Os -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -falign-jumps=0 -falign-loops=0 -falign-functions=0"
+ fi
+ ;;
+
+ parisc*)
+ CC=${CC:-gcc}
+ FLX_ARCH_CURRENT="${FLXARCH##parisc}" ; FLX_ARCH_CURRENT="${FLX_ARCH_CURRENT:-1.1}"
+ FLX_ARCH_COMMON="1.0"
+ FLX_ARCH_SMALL="1.0"
+ GCC_ARCH_CURRENT="-march=$FLX_ARCH_CURRENT"
+ GCC_ARCH_COMMON="-march=$FLX_ARCH_COMMON"
+ GCC_ARCH_SMALL="-march=$FLX_ARCH_SMALL"
+ GCC_CPU_CURRENT="-mschedule=7100LC"
+ GCC_CPU_COMMON="-mschedule=7100"
+ GCC_CPU_SMALL="-mschedule=7100"
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -falign-jumps=0"
+ GCC_OPT_SMALL="-Os -falign-jumps=0 -falign-loops=0 -falign-functions=0"
+ ;;
+
+ sparc*)
+ CC=${CC:-gcc}
+ FLX_ARCH_CURRENT="$FLXARCH"
+ FLX_ARCH_COMMON="$FLXARCH"
+ FLX_ARCH_SMALL="$FLXARCH"
+ GCC_ARCH_CURRENT="-mcpu=$arch"
+ GCC_ARCH_COMMON="-mcpu=$arch"
+ GCC_ARCH_SMALL="-mcpu=$arch"
+ GCC_CPU_CURRENT="-mtune=$cpu"
+ GCC_CPU_COMMON="-mtune=$cpu"
+ GCC_CPU_SMALL="-mtune=$cpu"
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -falign-jumps=0"
+ GCC_OPT_SMALL="-Os -falign-jumps=0 -falign-loops=0 -falign-functions=0"
+ ;;
+
+ ev[456]*)
+ CC=${CC:-gcc}
+ FLX_ARCH_CURRENT="$FLXARCH"
+ FLX_ARCH_COMMON="$FLXARCH"
+ FLX_ARCH_SMALL="$FLXARCH"
+ GCC_ARCH_CURRENT="-mcpu=$arch"
+ GCC_ARCH_COMMON="-mcpu=$arch"
+ GCC_ARCH_SMALL="-mcpu=$arch"
+ GCC_CPU_CURRENT="-mtune=$cpu"
+ GCC_CPU_COMMON="-mtune=$cpu"
+ GCC_CPU_SMALL="-mtune=$cpu"
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -falign-jumps=0"
+ GCC_OPT_SMALL="-Os -falign-jumps=0 -falign-loops=0 -falign-functions=0"
+ ;;
+
+ *)
+ CC=${CC:-gcc}
+ FLX_ARCH_CURRENT="$FLXARCH"
+ FLX_ARCH_COMMON="$FLXARCH"
+ FLX_ARCH_SMALL="$FLXARCH"
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -malign-jumps=0"
+ GCC_OPT_SMALL="-Os -malign-jumps=0 -malign-loops=0 -malign-functions=0"
+ if [ $TESTGCC -gt 0 ] && $CC -falign-loops=0 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then
+ GCC_OPT_FASTEST="-O3 -fomit-frame-pointer"
+ GCC_OPT_FAST="-O2 -falign-jumps=0"
+ GCC_OPT_SMALL="-Os -falign-jumps=0 -falign-loops=0 -falign-functions=0"
+ fi
+ ;;
+ esac
+
+ export FLX_ARCH_CURRENT FLX_ARCH_COMMON FLX_ARCH_SMALL
+ export CC GCC_ARCH_CURRENT GCC_ARCH_COMMON GCC_ARCH_SMALL
+ export GCC_CPU_CURRENT GCC_CPU_COMMON GCC_CPU_SMALL
+ export GCC_OPT_FASTEST GCC_OPT_FAST GCC_OPT_SMALL
+
+ return 0
+}
+
function usage {
+ # this is needed to present current options to the user
+ set_compiler_options
+
echo "Usage:"
echo " pkg [-options]* <action> [ pkg [ pkg2 ] ]"
echo
echo " pkg newpkg [ new_pkg [ old_pkg ] ]"
+ echo " pkg newpkg [ newpkg ]=[ old_pkg ]"
echo " ex: pkg newpkg openssl-0.9.6g-${BUILDSFX}${BUILDVER}.1 openssl-0.9.6d-${BUILDSFX}${BUILDVER}.1"
- echo " pkg newpkg apache apache-1.3"
+ echo " pkg newpkg =apache-1.3"
echo " pkg newpkg bash"
echo " pkg newpkg gcc gcc-3*${BUILDSFX}*.1"
echo
echo " pkg setpkg [ new_pkg ]"
echo " ex: pkg setpkg openssl-0.9.6g-${BUILDSFX}${BUILDVER}.1"
echo
- echo " pkg { info | cat | edit | unpack } [ pkg ]"
+ echo " pkg { info | cat | edit | unpack | changelog } [ pkg ]"
echo " ex: pkg info"
echo " pkg info bash"
echo " pkg edit modutils-2.4"
@@ -1122,6 +1269,16 @@ function usage {
echo "ROOTDIR : base directory for package installation (not source), <$ROOTDIR>"
echo "FLXARCH : architecture to use for the package, <$FLXARCH>"
echo "KERNDIR : kernel sources location, if needed, <$KERNDIR>"
+ echo
+ echo "Architecture-specific variables :"
+ echo -e " CURRENT\t|COMMON\t|SMALL"
+ echo -e "FLX_ARCH_ : $FLX_ARCH_CURRENT\t| $FLX_ARCH_COMMON\t| $FLX_ARCH_SMALL"
+ echo -e "GCC_ARCH_ : $GCC_ARCH_CURRENT\t| $GCC_ARCH_COMMON\t| $GCC_ARCH_SMALL"
+ echo -e "GCC_CPU_ : $GCC_CPU_CURRENT\t| $GCC_CPU_COMMON\t| $GCC_CPU_SMALL"
+ echo "GCC_OPT_FASTEST=$GCC_OPT_FASTEST"
+ echo "GCC_OPT_FAST=$GCC_OPT_FAST"
+ echo "GCC_OPT_SMALL=$GCC_OPT_SMALL"
+
# Those two are not user-settable anymore
# echo "CFGFILE : force to use of a .pkg, <$CFGFILE>"
# echo "DISTVER : build version (${BUILDSFX}${BUILDVER}.1)"
@@ -1134,11 +1291,80 @@ function do_help {
return 0
}
+# creates a new changelog entry and prompts the user to add information.
+function do_changelog {
+ # Let's create a new changelog entry
+ (echo '0a'; date +"%Y/%m/%d %H:%M $LOGNAME@$HOSTNAME";
+ echo ''; echo $'\t* '; echo ''; echo '.' ;
+ echo '1,$wq') | ed $PKGDIR/ChangeLog >/dev/null
+
+ # we'll ask the user to fill the changelog
+ vi -c ":3" $PKGDIR/ChangeLog
+ return 0
+}
+
+# marks the current package as released
function do_release {
+ local last_pkg
+
echo "#####################################################"
echo "# Release command not implemented yet ! Aborting... #"
echo "#####################################################"
- exit 1
+ #exit 1
+ # some important checks before things get wrong
+ if [ -z "$PKGROOT" -o -z "$PKGDIR" -o -z "$EXACTPKG" ]; then
+ echo "Critical error : PKGROOT, PKGDIR and EXACTPKG must be set !"
+ exit 1
+ fi
+
+ if ! [ -s "$PKGDIR/.lst" -a -e "$PKGDIR/.dep" -a -s "$PKGDIR/.tgz" ]; then
+ echo "Nothing to be released in this package."
+ echo "Please ensure that .lst, .dep and .tgz exist."
+ exit 1
+ fi
+
+ # first, the destination directory must not exist
+ if [ -d "$PKGROOT/$EXACTPKG" ]; then
+ if [ -e "$PKGROOT/$EXACTPKG/RELEASED" ]; then
+ echo "Error: This package already exists."
+ else
+ echo "Error: The package directory $PKGROOT/$EXACTPKG already exists."
+ fi
+ exit 1
+ fi
+
+ # identify last changelog entry
+ last_pkg=""
+ if [ -e "$PKGDIR/ChangeLog" ]; then
+ last_pkg=$(grep -m 1 $'^[\t ]*\* released' "$PKGDIR/ChangeLog")
+ last_pkg=${last_pkg##*released }
+ fi
+
+ if [ "$last_pkg" != "$EXACTPKG" ]; then
+ # Let's create a new changelog entry
+ touch $PKGDIR/ChangeLog # avoid error message in case it doesn't exist
+ (echo '0a'; date +"%Y/%m/%d %H:%M $LOGNAME@$HOSTNAME";
+ echo ''; echo $'\t'"* released $EXACTPKG";
+ echo ''; echo '.' ; echo '1,$wq') | ed $PKGDIR/ChangeLog >/dev/null
+ fi
+
+ # we'll ask the user to fill the changelog
+ vi -c ":4" $PKGDIR/ChangeLog
+
+#<FIXME.WTA>
+#traiter le cas où PKGROOT/PKGDIR existe déjà mais pour d'autres archi
+#</FIXME>
+
+ if ! mv $PKGDIR $PKGROOT/ ; then
+ echo "Error: cannot move the package to the released directory. Cancelling."
+ # the mv here fails atomically, so nothing's lost in PKGDIR, but we have
+ # to clean a possible partial copy
+ rm -rf $PKGROOT/$EXACTPKG
+ exit 2
+ fi
+
+ touch $PKGROOT/$EXACTPKG/RELEASED
+
return 0
}
@@ -1162,6 +1388,7 @@ function known_cmd {
release_only=0
force=0
+TESTGCC=0
PRINTUSAGE=0
ARGLIST=( )
ACTION=
@@ -1207,7 +1434,7 @@ done
while [ $CHAINCMD -gt 0 -a ${#ARGLIST[@]} -gt 0 ]; do
set -o noglob
ACTION=${ARGLIST[0]}
-
+ TESTGCC=0
# unset ARGLIST[0] ### doesn't work in scripts with this shitty bash !!!
ARGLIST[0]= ; ARGLIST=( ${ARGLIST[*]} ) # gets expanded with shitty bash !
@@ -1222,7 +1449,7 @@ while [ $CHAINCMD -gt 0 -a ${#ARGLIST[@]} -gt 0 ]; do
KNOWNCMD=1
get_name $1 %P default
;;
- info|edit|cat|unpack)
+ info|edit|cat|unpack|changelog)
CHAINCMD=0
KNOWNCMD=1
get_name ${ARGLIST[0]} %L %P %D
@@ -1231,17 +1458,27 @@ while [ $CHAINCMD -gt 0 -a ${#ARGLIST[@]} -gt 0 ]; do
CHAINCMD=0
KNOWNCMD=1
REPLY=$(basename $(readlink ${LINKNAME}) 2>/dev/null)
+ PKGDIR=$(readlink ${LINKNAME} 2>/dev/null)
# get_name %L
;;
- compile_only|config|config_only|compile|build|prepack|strip|pack|delpack|release|clean)
+ compile_only|config|config_only|compile|build)
KNOWNCMD=1
REPLY=$(basename $(readlink ${LINKNAME}) 2>/dev/null)
+ PKGDIR=$(readlink ${LINKNAME} 2>/dev/null)
+ TESTGCC=1
+ # get_name %L
+ ;;
+ prepack|strip|pack|delpack|release|clean)
+ KNOWNCMD=1
+ REPLY=$(basename $(readlink ${LINKNAME}) 2>/dev/null)
+ PKGDIR=$(readlink ${LINKNAME} 2>/dev/null)
# get_name %L
;;
*)
CHAINCMD=0
KNOWNCMD=0
REPLY=$(basename $(readlink ${LINKNAME}) 2>/dev/null)
+ PKGDIR=$(readlink ${LINKNAME} 2>/dev/null)
# get_name %L
;;
esac
@@ -1256,10 +1493,12 @@ while [ $CHAINCMD -gt 0 -a ${#ARGLIST[@]} -gt 0 ]; do
fi
EXACTPKG=$REPLY
- if [ -e "$PKGROOT/$EXACTPKG/build.cfg" ]; then
- PKGDIR=$PKGROOT/$EXACTPKG
- else
- PKGDIR=$DEVROOT/$EXACTPKG
+ if [ -z "$PKGDIR" ]; then
+ if [ -e "$PKGROOT/$EXACTPKG/build.cfg" ]; then
+ PKGDIR=$PKGROOT/$EXACTPKG
+ else
+ PKGDIR=$DEVROOT/$EXACTPKG
+ fi
fi
CFGFILE=$PKGDIR/build.cfg
PKGRADIX=$(get_pkg_radix $EXACTPKG)
@@ -1271,22 +1510,18 @@ while [ $CHAINCMD -gt 0 -a ${#ARGLIST[@]} -gt 0 ]; do
# for compatibility with old functions. Not used anywhere outside this script.
packver=$EXACTPKG
pack=$PKGRADIX
-
- . $CFGFILE
fi
- case "$FLXARCH" in
- i686) arch=i686 cpu=i686 basearch=i386 ;;
- i486) arch=i486 cpu=i486 basearch=i386 ;;
- i386) arch=i386 cpu=i386 basearch=i386 ;;
- ev6) arch=ev6 cpu=ev6 basearch=ev6 ;;
- *) arch=i586 cpu=i686 basearch=i386 ;;
- esac
+ set_compiler_options
- if [ -z "$FLXMAKE" ]; then
- FLXMAKE=make
+ if [ "$ACTION" != "newpkg" ]; then
+ . $CFGFILE
fi
+ # FLXMAKE is used for sequential make and FLXPMAKE for parallel make
+ FLXMAKE=${FLXMAKE:-make}
+ FLXPMAKE=${FLXPMAKE:-$FLXMAKE}
+
export DISTVER PKGRADIX PKGVER FLXMAKE PATCH_LIST FILE_LIST
# echo "ACTION=$ACTION, KNOWNCMD=$KNOWNCMD, CHAINCMD=$CHAINCMD"