[jhalfs] 01/03: Change the {save,restore}-luser targets

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.automated
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch plabs/lfs-user
in repository jhalfs.

commit 6015e111c0f98d7e9ede783084eb7c7e685824ae
Author: Pierre Labastie <[email protected]>
AuthorDate: Thu Dec 26 09:02:55 2024 +0100

    Change the {save,restore}-luser targets
    
    As discussed in ticket #1739, we don't want to remove the lfs user
    anymore. This means we don't need to restore it afterwards either.
    So if an lfs user exists, it has to be renamed to something else
    (lfsxxx), and the lfs user will be (re)created by book instructions.
    The save-luser target does this. The restore-luser target is just
    a warning about the states of the lfs* users.
---
 LFS/master.sh | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/LFS/master.sh b/LFS/master.sh
index 39ea38e..c18ceee 100644
--- a/LFS/master.sh
+++ b/LFS/master.sh
@@ -492,15 +492,20 @@ create-sbu_du-report:  mk_BOOT
 
 save-luser:
 	@\$(call echo_message, Building)
-	@LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
-	if [ -n "\$\$LUSER_ID" ]; then  \\
-	    if [ ! -d \$(LUSER_HOME).XXX ]; then \\
-		mv \$(LUSER_HOME){,.XXX}; \\
-		mkdir \$(LUSER_HOME); \\
-		chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
+	@if grep -q '^\$(LUSER):' /etc/passwd; then \\
+	    if grep -q '^\$(LUSER)xxx:' /etc/passwd; then \\
+	        userdel -r \$(LUSER)xxx; \\
+	        groupdel \$(LGROUP)xxx; \\
 	    fi; \\
-	    echo "\$\$LUSER_ID" > luser-id; \\
-	    echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
+	    rm -rf \$(LUSER_HOME)xxx; \\
+	    usermod -d \$(LUSER_HOME)xxx -m \$(LUSER); \\
+	    usermod -l \$(LUSER)xxx \$(LUSER); \\
+	    groupmod -n \$(LGROUP)xxx \$(LGROUP); \\
+	    touch luser-id; \\
+	    echo User \$(LUSER) exists:; \\
+	    echo it has been renamed to \$(LUSER)xxx and its home; \\
+	    echo has been moved to \$(LUSER_HOME)xxx.; \\
+	    echo It will be recreated with book instructions.; \\
 	else \\
 	    rm -f luser-id; \\
 	    echo User \$(LUSER) does not exist; \\
@@ -509,15 +514,20 @@ save-luser:
 	@\$(call housekeeping)
 
 restore-luser:
-	@\$(call echo_message, Building)
 	@if [ -f luser-id ]; then \\
-		rm -rf \$(LUSER_HOME); \\
-		mv \$(LUSER_HOME){.XXX,}; \\
-		rm luser-id; \\
+	        rm luser-id; \\
+	        echo \$(RED) " W A R N I N G " \$(BOLD); \\
+	        echo A new "\$(LUSER)" user has been created during the build.; \\
+	        echo The original "\$(LUSER)" user has been renamed to; \\
+	        echo \$(LUSER)xxx, and its home moved to \$(LUSER_HOME)xxx.; \\
+	        echo Be sure to rename it back if you want to preserve the; \\
+	        echo original content. Otherwise it will be destroyed next; \\
+	        echo time jhalfs is run.; \\
 	else \\
-		userdel \$(LUSER); \\
-		groupdel \$(LGROUP); \\
-		rm -rf \$(LUSER_HOME); \\
+	        echo \$(RED) " W A R N I N G " \$(BOLD); \\
+	        echo A new "\$(LUSER)" user has been created during the build.; \\
+	        echo Since the book does not delete it, jhalfs does not; \\
+	        echo either.; \\
 	fi
 	@\$(call housekeeping)
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/alfs-discuss
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.