7 Commits
0.2 ... 0.3

Author SHA1 Message Date
emmett1
0440395881 fix 2020-02-10 17:44:48 +08:00
emmett1
6dddc034f9 updated 2020-02-10 00:18:14 +08:00
emmett1
4d8f539f45 updated 2020-02-08 23:44:01 +08:00
emmett1
cfaca4e65f updated 2020-02-08 17:50:37 +08:00
emmett1
0a9cfce26a add xchroot script 2020-02-07 23:31:35 +08:00
emmett1
5eeb974b17 updated 2020-02-07 23:22:30 +08:00
emmett1
2e26f7c2f0 add package alias function 2020-02-06 13:35:11 +08:00
10 changed files with 275 additions and 112 deletions

View File

@@ -14,10 +14,9 @@ install -d ${DESTDIR}${REVDEPD}
install -dm777 ${DESTDIR}${CACHE_DIR}/packages
install -dm777 ${DESTDIR}${CACHE_DIR}/sources
install -dm777 ${DESTDIR}${CACHE_DIR}/log
install -dm777 ${DESTDIR}${CACHE_DIR}/work
install -m755 revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf ${DESTDIR}${BINDIR}
install -m644 scratchpkg.conf scratchpkg.repo ${DESTDIR}${CONFDIR}
install -m755 xchroot revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf ${DESTDIR}${BINDIR}
install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias ${DESTDIR}${CONFDIR}
install -m644 revdep.conf ${DESTDIR}${REVDEPCONF}

128
pkgadd
View File

