Misleading description in /usr/lib/setup/INSURL script on installation image
by crts from LinuxQuestions.org on (#504NY)
A while back I had some problems doing a PXE install. Prompted by this thread I revisited the issue and stumbled on another issue. The description, when entering the package sourcepath in file usr/lib/setup/INSURL, reads as follows:
Code: The installation script needs to know the name of the
directory on your server that contains the series
subdirectories. For example, if your A series is found at
/slack/slackware64/a, then you would respond: /slack/slackware64This implies, that someone might be able to build a custom repository on the server with a custom name, e.g., /slack/myrepository.
However, the script usr/lib/setup/slackinstall tries to download those packages in the following manner:
Code:get_pkg () {
...
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${PKGBASE}.txt
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${2}
if [ $? -ne 0 ]; then # One retry for aborted transfers
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${2}
fi
...
}As you can see, the wget has the slackware64 directory hardcoded in function get_pkg(), therefore the repository name cannot be freely chosen.
It is worse, actually. This is how the script usr/lib/setup/INSURL checks if the user has entered a valid path:
Code:REMOTE_ROOT=$(dirname $REMOTE_PATH)
mkdir -p $TMP/treecache 2>/dev/null
chmod 700 $TMP/treecache
rm -rf $TMP/treecache/* 2>/dev/null
ln -sf $TMP/treecache /var/log/mount/
cd /var/log/mount/treecache
echo "Downloading PACKAGES.TXT ..." >> $TMP/wgetout
echo "URL: $REMOTE_URL$REMOTE_ROOT" > $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
if [ $RET != 0 ]; then
echo "> Download failed. Going to try one directory lower." >> $TMP/wgetout
REMOTE_ROOT=$REMOTE_PATH
echo "URL: $REMOTE_URL$REMOTE_ROOT" >> $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
[ $RET != 0 ] && echo "> Download failed again." >> $TMP/wgetout
fiThe variable $REMOTE_PATH stores the user's input but the script discards the user's entered root directory and first searches one level above for PACKAGES.TXT. E.g., if the user followed the directions and entered '/slack/slackware64' then the script will first search in '/slack'. If it finds a PACKAGES.TXT file there then this value will be stored as package location.
Only if it does not find the file the user's entered choice is considered, i.e., '/slack/slackware64'. This will lead to an error in get_pkg() (script slackinstall) later because get_pkg() will search for the packages in '<remote_ip>/slack/slackware64/slackware64' due to the hardcoded 'slackware64' subfolder.
I suggest the following changes:
Code:--- INSURL 2020-03-01 00:58:36.380518663 +0100
+++ INSURL.new 2020-03-02 18:05:20.520953091 +0100
@@ -91,9 +91,10 @@
packages and files arranged in a tree like the FTP site.
The installation script needs to know the name of the
- directory on your server that contains the series
- subdirectories. For example, if your A series is found at
- /slack/slackware64/a, then you would respond: /slack/slackware64
+ directory on the server that contains the slackware64
+ subdirectory. For example, if the A series is found at
+ http://example.com/slack/slackware64/a, then you
+ would respond: /slack
What is the Slackware source directory?
EOF
@@ -126,7 +127,7 @@
dialog --title "DOWNLOAD INFORMATION" --msgbox "$(cat $TMP/tempmsg)" 20 70
rm -f $TMP/tempmsg
- REMOTE_ROOT=$(dirname $REMOTE_PATH)
+ REMOTE_ROOT=$REMOTE_PATH
mkdir -p $TMP/treecache 2>/dev/null
chmod 700 $TMP/treecache
rm -rf $TMP/treecache/* 2>/dev/null
@@ -136,14 +137,7 @@
echo "URL: $REMOTE_URL$REMOTE_ROOT" > $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
- if [ $RET != 0 ]; then
- echo "> Download failed. Going to try one directory lower." >> $TMP/wgetout
- REMOTE_ROOT=$REMOTE_PATH
- echo "URL: $REMOTE_URL$REMOTE_ROOT" >> $TMP/wgetout
- wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
- RET=$?
- [ $RET != 0 ] && echo "> Download failed again." >> $TMP/wgetout
- fi
+ [ $RET != 0 ] && echo "> Download failed." >> $TMP/wgetout
echo "" >> $TMP/wgetout
if [ -r /var/log/mount/treecache/PACKAGES.TXT ]; thenI changed the description to emphasize that the client does/should not need to know the location on the server's filesystem, only the location inside the published webfolder. For the PXE setup scenario this would just be '/'. I have tested and verified the INSURL solution in PXE setup scenario.
I checked the INSNFS script, too. It has the same instructions regarding the repositories location but at some point it also expects a 'slackware64' directory. For nfs, however, the user needs to know the exact location on the fileserver, I think. I did not have time to verify the nfs issue, yet.


Code: The installation script needs to know the name of the
directory on your server that contains the series
subdirectories. For example, if your A series is found at
/slack/slackware64/a, then you would respond: /slack/slackware64This implies, that someone might be able to build a custom repository on the server with a custom name, e.g., /slack/myrepository.
However, the script usr/lib/setup/slackinstall tries to download those packages in the following manner:
Code:get_pkg () {
...
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${PKGBASE}.txt
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${2}
if [ $? -ne 0 ]; then # One retry for aborted transfers
wget $3 -c -P `cat $TMP/SeTDS`/${1} \
$REMOTE_URL$REMOTE_ROOT/slackware64/${1}/${2}
fi
...
}As you can see, the wget has the slackware64 directory hardcoded in function get_pkg(), therefore the repository name cannot be freely chosen.
It is worse, actually. This is how the script usr/lib/setup/INSURL checks if the user has entered a valid path:
Code:REMOTE_ROOT=$(dirname $REMOTE_PATH)
mkdir -p $TMP/treecache 2>/dev/null
chmod 700 $TMP/treecache
rm -rf $TMP/treecache/* 2>/dev/null
ln -sf $TMP/treecache /var/log/mount/
cd /var/log/mount/treecache
echo "Downloading PACKAGES.TXT ..." >> $TMP/wgetout
echo "URL: $REMOTE_URL$REMOTE_ROOT" > $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
if [ $RET != 0 ]; then
echo "> Download failed. Going to try one directory lower." >> $TMP/wgetout
REMOTE_ROOT=$REMOTE_PATH
echo "URL: $REMOTE_URL$REMOTE_ROOT" >> $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
[ $RET != 0 ] && echo "> Download failed again." >> $TMP/wgetout
fiThe variable $REMOTE_PATH stores the user's input but the script discards the user's entered root directory and first searches one level above for PACKAGES.TXT. E.g., if the user followed the directions and entered '/slack/slackware64' then the script will first search in '/slack'. If it finds a PACKAGES.TXT file there then this value will be stored as package location.
Only if it does not find the file the user's entered choice is considered, i.e., '/slack/slackware64'. This will lead to an error in get_pkg() (script slackinstall) later because get_pkg() will search for the packages in '<remote_ip>/slack/slackware64/slackware64' due to the hardcoded 'slackware64' subfolder.
I suggest the following changes:
Code:--- INSURL 2020-03-01 00:58:36.380518663 +0100
+++ INSURL.new 2020-03-02 18:05:20.520953091 +0100
@@ -91,9 +91,10 @@
packages and files arranged in a tree like the FTP site.
The installation script needs to know the name of the
- directory on your server that contains the series
- subdirectories. For example, if your A series is found at
- /slack/slackware64/a, then you would respond: /slack/slackware64
+ directory on the server that contains the slackware64
+ subdirectory. For example, if the A series is found at
+ http://example.com/slack/slackware64/a, then you
+ would respond: /slack
What is the Slackware source directory?
EOF
@@ -126,7 +127,7 @@
dialog --title "DOWNLOAD INFORMATION" --msgbox "$(cat $TMP/tempmsg)" 20 70
rm -f $TMP/tempmsg
- REMOTE_ROOT=$(dirname $REMOTE_PATH)
+ REMOTE_ROOT=$REMOTE_PATH
mkdir -p $TMP/treecache 2>/dev/null
chmod 700 $TMP/treecache
rm -rf $TMP/treecache/* 2>/dev/null
@@ -136,14 +137,7 @@
echo "URL: $REMOTE_URL$REMOTE_ROOT" > $TMP/wgetout
wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
RET=$?
- if [ $RET != 0 ]; then
- echo "> Download failed. Going to try one directory lower." >> $TMP/wgetout
- REMOTE_ROOT=$REMOTE_PATH
- echo "URL: $REMOTE_URL$REMOTE_ROOT" >> $TMP/wgetout
- wget -q $REMOTE_URL$REMOTE_ROOT/PACKAGES.TXT > /dev/null 2>&1
- RET=$?
- [ $RET != 0 ] && echo "> Download failed again." >> $TMP/wgetout
- fi
+ [ $RET != 0 ] && echo "> Download failed." >> $TMP/wgetout
echo "" >> $TMP/wgetout
if [ -r /var/log/mount/treecache/PACKAGES.TXT ]; thenI changed the description to emphasize that the client does/should not need to know the location on the server's filesystem, only the location inside the published webfolder. For the PXE setup scenario this would just be '/'. I have tested and verified the INSURL solution in PXE setup scenario.
I checked the INSNFS script, too. It has the same instructions regarding the repositories location but at some point it also expects a 'slackware64' directory. For nfs, however, the user needs to know the exact location on the fileserver, I think. I did not have time to verify the nfs issue, yet.