forked from kiss-community/kiss
kiss: Further simplify utilities.
This commit is contained in:
parent
23448e5079
commit
10333def43
@ -23,25 +23,24 @@ clean() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
[ -z "$1" ] && die Need a path to the chroot
|
||||||
[ -z "$1" ] && die Need a path to the chroot
|
[ -d "$1" ] || die Given path does not exist
|
||||||
[ -d "$1" ] || die Given path does not exist
|
[ "$(id -u)" = 0 ] || die Script needs to be run as root
|
||||||
[ "$(id -u)" = 0 ] || die Script needs to be run as root
|
|
||||||
|
|
||||||
trap 'clean "$1"' EXIT INT
|
trap 'clean "$1"' EXIT INT
|
||||||
|
|
||||||
log Mounting /dev, /proc and /sys from host; {
|
log Mounting /dev, /proc and /sys from host; {
|
||||||
mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev"
|
mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev"
|
||||||
mountpoint -q "$1/proc" || mount -t proc proc "$1/proc"
|
mountpoint -q "$1/proc" || mount -t proc proc "$1/proc"
|
||||||
mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys"
|
mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log Copying /etc/resolv.conf from host; {
|
log Copying /etc/resolv.conf from host; {
|
||||||
cp -f /etc/resolv.conf "$1/etc"
|
cp -f /etc/resolv.conf "$1/etc"
|
||||||
}
|
}
|
||||||
|
|
||||||
log Entering chroot; {
|
log Entering chroot; {
|
||||||
chroot "$1" /usr/bin/env -i \
|
chroot "$1" /usr/bin/env -i \
|
||||||
HOME=/root \
|
HOME=/root \
|
||||||
TERM="$TERM" \
|
TERM="$TERM" \
|
||||||
@ -52,7 +51,4 @@ main() {
|
|||||||
CXXFLAGS="${2:--march=x86-64 -mtune=generic -pipe -Os}" \
|
CXXFLAGS="${2:--march=x86-64 -mtune=generic -pipe -Os}" \
|
||||||
MAKEFLAGS="-j$(nproc 2>/dev/null || echo 1)" \
|
MAKEFLAGS="-j$(nproc 2>/dev/null || echo 1)" \
|
||||||
/bin/sh -l
|
/bin/sh -l
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
|
||||||
|
@ -2,45 +2,30 @@
|
|||||||
# Create a boilerplate package.
|
# Create a boilerplate package.
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
printf 'error: %s.\n' "$*" >&2
|
printf '%s\n' "$*"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
printf '=> %s.\n' "$*"
|
printf '=> %s.\n' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
[ "$1" ] || die "usage: kiss-new [name] [version] [source]"
|
||||||
[ "$1" ] || {
|
[ -d "$1" ] && die "error: Package $1 already exists"
|
||||||
log Create boilerplate KISS packages
|
mkdir -p "$1" || die "error: Couldn't create directory in $PWD"
|
||||||
log Usage: kiss-new name version source
|
cd "$1" || die "error: Couldn't enter directory $1/"
|
||||||
|
|
||||||
exit
|
log "Creating build file"; {
|
||||||
}
|
|
||||||
|
|
||||||
[ -d "$1" ] &&
|
|
||||||
die Package "$1" already exists.
|
|
||||||
|
|
||||||
mkdir -p "$1" ||
|
|
||||||
die Couldn\'t create directory in "$PWD"
|
|
||||||
|
|
||||||
cd "$1" ||
|
|
||||||
die Couldn\'t enter directory "$1/"
|
|
||||||
|
|
||||||
log Creating build file; {
|
|
||||||
printf '#!/bin/sh -e\n' > build
|
printf '#!/bin/sh -e\n' > build
|
||||||
chmod +x build
|
chmod +x build
|
||||||
}
|
|
||||||
|
|
||||||
log Creating version file with "'${2%% *} 1'"; {
|
|
||||||
printf '%s\n' "${2%% *} 1" > version
|
|
||||||
}
|
|
||||||
|
|
||||||
log Creating sources file with "'$3'"; {
|
|
||||||
printf '%s\n' "$3" > sources
|
|
||||||
}
|
|
||||||
|
|
||||||
log Package "$1" created in "$PWD"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
log "Creating version file with '${2%% *} 1'"; {
|
||||||
|
printf '%s\n' "${2%% *} 1" > version
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Creating sources file with '$3'"; {
|
||||||
|
printf '%s\n' "$3" > sources
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Package $1 created in $PWD"
|
||||||
|
Loading…
Reference in New Issue
Block a user