Add option to specify ownership of downloaded files and patches
authorHugo Villeneuve <hugo@hugovil.com>
Tue, 19 Aug 2014 04:03:31 +0000 (00:03 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Mon, 24 Nov 2014 13:56:10 +0000 (08:56 -0500)
functions/fpkg

index 6c0c26e..3f8e624 100644 (file)
@@ -3,6 +3,10 @@
 source ../config/urls
 source ../functions/gztobz2
 
+# Ownership of downloaded files
+FPKG_USER="root"
+FPKG_GROUP="users"
+
 LFS_PKG_BASE="$(dirname $(pwd))/packages"
 LFS_PKG_DIR="${LFS_PKG_BASE}/${LFS_STAGE}"
 LFS_PATCHES_DIR="${LFS_PKG_BASE}/${LFS_STAGE}/patches"
@@ -115,6 +119,9 @@ wget_wrapper()
         --output-document=${DESTDIR}/${SOURCE}.part
     wget_status=$?
 
+    chown ${FPKG_USER}:${FPKG_GROUP} ${DESTDIR}/${SOURCE}.part
+    chmod 664 ${DESTDIR}/${SOURCE}.part
+
     # Append log to global log file
     cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE}
 
@@ -150,6 +157,8 @@ wget_wrapper()
 
     # Rename temporary file to final name
     mv ${DESTDIR}/${SOURCE}{.part,}
+    chown ${FPKG_USER}:${FPKG_GROUP} ${DESTDIR}/${SOURCE}
+    chmod 664 ${DESTDIR}/${SOURCE}
 
     return 0
 }
@@ -190,12 +199,14 @@ update_packages_init()
 
     # Then create destination directory if it does not exists.
     if [ ! -d ${LFS_PKG_DIR} ]; then
-       install -v -m755 -d ${LFS_PKG_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
+       install -v -m775 -o ${FPKG_USER} -g ${FPKG_GROUP} \
+            -d ${LFS_PKG_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
     fi
 
     # Create patches destination directory if it does not exists.
     if [ ! -d ${LFS_PATCHES_DIR} ]; then
-       install -v -m755 -d ${LFS_PATCHES_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
+       install -v -m775 -o ${FPKG_USER} -g ${FPKG_GROUP} \
+            -d ${LFS_PATCHES_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
     fi
 
     if [ -n "${TEST_INTEGRITY}" ]; then