added doas support, not just sudo

This commit is contained in:
owl4ce 2021-03-16 19:01:54 +07:00
parent 57ebd15438
commit 90f501f0df
No known key found for this signature in database
GPG key ID: F9D30BA7338120AC
2 changed files with 15 additions and 6 deletions

View file

@ -1,5 +1,14 @@
#!/bin/bash -e #!/bin/bash -e
if type -p "sudo" &>/dev/null; then
PRIV="sudo"
elif type -p "doas" &>/dev/null; then
PRIV="doas"
else
echo "\e[1;31merror:\e[0m sudo/doas not found!"
exit 1
fi
fetch() { fetch() {
tarballname=$(echo $1 | rev | cut -d / -f 1 | rev) tarballname=$(echo $1 | rev | cut -d / -f 1 | rev)
WGETCMD="wget --passive-ftp --tries=3 --waitretry=3 --output-document=$2/$tarballname.partial" WGETCMD="wget --passive-ftp --tries=3 --waitretry=3 --output-document=$2/$tarballname.partial"
@ -94,7 +103,7 @@ main() {
checkdone || continue checkdone || continue
build_stage1 $script build_stage1 $script
done done
sudo chown -Rv 0:0 $LFS $PRIV chown -Rv 0:0 $LFS
} }
if [ $(id -u) = 0 ]; then if [ $(id -u) = 0 ]; then
@ -129,15 +138,15 @@ export LC_ALL=C PATH MAKEFLAGS LFS LFS_TGT LFS_TGT32
mkdir -p $SRCDIR $PKGDIR $WORKDIR mkdir -p $SRCDIR $PKGDIR $WORKDIR
if [ ! -d $LFS/tools ]; then if [ ! -d $LFS/tools ]; then
sudo mkdir -pv $LFS/tools $PRIV mkdir -pv $LFS/tools
fi fi
if [ ! -w $LFS ]; then if [ ! -w $LFS ]; then
sudo chown -Rv $USER:$USER $LFS $PRIV chown -Rv $USER:$USER $LFS
fi fi
if [ ! -L /tools ] || [ $(realpath /tools) != $LFS/tools ]; then if [ ! -L /tools ] || [ $(realpath /tools) != $LFS/tools ]; then
sudo ln -svf $LFS/tools / $PRIV ln -svf $LFS/tools /
fi fi
main $@ main $@

View file

@ -4,7 +4,7 @@ This repo contain scripts to automate multilib LFS build + livecd. This LFS buil
### Requirements ### Requirements
* sudo * sudo/doas
* wget * wget
* passes lfs version-check.sh test * passes lfs version-check.sh test
* squashfs-tools & libisoburn (optional to create the livecd iso) * squashfs-tools & libisoburn (optional to create the livecd iso)
@ -44,7 +44,7 @@ Basically you just need to run all those 3 scripts without other command to get
``` ```
$ ./01-toolchain && sudo ./02-base && sudo ./03-mkiso $ ./01-toolchain && sudo ./02-base && sudo ./03-mkiso
``` ```
> Note: script 01-toolchain gonna ask for sudo password > Note: script 01-toolchain gonna ask for sudo/doas password
- First grab any distro's livecd to use as host, or you can just your current running linux distro as host. (read below for tested host) - First grab any distro's livecd to use as host, or you can just your current running linux distro as host. (read below for tested host)
- Prepare your partition for LFS and mount it on `/mnt/lfs` or you can change where LFS build directory in `config` file. - Prepare your partition for LFS and mount it on `/mnt/lfs` or you can change where LFS build directory in `config` file.