Remove use of uid=1000 in favour of $SUDO_USER globally
authorCole Poirier <colepoirier@gmail.com>
Fri, 24 Jul 2020 21:42:23 +0000 (14:42 -0700)
committerCole Poirier <colepoirier@gmail.com>
Fri, 24 Jul 2020 21:42:23 +0000 (14:42 -0700)
coriolis2-chroot
hdl-dev-repos
hdl-tools-yosys
pia-install

index 768463300d485cbbf6075bb720b8d447287bfce4..752a515249672a89d652f42061912899d9b7fc2e 100755 (executable)
@@ -24,8 +24,6 @@ mount /opt/chroot/coriolis/proc
 mount /opt/chroot/coriolis/sys
 mount /opt/chroot/coriolis/tmp
 echo "coriolis2" > /opt/chroot/coriolis/etc/debian_chroot
 mount /opt/chroot/coriolis/sys
 mount /opt/chroot/coriolis/tmp
 echo "coriolis2" > /opt/chroot/coriolis/etc/debian_chroot
-export MYNAME=`id 1000 | awk '{print $1}' | sed 's/.*(\(.*\))/\1/'`
-export CHU_HOME=/home/$MYNAME
 # Install apt dependencies in the chroot
 chroot /opt/chroot/coriolis /bin/bash << EOF
 echo Installing necessary apt dependencies in the chroot
 # Install apt dependencies in the chroot
 chroot /opt/chroot/coriolis /bin/bash << EOF
 echo Installing necessary apt dependencies in the chroot
@@ -44,20 +42,20 @@ texlive-latex-extra texlive-pictures xfig yosys zlib1g-dev
 
 
 # Create user with same UID in the chroot
 
 
 # Create user with same UID in the chroot
-useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $MYNAME -k /etc/skel
+useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $SUDO_USER -k /etc/skel
 echo -e "
 echo -e "
