CVSTAG=""
GIT_SERVER="git://github.com/draenog"
HEAD_DETACHED=""
+DEPTH=""
RES_FILE=""
echo "\
Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--add_cvs] [-b|-ba|--build]
[-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
-[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
+[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [--depth <number>]
[-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
[-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
- setup \$CVSROOT,
--define <macro> <value>
- define a macro <macro> with value <value>,
+--depth <number>
+ - make shallow fetch
--alt_kernel <kernel>
- same as --define 'alt_kernel <kernel>'
--nodeps - rpm won't check any dependences
mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
}
+# inserts git log instead of %changelog
+# outputs name of modified file created by tempfile
+insert_gitlog() {
+ local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
+
+ # allow this being customized
+ local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
+
+ # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
+ # otherwise i'd use --date=iso here
+ # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
+ # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
+ # NOTE: changelog date is always in UTC for rpmbuild
+ # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
+ git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog
+ gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
+ sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
+ a%changelog
+ r $speclog
+ }
+ " > $specfile
+ rm -f $gitlog $speclog
+ echo $specfile
+}
+
# change dependency to specname
# common changes:
# - perl(Package::Name) -> perl-Package-Name
fi
if [ "$NOCVSSPEC" != "yes" ]; then
- if [ -d "$ASSUMED_NAME/.git" ]; then
- git fetch origin || Exit_error err_no_spec_in_repo
- elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
- if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
- echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
- exit 101
+ if [ -z "$DEPTH" ]; then
+ if [ -d "$ASSUMED_NAME/.git" ]; then
+ git fetch origin || Exit_error err_no_spec_in_repo
+ elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
+ if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
+ echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
+ exit 101
+ fi
+ Exit_error err_not_implemented
+ else
+ (
+ unset GIT_WORK_TREE
+ git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
+ # softfail if new package, i.e not yet added to cvs
+ [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
+ echo "Warning: package not in CVS - assuming new package"
+ NOCVSSPEC="yes"
+ }
+ )
fi
- Exit_error err_not_implemented
else
- (
- unset GIT_WORK_TREE
- git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
- # softfail if new package, i.e not yet added to cvs
- [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
- echo "Warning: package not in CVS - assuming new package"
- NOCVSSPEC="yes"
- }
- )
+ if [ ! -d "$ASSUMED_NAME/.git" ]; then
+ if [ ! -d "$ASSUMED_NAME" ]; then
+ mkdir $ASSUMED_NAME
+ fi
+ git init
+ git remote add origin ${GIT_SERVER}/${ASSUMED_NAME}.git
+ fi
+ git fetch "$DEPTH" origin ${CVSTAG}:remotes/origin/${CVSTAG} || {
+ echo >&2 "Error: branch $CVSTAG does not exist"
+ exit 3
+ }
fi
cvsignore_df .gitignore
fi
if [ -n "$CVSTAG" ]; then
- git checkout "$CVSTAG" -- || exit
+ git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "origin/$CVSTAG" > /dev/null || exit
git symbolic-ref -q HEAD > /dev/null &&
git merge '@{u}'
if [ -n "$CVSDATE" ]; then
local md5
if [ -f additional-md5sums ]; then
- local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
- if [ -z "$spec_rev" ]; then
- spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
- fi
- local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
md5=$(grep -s -v '^#' additional-md5sums | \
- grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
+ grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
grep -E '^[0-9a-f]{32}$')
echo "LASTLOG=$LOG" > $LASTLOG_FILE
fi
RES_FILE=$(tempfile)
+ local specfile=$(insert_gitlog $SPECFILE)
- (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
+ (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specfile; echo $? > $RES_FILE) 2>&1 |tee $LOG
RETVAL=`cat $RES_FILE`
- rm $RES_FILE
+ rm $RES_FILE $specfile
if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
if [ "$RETVAL" -eq "0" ]; then
mv $LOG $LOGDIROK
# remove spec and sources
$RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
- rm -rf $PACKAGE_DIR/.git
+ rm -rf $PACKAGE_DIR/.git .gitignore
+ cd $__PWD
+ rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
}
#---------------------------------------------
CVS_FORCE="-f"; shift;;
-d | --cvsroot )
shift; CVSROOT="${1}"; shift ;;
+ --depth )
+ DEPTH="--depth=$2"
+ shift 2
+ ;;
-g | --get )
COMMAND="get"; shift ;;
-h | --help )