add sysusers option and fix some bugs

This commit is contained in:
emmett1
2018-06-26 17:56:26 +08:00
parent cbfc70b35b
commit 4418d408ab
5 changed files with 40 additions and 3 deletions

View File

@@ -4,11 +4,12 @@ BINDIR=/usr/bin
FUNCDIR=/usr/share/scratchpkg
CONFDIR=/etc
HOOK_DIR=/etc/hooks
SYSUSERS_DIR=/etc/sysusers
CACHE_DIR=/var/cache/scratchpkg
INDEX_DIR=/var/lib/scratchpkg
PORT_DIR=/usr/ports
mkdir -pv ${DESTDIR}{${BINDIR},${FUNCDIR},${CONFDIR},${HOOK_DIR},${PORT_DIR}}
mkdir -pv ${DESTDIR}{${BINDIR},${FUNCDIR},${CONFDIR},${HOOK_DIR},${SYSUSERS_DIR},${PORT_DIR}}
install -m755 revdep buildpkg installpkg removepkg scratch ${DESTDIR}${BINDIR}
install -m644 functions/* ${DESTDIR}${FUNCDIR}
install -m644 scratchpkg.conf scratchpkg.repo ${DESTDIR}${CONFDIR}

View File

@@ -8,7 +8,7 @@ backupconf() {
for bkp in ${backup[@]}; do
if [ ! -f $bkp ]; then
msgerr "File '$bkp' not exist!"
exit 1
exitscript1
else
mv $bkp $bkp.spkgnew
fi

View File

@@ -18,6 +18,7 @@ SOURCE_DIR="/var/cache/scratchpkg/sources"
WORK_DIR="/tmp"
LOG_DIR="/var/cache/scratchpkg/log"
HOOK_DIR="/etc/hooks"
SYSUSERS_DIR="/etc/sysusers"
OPTIONS=(!libtool emptydirs strip docs purge zipman buildflags makeflags)
PURGE_FILES=(usr/{,share/}info/dir)

View File

@@ -66,7 +66,7 @@ installpkg() {
#installing package into system
msg2 "Extracting package..."
installcmd() {
tar --keep-directory-symlink --no-overwrite-dir -p -x -v -f $1 -C $ROOT_DIR --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]}
tar --keep-directory-symlink -p -x -v -f $1 -C $ROOT_DIR --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]}
}
rm -f /tmp/spkginstall.$name
@@ -134,6 +134,8 @@ installpkg() {
msg2 "This package has ${GREEN}readme${CRESET}"
fi
sysusers
runhooks
msg "Successfully $oprmsg ${GREEN}$name-$version-$release${CRESET}."
@@ -305,6 +307,38 @@ runhooks() {
}
sysusers() {
if [ "$(ls $SYSUSERS_DIR/*.conf 2>/dev/null)" ]; then
for file in $(ls $SYSUSERS_DIR/*.conf); do
while read uid gid mode dir junk; do
# Ignore comments and blank lines
case "${uid}" in
""|\#*) continue ;;
esac
if [ -e "$dir" ]; then
if [ "$uid" != '-' ]; then
getent passwd $uid >/dev/null
if [[ "$?" = 0 ]]; then
chown "$uid" "$dir"
fi
fi
if [ "$gid" != '-' ]; then
getent group $gid >/dev/null
if [[ "$?" = 0 ]]; then
chgrp "$gid" "$dir"
fi
fi
if [ "$mode" != '-' ]; then
chmod "$mode" "$dir"
fi
fi
done < "$file"
done
fi
}
help() {
cat << EOF

View File

@@ -20,6 +20,7 @@ MAKEFLAGS="-j2"
# WORK_DIR="/tmp"
# LOG_DIR="/var/cache/scratchpkg/log"
# HOOK_DIR="/etc/hooks"
# SYSUSERS_DIR="/etc/sysusers"
##
## GLOBAL PACKAGE OPTIONS