Commits

Guan-Zhong Huang committed 23e5cdb

vcprompt: Added (version control system prompt)

Comments (0)

Files changed (6)

vcprompt/Makefile.patch

+diff -r 6d758d5f8d44 -r de5b7ce36a62 Makefile
+--- a/Makefile	Sun Aug 28 21:55:50 2011 -0400
++++ b/Makefile	Sat Jul 21 21:10:02 2012 +0800
+@@ -1,5 +1,5 @@
+ 
+-CFLAGS = -Wall -Wextra -Wno-unused-parameter -g -O2
++CFLAGS += -Wall -Wextra -Wno-unused-parameter
+ 
+ headers = $(wildcard src/*.h)
+ sources = $(wildcard src/*.c)
+@@ -36,7 +36,7 @@
+ 	rm -f $(objects) vcprompt
+ 
+ DESTDIR =
+-PREFIX = /usr/local
++PREFIX ?= /usr/local
+ .PHONY: install
+ install: vcprompt
+ 	install -d $(DESTDIR)$(PREFIX)/bin
+vcprompt is a little C program that prints a short string, designed to be
+included in your prompt, with barebones information about the current working
+directory for various version control systems. It is designed to be small and
+lightweight rather than comprehensive.
+
+Currently, it has varying degrees of recognition for Mercurial, Git, CVS, and
+Subversion working copies.

vcprompt/hg_bookmark.patch

+diff -r 6d758d5f8d44 -r 70f5f068830f src/hg.c
+--- a/src/hg.c	Sun Aug 28 21:55:50 2011 -0400
++++ b/src/hg.c	Sat Jul 21 20:35:11 2012 +0800
+@@ -215,19 +215,26 @@
+     result_t* result = init_result();
+     char buf[1024];
+ 
+-    // prefer bookmark because it tends to be more informative
+-    if (read_first_line(".hg/bookmarks.current", buf, 1024) && buf[0]) {
+-        debug("read first line from .hg/bookmarks.current: '%s'", buf);
+-        result_set_branch(result, buf);
+-    }
+-    else if (read_first_line(".hg/branch", buf, 1024)) {
++    if (read_first_line(".hg/branch", buf, 1024)) {
+         debug("read first line from .hg/branch: '%s'", buf);
+-        result_set_branch(result, buf);
+     }
+     else {
+         debug("failed to read from .hg/branch: assuming default branch");
+-        result_set_branch(result, "default");
++        strcpy(buf, "default");
+     }
++    // append bookmark to branch if it exists
++    {
++        char bm[1024];
++        if (read_first_line(".hg/bookmarks.current", bm, 1024) && bm[0]) {
++            debug("read first line from .hg/bookmarks.current: '%s'", bm);
++            size_t l = strlen(buf);
++            buf[l++] = '|';
++            strncpy(buf + l, bm, 1024 - l);
++            buf[1023] = '\0';
++        }
++    }
++    result_set_branch(result, buf);
++
+ 
+     read_parents(context, result);
+ 
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':' except on otherwise blank lines.
+
+        |-----handy-ruler------------------------------------------------------|
+vcprompt: vcprompt (version control system prompt)
+vcprompt:
+vcprompt: vcprompt is a little C program that prints a short string, designed
+vcprompt: to be included in your prompt, with barebones information about the
+vcprompt: current working directory for various version control systems. It is
+vcprompt: designed to be small and lightweight rather than comprehensive.
+vcprompt:
+vcprompt:
+vcprompt:
+vcprompt: Home page: https://bitbucket.org/gward/vcprompt/
+vcprompt:

vcprompt/vcprompt.SlackBuild

+#!/bin/sh
+
+# Slackware build script for vcprompt
+
+# Copyright 2012  Guan-Zhong Huang, Taiwan <imprazaguy@gmail.com>
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+PRGNAM=vcprompt
+VERSION=${VERSION:-20120721_hg}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}	
+
+SRCNAM=gward-vcprompt
+COMMIT_ID=6d758d5f8d44
+SRCDIR=$SRCNAM-$COMMIT_ID
+
+if [ -z "$ARCH" ]; then
+  case "$( uname -m )" in
+    i?86) ARCH=i486 ;;
+    arm*) ARCH=arm ;;
+       *) ARCH=$( uname -m ) ;;
+  esac
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i486" ]; then
+  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+  LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+  LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+  SLKCFLAGS="-O2 -fPIC"
+  LIBDIRSUFFIX="64"
+else
+  SLKCFLAGS="-O2"
+  LIBDIRSUFFIX=""
+fi
+
+# Whether apply a patch to let mercurial bookmark appended to branch, not
+# substituted 
+HG_BOOKMARK=${HG_BOOKMARK:-no}
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $SRCDIR
+# Because wget may ignore Content-Disposition header, the downloaded filename
+# may be different. Check that and choose the right filename.
+if [ -r "$CWD/$SRCNAM-$COMMIT_ID.tar.gz" ]; then
+  tar xvf $CWD/$SRCNAM-$COMMIT_ID.tar.gz
+elif [ -r "$CWD/$COMMIT_ID.tar.gz" ]; then
+  tar xvf $CWD/$COMMIT_ID.tar.gz
+fi
+cd $SRCDIR
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \;
+
+patch -p1 < $CWD/Makefile.patch
+[ "$HG_BOOKMARK" = "yes" ] && patch -p1 < $CWD/hg_bookmark.patch
+
+CFLAGS="$SLKCFLAGS" \
+make
+make install DESTDIR=$PKG PREFIX=/usr
+
+find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
+  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a \
+  README.txt \
+  $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

vcprompt/vcprompt.info

+PRGNAM="vcprompt"
+VERSION="20120721_hg"
+HOMEPAGE="https://bitbucket.org/gward/vcprompt"
+DOWNLOAD="https://bitbucket.org/gward/vcprompt/get/6d758d5f8d44.tar.gz"
+MD5SUM="e6c187e768c5386bd593c79a085125c4"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+MAINTAINER="Guan-Zhong Huang"
+EMAIL="imprazaguy@gmail.com"
+APPROVED=""