Ticket #65 (closed Defect: fixed)

Opened 6 months ago

Last modified 4 months ago

Broken --prefix option in file ./install in autopackage.tar.bz2

Reported by: jahvascriptmaniac Assigned to: isak
Priority: High Milestone: 1.2.5
Component: main Version: 1.2.4
Severity: Normal Keywords: prefix installer
Cc: tajmorton@gmail.com

Description

In the autopackage installer, autopackage.tar.bz2 : In the file install (in the archive's root) :

lines 83-87 :

	case "$1" in

	# Adjust prefix location
	--prefix)
		prefix="$1"
		shift
		;;

Should be :

	case "$1" in

	# Adjust prefix location
	--prefix)
		prefix="$2"
		shift 2
		;;

You should change $1 to $2 and change shift to shift 2 on line 87. At the moment, using this option has the effect of assigning "--prefix" to the prefix variable, which breaks the whole installation process.

Also, you should check that the prefix matches an existing directory, if not ask the user for confirmation / output a wrning and mkdir -p it :

forceprefix=0
while [ $# -gt 0 ]
do
	case "$1" in

	# Accept non-existing prefix
	--force-prefix)
		forceprefix=1
		shift
		;;
		
	# Adjust prefix location
	--prefix)
		prefix="$2"
		shift 2
		;;
	
	...
	
	esac
doce

if [ ! -d "$prefix" ]; then
	if [ $forceprefix != 1 ]; then
		echo "ERROR : $prefix isn't a directory ! Use --force-prefix to force."
		exit 1
	else
		echo "Creating $prefix ..."
		mkdir -p "$prefix"
	fi
fi

I don't know if the variable forceprefix matches the naming convention in autopackage, you'd better check it out.

Last thing : on line 99 :

		shift 1

Should be :

		shift

(The 1 is useless and isn't provided for the --silence option, which could make someone trying to understand guess that "shift 1" shifts 2 arguments (1 extra) unlike "shift" which shifts 1 argument. That's what I thought for a few seconds.)

Attachments

prefix-option-main-installer.diff (410 bytes) - added by isak on 01/12/08 18:57:15.
remove "1" after shift call to be consistent

Change History

01/12/08 18:55:10 changed by isak

  • keywords changed from prefix to prefix installer.
  • owner changed from jahvascriptmaniac to isak.
  • cc set to tmorton@gmail.com.
  • milestone set to 1.2.5.

For the record, the file we're talking about here is autopackage-install.

I haven't tested this yet, but it surely seems you are correct. I created a proper patch from your comment (attached above), and as soon as I get this tested it should (most likely) go in.

Regarding the check for directory existance and the warning - I don't think that is really needed. The directories will be created anyway (we have mkdir -p further down in the code), and I think it's just annoying having to specify another argument.

01/12/08 18:57:15 changed by isak

  • attachment prefix-option-main-installer.diff added.

remove "1" after shift call to be consistent

01/12/08 18:59:24 changed by isak

  • cc changed from tmorton@gmail.com to tajmorton@gmail.com.

04/06/08 15:14:38 changed by isak

  • status changed from new to closed.
  • resolution set to fixed.

Patch applied in r2436. Thanks for reporting and investigating this and sorry for the long delay in getting this applied.