- tostrip="/"
- fi
-
- if [ "$files" ]; then
- for file in $files; do
- # Strip leading $tostrip from $file. If not there,
- # leave $file untouched.
- if [ `expr "$file" : "$tostrip\\(.*\\)"` ]; then
- file=`expr "$file" : "$tostrip\\(.*\\)"`
- fi
-
- # Create the sed string that will be used to
- # fill in the blanks in the autoscript files.
- # Fill with the owner, group, and perms of the file.
- sedstr=`find debian/$TMP/$file -printf "s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/%u/;s/#GROUP#/%g/;s/#PERMS#/%m/"`
-
- autoscript "postinst" "postinst-suid" "$sedstr"
- autoscript "postrm" "postrm-suid" "$sedstr"
- done
- fi
-done
+ $tostrip="/";
+ }
+
+ foreach $file (@files) {
+ # Strip leading $tostrip from $file.
+ $file=~s/^$tostrip//;
+
+ if (! -e "$TMP/$file") {
+ error("\"$TMP/$file\" does not exist.");
+ }
+
+ # Create the sed string that will be used to
+ # fill in the blanks in the autoscript files.
+ # Fill with the owner, group, and perms of the file.
+ (undef,undef,$mode,undef,$uid,$gid,undef) = stat("$TMP/$file");
+ # Now come up with the user and group names for the uid and gid.
+ $user=getpwuid($uid);
+ if (! defined $user) {
+ warning("$file has odd uid $uid, not in /etc/passwd");
+ $user=$uid;
+ }
+ $group=getgrgid($gid);
+ if (! defined $group) {
+ warning("$file has odd gid $gid not in /etc/group");
+ $group=$gid;
+ }
+ # Note that I have to print mode in ocal, stripping file type.
+ $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/$user/;s/#GROUP#/$group/;s/#PERMS#/%#o/",
+ $mode & 07777);
+
+ autoscript($PACKAGE,"postinst","postinst-suid",$sedstr);
+ autoscript($PACKAGE,"postrm","postrm-suid","$sedstr");
+
+ if ( -e "$TMP/$file") {
+ doit("chmod","a-s","$TMP/$file");
+ }
+ }
+}