diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-13 14:19:36 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-13 14:19:36 -0500 |
commit | b72653f654882335026d04de5c25ea02c20e8412 (patch) | |
tree | beb1ee4ad86e23396a09a61dda58c9804c2a5495 /src/diff-unfree | |
parent | 27d4291f8404cfa8992492211df6ed7042f6036e (diff) |
clean up some misc scripts
Diffstat (limited to 'src/diff-unfree')
-rwxr-xr-x | src/diff-unfree | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/src/diff-unfree b/src/diff-unfree index a0a8d63..24ada67 100755 --- a/src/diff-unfree +++ b/src/diff-unfree @@ -20,66 +20,67 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see <http://www.gnu.org/licenses/>. -source /etc/libretools.conf -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf - -[[ "$1" == "--help" ]] && { - msg "Diff-Unfree helps you diff build scripts from ABSLibre against - (Unfree) ABS. Package name and repo will we guessed if you don't - specify them." - msg2 "Usage: $0 [community|packages] [unfree-package] [repo]" - exit 0 -} +. /etc/libretools.conf + +cmd=${0##*/} -[[ ! -r PKGBUILD ]] && { - error "This is not a build dir." - exit 1 +usage() { + echo "Usage: $cmd [community|packages] [unfree-package] [repo]" + echo "Usage: $cmd --help" + echo "Helps you diff build scripts from ABSLibre against (Unfree) ABS." + echo "" + echo "Package name and repo will we guessed if you don't specify them." } -package_guess=$(basename $PWD) +main() { + if [[ "$1" == "--help" ]]; then + usage + exit 0 + fi -repo=${1:-$(basename $(dirname $PWD))} -package=${2:-${package_guess/-libre}} -trunk=${3:-trunk} + local package_guess=${PWD##*/} + local repo=${1:-$(basename ${PWD%/*})} + local package=${2:-${package_guess%-libre}} + local trunk=${3:-trunk} -tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) + svnrepo="packages" + case $repo in + community*) svnrepo="community";; + multilib*) svnrepo="community";; + *) :;; + esac -svnrepo="packages" -case $repo in - community*) - svnrepo="community" - ;; - multilib*) - svnrepo="community" - ;; - *) - ;; -esac + if [[ ! -r PKGBUILD ]]; then + error "This is not a build dir." + exit 1 + fi -unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -[[ ! -d "${tmp_dir}" ]] && { - error "Can't create temp dir" - exit 1 -} + tmp_dir="$(mktemp --tmpdir -d ${package}.XXXXXX)" + if [[ ! -d "${tmp_dir}" ]]; then + error "Can't create temp dir" + exit 1 + fi + unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -stdnull 'pushd "${tmp_dir}"' + stdnull 'pushd "${tmp_dir}"' -msg "Getting diff from $repo/$package..." + msg "Getting diff from $repo/$package..." -stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' + stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' -cd ${svnrepo} -svn update ${package} + cd ${svnrepo} + svn update ${package} -# Back to start dir -stdnull popd + # Back to start dir + stdnull popd -msg "Diffing files" + msg "Diffing files" -for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" - ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" -done + for _file in ${unfree_dir}/*; do + msg2 "$(basename "${_file}")" + ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" + done +} -exit $? +main "$@" |