@@ -43,7 +43,7 @@ msgwarn() {
echo "==> WARNING: $1"
}
help() {
help() {
cat << EOF
Usage:
$(basename $0) [ <options> <package.spkg.txz> ]
@@ -70,9 +70,9 @@ extract_opts() {
--*) opts="$opts $1";;
-*) char=${#1}; count=1
while [ "$count" != "$char" ]; do
count=$((count+1))
opts="$opts -$(echo $1 | cut -c $count)"
done;;
count=$((count+1))
opts="$opts -$(echo $1 | cut -c $count)"
done;;
*) opts="$opts $1"
esac
shift
@@ -93,12 +93,12 @@ parse_opts() {
-h | --help) SHOWHELP=yes ;;
--no-preinstall) NO_PREINSTALL=yes ;;
--no-postinstall) NO_POSTINSTALL=yes ;;
--no-preupgrade) NO_PREUPGRADE=yes ;;
--no-postupgrade) NO_POSTUPGRADE=yes ;;
--no-backup) NO_BACKUP=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;;
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
*) msg "Invalid option! ($1)"; exit 1 ;;
--no-preupgrade) NO_PREUPGRADE=yes ;;
--no-postupgrade) NO_POSTUPGRADE=yes ;;
--no-backup) NO_BACKUP=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;;
*.spkg.tar.*) PKGNAME="$(realpath $1)" ;;
*) msg "Invalid option! ($1)"; exit 1 ;;
esac
shift
done
@@ -107,30 +107,31 @@ parse_opts() {
ret() {
# remove lock and all tmp files on exit
rm -f "$LOCK_FILE" "$TMP_PKGADD" "$TMP_PKGINSTALL" "$TMP_CONFLICT"
rm -f "$ROOT_DIR/$LOCK_FILE" "$TMP_PKGADD" "$TMP_PKGINSTALL" "$TMP_CONFLICT"
exit $1
}
isinstalled() {
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$INDEX_DIR/$1/.pkginfo"; then
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
return 0
else
return 1
fi
}
run_scripts() {
if [ "$ROOT_DIR" ]; then
xchroot "$ROOT_DIR" sh $@
else
sh $@
fi
}
parse_opts $(extract_opts "$@")
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
# disable pre/post install/upgrade script when install to custom root location
if [ "$ROOT_DIR" != "" ]; then
NO_PREINSTALL=yes
NO_POSTINSTALL=yes
NO_PREUPGRADE=yes
NO_POSTUPGRADE=yes
fi
SCRATCHPKG_DIR="var/lib/scratchpkg"
INDEX_DIR="$SCRATCHPKG_DIR/index"
LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
# show help page
[ "$SHOWHELP" ] || [ -z "$PKGNAME" ] && {
@@ -138,25 +139,25 @@ fi
ret 0
}
[ -d "$INDEX_DIR" ] || {
msgerr "Package's database directory not exist! ($INDEX_DIR)"
[ -d "$ROOT_DIR/$INDEX_DIR" ] || {
msgerr "Package's database directory not exist! ($ROOT_DIR$/INDEX_DIR)"
ret 1
}
# check for root access, non-root only allowed if use custom --root= location
[ "$(id -u)" = "0" ] || [ "$ROOT_DIR" ] || {
# check for root access
[ "$(id -u)" = "0" ] || {
msgerr "Installing package need root access!"
ret 1
}
# check for lock file
[ -f "$LOCK_FILE" ] && {
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
msgerr "Cant install/remove package simultaneously."
msgerr "remove '$LOCK_FILE' if no install/remove package process running."
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
}
touch "$LOCK_FILE" 2>/dev/null || {
msgerr "Cant create lock file in '$LOCK_FILE'."
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'."
exit 1
}
@@ -173,11 +174,11 @@ release=${noextname##*-}
noextname=${noextname%-*}
version=${noextname##*-}
name=${noextname%-*}
# get package information if installed
if isinstalled $name; then
iversion=$(grep ^version $INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
irelease=$(grep ^release $INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
iversion=$(grep ^version $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
irelease=$(grep ^release $ROOT_DIR/$INDEX_DIR/$name/.pkginfo | cut -d " " -f3-)
ALREADYINSTALLED=yes
fi
@@ -200,9 +201,9 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
fi
fi
TMP_PKGADD="/tmp/.tmp_pkgadd.$$"
TMP_PKGINSTALL="/tmp/.tmp_pkginstall.$$"
TMP_CONFLICT="/tmp/.tmp_conflict.$$"
TMP_PKGADD="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkgadd"
TMP_PKGINSTALL="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_pkginstall"
TMP_CONFLICT="$ROOT_DIR/$SCRATCHPKG_DIR/.tmp_conflict"
# check integrity of package and save list file/dirs to install in the meantime
tar -tf $PKGNAME > $TMP_PKGADD 2>/dev/null || {
@@ -225,7 +226,7 @@ if [ ! "$IGNORE_CONFLICT" ]; then
fi
if [ -e "$ROOT_DIR/$line" ] || [ -L "$ROOT_DIR/$line" ]; then
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
if ! grep -Fqx "$line" "$INDEX_DIR/$name/.files"; then
if ! grep -Fqx "$line" "$ROOT_DIR/$INDEX_DIR/$name/.files"; then
echo "$line"
touch "$TMP_CONFLICT"
fi
@@ -244,19 +245,19 @@ fi
# pre-install and pre-upgrade script
if grep -qx .pkginstall $TMP_PKGADD; then
TMP_PKGINSTALL_SCRIPT="/tmp/.tmp_pkgadd_installscript.$$"
tar -xf "$PKGNAME" .pkginstall -O > "$TMP_PKGINSTALL_SCRIPT"
TMP_PKGINSTALL_SCRIPT="$SCRATCHPKG_DIR/pkgadd_installscript"
tar -xf "$PKGNAME" .pkginstall -O > "$ROOT_DIR/$TMP_PKGINSTALL_SCRIPT"
if [ ! "$NO_PREINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
(cd "$ROOT_DIR"/
sh "$TMP_PKGINSTALL_SCRIPT" pre-install "$version"
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-install "$version"
)
fi
if [ "$UPGRADE_PKG" ] && [ ! "$NO_PREUPGRADE" ]; then
(cd "$ROOT_DIR"/
sh "$TMP_PKGINSTALL_SCRIPT" pre-upgrade "$version" "$iversion"
run_scripts "$TMP_PKGINSTALL_SCRIPT" pre-upgrade "$version" "$iversion"
)
fi
rm -f "$TMP_PKGINSTALL_SCRIPT"
rm -f "$ROOT_DIR/$TMP_PKGINSTALL_SCRIPT"
fi
# exclude .pkg* files when extract into system
@@ -284,17 +285,18 @@ done
# remove old files from old package that not exist in new package
if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
rmlist_file="/tmp/.rmlist_file.$$"
rmlist_dir="/tmp/.rmlist_dir.$$"
reserve_dir="/tmp/.reserve_dir.$$"
rmlist_all="/tmp/.rmlist_all.$$"
grep '/$' $INDEX_DIR/*/.files | grep -v $INDEX_DIR/$name/.files | awk -F : '{print $2}' | sort | uniq > $reserve_dir # get list reserved dirs
grep -Fxv -f "$TMP_PKGINSTALL" $INDEX_DIR/$name/.files > $rmlist_all # get list files and dirs to remove
grep -v '/$' "$rmlist_all" | tac > "$rmlist_file" # get files only to remove
grep -Fxv -f "$reserve_dir" "$rmlist_all" | grep '/$' | tac > "$rmlist_dir" # get dirs only (safe) to remove
# remove pseudo fs from remove list
#sed '/^dev\//d;/^sys\//d;/^proc\//d;/^run\//d;/^tmp\//d' -i $rmlist_file
#sed '/^dev\//d;/^sys\//d;/^proc\//d;/^run\//d;/^tmp\//d' -i $rmlist_dir
rmlist_file="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_file"
rmlist_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_dir"
reserve_dir="$ROOT_DIR/$SCRATCHPKG_DIR/.reserve_dir"
rmlist_all="$ROOT_DIR/$SCRATCHPKG_DIR/.rmlist_all"
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \
| grep -v $ROOT_DIR/$INDEX_DIR/$name/.files \
| awk -F : '{print $2}' \
| sort \
| uniq > $reserve_dir # get list reserved dirs
grep -Fxv -f "$TMP_PKGINSTALL" $ROOT_DIR/$INDEX_DIR/$name/.files > $rmlist_all # get list files and dirs to remove
grep -v '/$' "$rmlist_all" | tac > "$rmlist_file" # get files only to remove
grep -Fxv -f "$reserve_dir" "$rmlist_all" | grep '/$' | tac > "$rmlist_dir" # get dirs only (safe) to remove
(cd "$ROOT_DIR"/
[ -s $rmlist_file ] && xargs -a $rmlist_file -d'\n' rm $VERBOSE_INSTALL
[ -s $rmlist_dir ] && xargs -a $rmlist_dir -d'\n' rmdir $VERBOSE_INSTALL
@@ -303,30 +305,30 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
fi
# register package into database
rm -fr "$INDEX_DIR/$name"
mkdir "$INDEX_DIR/$name"
echo "name = $name" > "$INDEX_DIR/$name/.pkginfo"
echo "version = $version" >> "$INDEX_DIR/$name/.pkginfo"
echo "release = $release" >> "$INDEX_DIR/$name/.pkginfo"
install -m644 "$TMP_PKGINSTALL" "$INDEX_DIR/$name/.files"
rm -fr "$ROOT_DIR/$INDEX_DIR/$name"
mkdir "$ROOT_DIR/$INDEX_DIR/$name"
echo "name = $name" > "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
echo "version = $version" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
echo "release = $release" >> "$ROOT_DIR/$INDEX_DIR/$name/.pkginfo"
install -m644 "$TMP_PKGINSTALL" "$ROOT_DIR/$INDEX_DIR/$name/.files"
for ii in $(grep ^.pkg* $TMP_PKGADD); do
pkgfiles="$pkgfiles $ii"
done
if [ "$pkgfiles" ]; then
tar -x -f "$PKGNAME" -C "$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1
tar -x -f "$PKGNAME" -C "$ROOT_DIR/$INDEX_DIR/$name" $pkgfiles >/dev/null 2>&1
fi
if [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
if [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
(cd "$ROOT_DIR"/
sh "$INDEX_DIR/$name/.pkginstall" post-install "$version"
run_scripts "$INDEX_DIR/$name/.pkginstall" post-install "$version"
)
fi
if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
(cd "$ROOT_DIR"/
sh "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
run_scripts "$INDEX_DIR/$name/.pkginstall" post-upgrade "$version" "$iversion"
)
fi
fi

View File

@@ -291,6 +291,24 @@ backupconf() {
done
}
removedocs() {
for i in doc gtk-doc info; do
rm -fr \
usr/share/$i \
usr/$i \
usr/local/$i \
usr/local/share/$i
done
}
removelocales() {
rm -fr \
usr/share/locale \
usr/locale \
usr/local/locale \
usr/local/share/locale
}
packaging() {
for FILE in $INCLUDEINPKG; do
if [ -f $FILE ]; then
@@ -316,6 +334,8 @@ packaging() {
[ "$KEEP_LIBTOOL" = 0 ] && removelibtool
[ "$STRIP_BINARY" = 1 ] && strip_files
[ "$ZIP_MAN" = 1 ] && compressinfomanpages
[ "$KEEP_DOCS" = 0 ] && removedocs
[ "$KEEP_LOCALES" = 0 ] && removelocales
if [ "${#backup[@]}" -gt 0 ]; then
backupconf
@@ -427,6 +447,10 @@ set_options() {
!makeflags) MAKE_FLAGS=0 ;;
checksum) CHECK_MDSUM=1 ;;
!checksum) CHECK_MDSUM=0 ;;
docs) KEEP_DOCS=1 ;;
!docs) KEEP_DOCS=0 ;;
locales) KEEP_LOCALES=1 ;;
!locales) KEEP_LOCALES=0 ;;
esac
done
}
@@ -641,6 +665,7 @@ main() {
abort 0
fi
else
msg "Building '$name-$version-$release'..."
download_src
prepare_src
run_build
@@ -669,7 +694,7 @@ WORK_DIR="/var/cache/scratchpkg/work"
DOWNLOAD_PROG="wget"
COMPRESSION_MODE="xz"
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum"
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"
INCLUDEINPKG="install readme mkdirs"

84
pkgdel
View File

@@ -74,7 +74,7 @@ extract_opts() {
echo $opts
}
parse_opts() {
parse_opts() {
if [ -z "$1" ]; then
SHOWHELP=yes
else
@@ -83,62 +83,64 @@ parse_opts() {
-h | --help) SHOWHELP=yes ;;
-v | --verbose) VERBOSE_REMOVE="-v" ;;
--no-preremove) NO_PREREMOVE=yes ;;
--no-postremove) NO_POSTREMOVE=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;;
-*) msg "Invalid option: ($1)"; exit 1 ;;
*) RMNAME=$1 ;;
--no-postremove) NO_POSTREMOVE=yes ;;
--root=*) ROOT_DIR="${1#*=}" ;;
-*) msg "Invalid option: ($1)"; exit 1 ;;
*) RMNAME=$1 ;;
esac
shift
done
fi
fi
}
ret() {
# remove lock file on exit
rm -f "$LOCK_FILE" "$reserve" "$dirs" "$remove" "$files"
rm -f "$ROOT_DIR/$LOCK_FILE" "$reserve" "$dirs" "$remove" "$files"
exit $1
}
isinstalled() {
if [ -s "$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$INDEX_DIR/$1/.pkginfo"; then
if [ -s "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo" ] && grep -q "$1" "$ROOT_DIR/$INDEX_DIR/$1/.pkginfo"; then
return 0
else
return 1
fi
}
run_scripts() {
if [ "$ROOT_DIR" ]; then
xchroot "$ROOT_DIR" sh $@
else
sh $@
fi
}
parse_opts $(extract_opts "$@")
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
INDEX_DIR="var/lib/scratchpkg/index"
LOCK_FILE="var/lib/scratchpkg/spkg.lock"
# disable pre/post remove script when remove from custom root location
if [ "$ROOT_DIR" != "" ]; then
NO_PREREMOVE=yes
NO_POSTREMOVE=yes
fi
# show help page
[ "$SHOWHELP" ] || [ -z "$RMNAME" ] && {
help
ret 0
}
# check for root access, non-root only allowed if use custom --root= location
[ "$(id -u)" = "0" ] || [ "$ROOT_DIR" ] || {
# check for root access
[ "$(id -u)" = "0" ] || {
echo "Removing package need root access!"
ret 1
}
# check for lock file
[ -f "$LOCK_FILE" ] && {
[ -f "$ROOT_DIR/$LOCK_FILE" ] && {
msgerr "Cant install/remove package simultaneously."
msgerr "remove '$LOCK_FILE' if no install/remove package process running."
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
exit 1
}
touch "$LOCK_FILE" 2>/dev/null || {
msgerr "Cant create lock file in '$LOCK_FILE'"
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {
msgerr "Cant create lock file in '$ROOT_DIR/$LOCK_FILE'"
exit 1
}
@@ -147,32 +149,36 @@ if ! isinstalled "$RMNAME"; then
ret 1
fi
name=$(grep ^name $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
version=$(grep ^version $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
release=$(grep ^release $INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
name=$(grep ^name $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
version=$(grep ^version $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
release=$(grep ^release $ROOT_DIR/$INDEX_DIR/$RMNAME/.pkginfo | cut -d " " -f3-)
if [ -z $name ] && [ -z $version ] && [ -z $release ]; then
if [ -z "$name" ] && [ -z "$version" ] && [ -z "$release" ]; then
msgerr "Package '$RMNAME' not installed but exist in database."
ret 1
fi
# create list for reserve and remove (dirs and files)
reserve="/tmp/.pkgdel_reserve.$$"
remove="/tmp/.pkgdel_remove.$$"
dirs="/tmp/.pkgdel_dirs.$$"
files="/tmp/.pkgdel_files.$$"
reserve="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_reserve"
remove="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_remove"
dirs="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_dirs"
files="$ROOT_DIR/$SCRATCHPKG_DIR/.pkgdel_files"
grep '/$' $INDEX_DIR/*/.files | grep -v "$INDEX_DIR/$name" | awk -F : '{print $2}' | sort | uniq > "$reserve"
grep '/$' "$INDEX_DIR/$name/.files" > "$remove"
grep '/$' $ROOT_DIR/$INDEX_DIR/*/.files \
| grep -v "$ROOT_DIR/$INDEX_DIR/$name" \
| awk -F : '{print $2}' \
| sort \
| uniq > "$reserve"
grep '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" > "$remove"
grep -Fxv -f "$reserve" "$remove" | tac > "$dirs"
grep -v '/$' "$INDEX_DIR/$name/.files" | tac >> "$files"
grep -v '/$' "$ROOT_DIR/$INDEX_DIR/$name/.files" | tac >> "$files"
echo "remove: $name-$version-$release..."
# pre-remove script
if [ ! "$NO_PREREMOVE" ] && [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
if [ ! "$NO_PREREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
(cd "$ROOT_DIR"/
sh "$INDEX_DIR/$name/.pkginstall" pre-remove "$version"
run_scripts "$INDEX_DIR/$name/.pkginstall" pre-remove "$version"
)
fi
@@ -184,15 +190,15 @@ fi
rm -f "$reserve" "$dirs" "$remove" "$files"
# post-remove script
if [ ! "$NO_POSTREMOVE" ] && [ -f "$INDEX_DIR/$name/.pkginstall" ]; then
# post-remove script
if [ ! "$NO_POSTREMOVE" ] && [ -f "$ROOT_DIR/$INDEX_DIR/$name/.pkginstall" ]; then
(cd "$ROOT_DIR"/
sh "$INDEX_DIR/$name/.pkginstall" post-remove "$version"
run_scripts "$INDEX_DIR/$name/.pkginstall" post-remove "$version"
)
fi
# remove from database
rm -rf "$INDEX_DIR/$name"
rm -rf "$ROOT_DIR/$INDEX_DIR/$name"
# running ldconfig
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then

View File

@@ -67,13 +67,27 @@ installed_pkg_info() {
fi
}
deps_alias() {
[ -f $ALIAS_FILE ] || {
echo $@
return
}
while [ "$1" ]; do
getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}')
echo ${getalias:-$1}
shift
done
unset getalias
}
getdepends() {
ppath=$(getportpath $1) || return 0
grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
deps=$(grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
| sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \
| tr ' ' '\n' \
| awk '!a[$0]++' \
| sed 's/,//'
| sed 's/,//')
deps_alias $deps
}
getportpath() {
@@ -320,6 +334,7 @@ print_runhelp_msg() {
BUILD_SCRIPT="spkgbuild"
INDEX_DIR="/var/lib/scratchpkg/index"
REPO_FILE="/etc/scratchpkg.repo"
ALIAS_FILE="/etc/scratchpkg.alias"
if [ -f "$REPO_FILE" ]; then
for repodir in $(grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1}'); do

19
scratch
View File

@@ -99,13 +99,27 @@ allinstalled() {
grep ^name "$INDEX_DIR"/*/.pkginfo | awk '{print $3}'
}
deps_alias() {
[ -f $ALIAS_FILE ] || {
echo $@
return
}
while [ "$1" ]; do
getalias=$(grep -w ^$1 $ALIAS_FILE | awk '{print $2}')
echo ${getalias:-$1}
shift
done
unset getalias
}
get_depends() {
ppath=$(getportpath $1) || return 0
grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
deps=$(grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \
| sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \
| tr ' ' '\n' \
| awk '!a[$0]++' \
| sed 's/,//'
| sed 's/,//')
deps_alias $deps
}
confirm() {
@@ -1172,6 +1186,7 @@ print_runhelp_msg() {
BUILD_SCRIPT="spkgbuild"
INDEX_DIR="/var/lib/scratchpkg/index"
REPO_FILE="/etc/scratchpkg.repo"
ALIAS_FILE="/etc/scratchpkg.alias"
# default value from pkgbuild
SOURCE_DIR="/var/cache/scratchpkg/sources"

9
scratchpkg.alias Normal file
View File

@@ -0,0 +1,9 @@
#
# /etc/scratchpkg.alias : scratchpkg alias file
#
# format:
# <real package> <aliased package>
#
# example:
# openssl libressl
#

View File

@@ -24,8 +24,10 @@ MAKEFLAGS="-j$(nproc)"
# -- buildflags: Enable buildflags (CFLAGS and CXXFLAGS)
# -- makeflags: Enable makeflags (MAKEFLAGS)
# -- checksum: Enable checking checksum
# -- docs: Keep docs
# -- locales: Keep locales
#
# -- These are default values for the options="" settings
# -- add '!' in front of this option to disable it
#
# OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum"
# OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"

View File

@@ -21,7 +21,7 @@
EDITOR=${EDITOR:-vi}
type -p $EDITOR >/dev/null || {
echo "Editor '$EDITOR' not exist..."
echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}."
exit 2
}

90
xchroot Executable file
View File

@@ -0,0 +1,90 @@
#!/bin/sh
printhelp() {
cat << EOF
Usage:
$(basename $0) <chroot-dir> [command]
If 'command' is unspecified, ${0##*/} will launch /bin/sh.
EOF
}
msgerr() {
echo "ERROR: $*"
}
[ "$(id -u)" = "0" ] || {
msgerr "$(basename $0) need root access!"
printhelp
exit 1
}
TARGET=$1
[ "$1" ] || {
msgerr "Please set directory for chroot!"
printhelp
exit 1
}
[ -d "$TARGET" ] || {
msgerr "Directory '$TARGET' not exist!"
printhelp
exit 1
}
shift
if [ ! "$1" ]; then
CMD="/bin/sh"
else
CMD=$*
fi
if [ -e /sys/firmware/efi/systab ]; then
EFI_SYSTEM=1
fi
mount --bind /dev $TARGET/dev
mount -t devpts devpts $TARGET/dev/pts -o gid=5,mode=620
mount -t proc proc $TARGET/proc
mount -t sysfs sysfs $TARGET/sys
if [ -n "$EFI_SYSTEM" ]; then
mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
fi
mount -t tmpfs tmpfs $TARGET/run
if [ -h $TARGET/dev/shm ]; then
mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
fi
[ -f $TARGET/etc/resolv.conf ] && {
backupresolvconf=1
mv $TARGET/etc/resolv.conf $TARGET/etc/resolv.conf.tmp
}
cp -L /etc/resolv.conf $TARGET/etc
chroot "$TARGET" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD
retval=$?
[ "$backupresolvconf" = 1 ] && {
mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
}
umount $TARGET/dev/pts
umount $TARGET/dev
umount $TARGET/run
umount $TARGET/proc
if [ -n "$EFI_SYSTEM" ]; then
umount $TARGET/sys/firmware/efi/efivars
fi
umount $TARGET/sys
exit $retval