-Added user ${MYNAME} with \e[1;91mpassword: 1234\e[0m"
+Added user ${SUDO_USER} with \e[1;91mpassword: 1234\e[0m"
 
 echo -e "
 
 echo -e "
-\e[1;91mPlease use command 'passwd ${MYNAME}' to change this immediately after this script is run for security purposes.\e[0m
+\e[1;91mPlease use command 'passwd ${SUDO_USER}' to change this immediately after this script is run for security purposes.\e[0m
 "
 
 # Add convenience variable to chroot user .bash_profile
 "
 
 # Add convenience variable to chroot user .bash_profile
-echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\nexport ALLIANCE_TOP=$CHU_HOME/alliance/install\nexport YOSYS_TOP=$CHU_HOME/yosys\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib:\044{LD_LIBRARY_PATH}\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib64:\044{LD_LIBRARY_PATH}' > $CHU_HOME/.bash_profile
-chown $MYNAME $CHU_HOME/.bash_profile
-chgrp $MYNAME $CHU_HOME/.bash_profile
+echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\nexport ALLIANCE_TOP=/home/$SUDO_USER/alliance/install\nexport YOSYS_TOP=/home/$SUDO_USER/yosys\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib:\044{LD_LIBRARY_PATH}\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib64:\044{LD_LIBRARY_PATH}' > /home/$SUDO_USER/.bash_profile
+chown $SUDO_USER /home/$SUDO_USER/.bash_profile
+chgrp $SUDO_USER /home/$SUDO_USER/.bash_profile
 
 
-echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to $CHU_HOME/.bash_profile to speed up rebuilds"
+echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to /home/$SUDO_USER/.bash_profile to speed up rebuilds"
 EOF
 
 # Add coriolis config to schroot.conf
 EOF
 
 # Add coriolis config to schroot.conf
@@ -65,7 +63,7 @@ cat <<EOF >>/etc/schroot/schroot.conf
 [coriolis]
 description=Debian Buster for Coriolis
 directory=/opt/chroot/coriolis
 [coriolis]
 description=Debian Buster for Coriolis
 directory=/opt/chroot/coriolis
-groups=sbuild-security,$MYNAME,users
+groups=sbuild-security,$SUDO_USER,users
 EOF
 
 echo "Adding the following coriolis section to /etc/schroot/schroot.conf:
 EOF
 
 echo "Adding the following coriolis section to /etc/schroot/schroot.conf:
@@ -73,7 +71,7 @@ echo "Adding the following coriolis section to /etc/schroot/schroot.conf:
 [coriolis]
 description=Debian Buster for Coriolis
 directory=/opt/chroot/coriolis
 [coriolis]
 description=Debian Buster for Coriolis
 directory=/opt/chroot/coriolis
-groups=sbuild-security,$MYNAME,users
+groups=sbuild-security,$SUDO_USER,users
 
 This enables you to chroot into coriolis as an unprivileged user by running
 'schroot -c coriolis /bin/bash'
 
 This enables you to chroot into coriolis as an unprivileged user by running
 'schroot -c coriolis /bin/bash'
@@ -85,8 +83,8 @@ apt-get update -y
 apt-get build-dep yosys -y
 apt-get remove yosys -y
 EOF
 apt-get build-dep yosys -y
 apt-get remove yosys -y
 EOF
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
 git clone https://github.com/cliffordwolf/yosys.git
 cd yosys
 make config-clang
 git clone https://github.com/cliffordwolf/yosys.git
 cd yosys
 make config-clang
@@ -94,60 +92,60 @@ make -j$(nproc)
 EOF'
 
 chroot /opt/chroot/coriolis /bin/bash << EOF
 EOF'
 
 chroot /opt/chroot/coriolis /bin/bash << EOF
-cd $CHU_HOME/yosys
+cd /home/$SUDO_USER/yosys
 make install
 EOF
 
 # Install coriolis2 from source
 make install
 EOF
 
 # Install coriolis2 from source
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
 source .bash_profile
 source .bash_profile
-mkdir -p $CHU_HOME/coriolis-2.x/src
-cd $CHU_HOME/coriolis-2.x/src
+mkdir -p /home/$SUDO_USER/coriolis-2.x/src
+cd /home/$SUDO_USER/coriolis-2.x/src
 git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
 cd coriolis
 git checkout devel
 ./bootstrap/ccb.py --project=coriolis --make="-j$(nproc) install"
 
 # Setup and test coriolisenv
 git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
 cd coriolis
 git checkout devel
 ./bootstrap/ccb.py --project=coriolis --make="-j$(nproc) install"
 
 # Setup and test coriolisenv
-$CHU_HOME/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > $CHU_HOME/coriolisenv
-source $CHU_HOME/.bash_profile
-source $CHU_HOME/coriolisenv
+/home/$SUDO_USER/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > /home/$SUDO_USER/coriolisenv
+source /home/$SUDO_USER/.bash_profile
+source /home/$SUDO_USER/coriolisenv
 EOF'
 
 # Install alliance from source
 EOF'
 
 # Install alliance from source
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash <<    EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash <<    EOF
+cd /home/$SUDO_USER
 source coriolisenv
 git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
 source coriolisenv
 git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
-mkdir -p $CHU_HOME/alliance/build $CHU_HOME/alliance/install
+mkdir -p /home/$SUDO_USER/alliance/build /home/$SUDO_USER/alliance/install
 mv alliance/alliance/src alliance
 rm -rf alliance/alliance
 cd alliance/src
 ./autostuff
 mv alliance/alliance/src alliance
 rm -rf alliance/alliance
 cd alliance/src
 ./autostuff
-cd $CHU_HOME/alliance/build
-../src/configure --prefix=$CHU_HOME/alliance/install --enable-alc-shared
+cd /home/$SUDO_USER/alliance/build
+../src/configure --prefix=/home/$SUDO_USER/alliance/install --enable-alc-shared
 EOF'
 
 chroot /opt/chroot/coriolis /bin/bash << EOF
 EOF'
 
 chroot /opt/chroot/coriolis /bin/bash << EOF
-cd $CHU_HOME/alliance/build
-source $CHU_HOME/coriolisenv
+cd /home/$SUDO_USER/alliance/build
+source /home/$SUDO_USER/coriolisenv
 make -j1 install
 EOF
 
 # Install and configure alliance-check-toolkit
 make -j1 install
 EOF
 
 # Install and configure alliance-check-toolkit
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
 git clone https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git
 source coriolisenv
 git clone https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git
 source coriolisenv
-touch alliance-check-toolkit/etc/mk/users.d/user-$MYNAME.mk
-cat <<EOG >>alliance-check-toolkit/etc/mk/users.d/user-$MYNAME.mk
-export CORIOLIS_TOP=/home/$MYNAME/coriolis-2.x/Linux.x86_64/Release.Shared/install
-export ALLIANCE_TOP=/home/$MYNAME/alliance/install
-export CHECK_TOOLKIT=/home/$MYNAME/alliance-check-toolkit
-export YOSYS_TOP=/home/$MYNAME/yosys
+touch alliance-check-toolkit/etc/mk/users.d/user-$SUDO_USER.mk
+cat <<EOG >>alliance-check-toolkit/etc/mk/users.d/user-$SUDO_USER.mk
+export CORIOLIS_TOP=/home/$SUDO_USER/coriolis-2.x/Linux.x86_64/Release.Shared/install
+export ALLIANCE_TOP=/home/$SUDO_USER/alliance/install
+export CHECK_TOOLKIT=/home/$SUDO_USER/alliance-check-toolkit
+export YOSYS_TOP=/home/$SUDO_USER/yosys
 EOG
 EOG
-source $CHU_HOME/.bash_profile
+source /home/$SUDO_USER/.bash_profile
 cd alliance-check-toolkit/benchs/ARM/cmos
 make lvx
 echo -e "
 cd alliance-check-toolkit/benchs/ARM/cmos
 make lvx
 echo -e "
index 474a6dfa8d10a3a03f1c85646d79482b5e35e7a3..255692bd91bdcd42b18ebd608787de77a23e01eb 100755 (executable)
@@ -4,11 +4,8 @@ if [ "$EUID" -ne 0 ]
   exit
 fi
 
   exit
 fi
 
-export MYNAME=`id 1000 | awk '{print $1}' | sed 's/.*(\(.*\))/\1/'`
-export MYHOME=/home/$MYNAME
-
-runuser $MYNAME --preserve-environment -c '
-cd /home/$MYNAME
+runuser $SUDO_USER --preserve-environment -c '
+cd /home/$SUDO_USER
 mkdir src
 cd src
 git clone https://github.com/nmigen/nmigen.git
 mkdir src
 cd src
 git clone https://github.com/nmigen/nmigen.git
@@ -17,7 +14,7 @@ git clone https://git.libre-soc.org/git/ieee754fpu.git
 git clone https://git.libre-soc.org/git/nmigen-soc.git
 git clone https://git.libre-soc.org/git/soc.git
 '
 git clone https://git.libre-soc.org/git/nmigen-soc.git
 git clone https://git.libre-soc.org/git/soc.git
 '
-cd /home/$MYNAME/src/nmigen
+cd /home/$SUDO_USER/src/nmigen
 python3 setup.py develop
 cd ../nmutil
 python3 setup.py develop
 python3 setup.py develop
 cd ../nmutil
 python3 setup.py develop
@@ -30,8 +27,8 @@ cd ../soc
 git submodule update --init --recursive
 python3 setup.py develop
 cd ../
 git submodule update --init --recursive
 python3 setup.py develop
 cd ../
-chown -R $MYNAME .
-chgrp -R $MYNAME .
+chown -R $SUDO_USER .
+chgrp -R $SUDO_USER .
 echo -e "
 \e[1;91mAll Libre-SOC dev dependenices should now be installed.\e[0m
 "
 echo -e "
 \e[1;91mAll Libre-SOC dev dependenices should now be installed.\e[0m
 "
index 7a13bb70ad4b52ec5e892b96c84b0204d470d9df..23cbd93304876fa421e537ac7f7d674827c625e5 100755 (executable)
@@ -8,7 +8,7 @@ apt-get update -y
 apt-get build-dep yosys -y
 apt-get remove yosys -y
 
 apt-get build-dep yosys -y
 apt-get remove yosys -y
 
-cd $CHU_HOME
+cd $SUDO_USER/home
 mkdir hdl_tools
 cd hdl_tools
 
 mkdir hdl_tools
 cd hdl_tools
 
@@ -37,6 +37,6 @@ cd build
 make -j$(nproc)
 make install
 
 make -j$(nproc)
 make install
 
-cd $CHU_HOME/hdl_tools
-chown -R $MYNAME hdl_tools
-chgrp -R $MYNAME hdl_tools
+cd $SUDO_USER/home/hdl_tools
+chown -R $SUDO_USER hdl_tools
+chgrp -R $SUDO_USER hdl_tools
index 04cb826e1ae00cb85992b35bd770162ee7b0d761..7ed614777636ea9d2f920bb46bf21fb60c88c867 100755 (executable)
@@ -1,26 +1,14 @@
 #!/bin/bash
 #!/bin/bash
-if [ "$EUID" -ne 0 ]
-  then echo "Please run as root"
-  exit
-fi
-
-export MYNAME=`id 1000 | awk '{print $1}' | sed 's/.*(\(.*\))/\1/'`
-
-runuser $MYNAME --preserve-environment -c '/bin/bash << EOF
-export PATH=/home/$MYNAME/.cargo/bin:$PATH
-export HOME=/home/$MYNAME
 if ! command -v rustup &> /dev/null
 then
     echo -e "Rustup could not be found, it can be installed by running the following command: curl --proto \047=https\047 --tlsv1.2 -sSf https://sh.rustup.rs | sh"
     exit
 fi
 if ! command -v rustup &> /dev/null
 then
     echo -e "Rustup could not be found, it can be installed by running the following command: curl --proto \047=https\047 --tlsv1.2 -sSf https://sh.rustup.rs | sh"
     exit
 fi
-cd /home/$MYNAME/src
+cd /home/$USER/src
 rustup default stable
 rustup update
 cargo install maturin
 git clone https://salsa.debian.org/Kazan-team/power-instruction-analyzer.git pia
 cd pia
 maturin build --cargo-extra-args=--features=python-extension
 rustup default stable
 rustup update
 cargo install maturin
 git clone https://salsa.debian.org/Kazan-team/power-instruction-analyzer.git pia
 cd pia
 maturin build --cargo-extra-args=--features=python-extension
-EOF'
-cd /home/$MYNAME/src/pia
-python3 -m pip install target/wheels/*.whl
+python3 -m pip install --user target/wheels/*.whl