#!/bin/sh # # Copyright (C) 2008 Mikhail Gusarov # # hsh wrapper for building packages on tmpfs # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # . gear-sh-functions . shell-getopt print_version() { cat < Copyright (C) 2008 Mikhail Gusarov This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. EOF exit } hash_repo_dir() { echo "$1" | sed -e 's,/,_,g' } GETOPT_ALLOW_UNKNOWN=1 TEMP=`getopt -n $PROG -o 'h,V' -l 'repo:,repo-bin:,repo-src:,help,version' -- "$@"` || show_usage eval set -- "$TEMP" while :; do case "$1" in --repo|--repo-bin|--repo-src) option=$1 show_usage "hsh(1) option $1 is not supported in $PROG" exit ;; -h|--help) hsh -h | awk 'BEGIN { show=1 } /^hsh/ { $1="hsh-tmpfs"; $4="package in tmpfs" } /^Usage:/ { $0="Usage: hsh-tmpfs [options] [] ..." } /^/ { $1="" } /--repo/ { show=0 } /--save-fakeroot/ { show=1 } { if(show) print }' exit ;; -V|--version) print_version ;; --) shift break ;; esac shift done if [ $# -eq 0 ]; then show_usage "At least one argument is required" fi REPODIR=$1 shift mkdir -p "$REPODIR" || show_usage "Unable to create repository in $REPODIR" REPODIR=`realpath $REPODIR` WORKDIR=/tmp/.private/$USER/`hash_repo_dir "$REPODIR"` mkdir -p "$WORKDIR" || show_usage "Unable to create hasher worker directory in $WORKDIR" exec hsh --repo="$REPODIR" "$WORKDIR" "$@"