Project

General

Profile

« Previous | Next » 

Revision d51927d2

Added by Jim Pingle about 13 years ago

Update pbi_create to current code from pc-bsd

View differences:

usr/local/sbin/pbi_create
35 35
  -i             -- Display information about this PBI
36 36
  -l             -- Display LICENSE text
37 37
  -o outdir      -- Extract to target directory 
38
  -r 	         -- Remote fetch installation file from update server
38
  -r 	         -- Fetch and install PBI
39
  -R 	         -- Fetch install file and save to disk (Do not install)
39 40
  -v             -- Enable verbose output
40 41
  --checkscript  -- Display any custom install / removal scripts
41 42
  --licagree     -- Agree to LICENSE terms for installation
......
62 63
  --genpatch   -- Generate patch files (*.pbp) from archived PBIs to current
63 64
  --keep <num> -- Keep <num> old versions in archive folder for each built PBI
64 65
  --prune      -- Remove files from 'outdir' that no longer have a module
66
  --pkgcache   -- Create and use a .txz pkg cache directory, in the <outdir> of each PBI
67
  --tmpfs      -- Use TMPFS for port WRKDIRPREFIX
65 68
  --sign key   -- Sign the PBI(s) with specified openssl key
66 69

  
67 70
EOF
......
116 119
  -p prefix    -- Specify alternate PBI Compile PREFIX
117 120
  --delbuild   -- Delete existing build dirs if they exist
118 121
  --mkdebug    -- Drop to debug shell if port make fails
122
  --tmpfs      -- Use TMPFS for port WRKDIRPREFIX
119 123
  --no-prune   -- Do not prune non REQUIREDBY ports
124
  --pkgdir dir -- Enable .txz pkg caching in the following directory
120 125
  --sign key   -- Sign the PBI with specified openssl key
121 126

  
122 127
EOF
......
158 163
usage: `basename $0` [options] oldpbi newpbi
159 164
                
160 165
Options:
161
  -o outdir    -- Save the .PBP file to outdir
162
  --sign key   -- Sign the PBI with specified openssl key
166
  -o outdir      -- Save the .PBP file to outdir
167
  --sign key     -- Sign the PBI with specified openssl key
168
  --no-checksig  -- Ignore signature verification and force install
169

  
163 170

  
164 171
EOF
165 172
        exit_trap
......
400 407
                case "$1" in
401 408
                -v)     PBI_VERBOSE="YES" 
402 409
                        ;;
410
         --refresh)     # Schedule us to refresh the index
411
			echo "Your meta and index files will begin refreshing in a moment..."
412
			echo "Details available in /var/log/pbid.log"
413
			rm ${PBI_DBINDEXDIR}/*.time >/dev/null 2>/dev/null
414
			if [ -e "/usr/local/etc/rc.d/pbid" ]; then
415
			   /usr/local/etc/rc.d/pbid restart >/dev/null 2>/dev/null
416
			fi
417
			exit 0
418
                        ;;
403 419
		esac
404 420
		shift
405 421
	done
......
440 456
            --sign)     if [ $# -eq 1 ]; then usage_makepatch_pbi; fi
441 457
                        shift; PBI_SSLPRIVKEY="$1"
442 458
                        ;;
459
     --no-checksig)     PBI_SKIPSIGVERIFY="YES" ;;
443 460
                 *)	if [ $# -gt 2  ]; then usage_makepatch_pbi; fi
444 461
                       	PBI_OLDFILENAME="$1"
445 462
			shift
......
614 631
		     if [ ! -f "${PBI_IT_ADDINDEX}" ] ; then 
615 632
			exit_err "No such file ${PBI_IT_ADDINDEX}"
616 633
		     fi
617
		     if [ ! -z "${PBI_IT_ADDKEEP}" ] ; then 
634
		     if [ -n "${PBI_IT_ADDKEEP}" ] ; then 
618 635
			expr ${PBI_IT_ADDKEEP} + 1 >/dev/null 2>/dev/null
619 636
			if [ "$?" != "0" ] ; then
620 637
				exit_err "-k option must be a integer!"
......
650 667
        done
651 668

  
652 669
	# Get / check the repoid
653
	if [ ! -z "${PBI_BROWSE_RID}" ] ; then
670
	if [ -n "${PBI_BROWSE_RID}" ] ; then
654 671
		ls ${PBI_DBREPODIR}/${PBI_BROWSE_RID}.* >/dev/null 2>/dev/null
655 672
		if [ "$?" != "0" ] ; then
656 673
			exit_err "The specified repoid ${PBI_BROWSE_RID} does not exist!"
......
697 714
	if [ "${PBI_LISTREPO_DOWN}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
698 715
		exit_err "Missing Repo ID to move down in priority."
699 716
	fi
700
	if [ ! -z "${PBI_LISTREPO_MIRROR}" -a -z "${PBI_LISTREPO_ID}" ]; then
717
	if [ -n "${PBI_LISTREPO_MIRROR}" -a -z "${PBI_LISTREPO_ID}" ]; then
701 718
		exit_err "Missing Repo ID to change a specific mirror URL."
702 719
	fi
703 720

  
704
	if [ ! -z "${PBI_LISTREPO_ID}" ] ; then
721
	if [ -n "${PBI_LISTREPO_ID}" ] ; then
705 722
		ls ${PBI_DBREPODIR}/${PBI_LISTREPO_ID}.* >/dev/null 2>/dev/null
706 723
		if [ "$?" != "0" ] ; then
707 724
			exit_err "The specified repoid ${PBI_LISTREPO_ID} does not exist!"
......
774 791
        if [ -z "${PBI_MKREPO_URL}" ]; then usage_makerepo_pbi ; fi
775 792
        if [ -z "${PBI_MKREPO_OUTDIR}" ]; then PBI_MKREPO_OUTDIR="${HOME}"; fi
776 793
        if [ ! -f "${PBI_MKREPO_KEY}" ]; then exit_err "The key file ${PBI_MKREPO_KEY} does not exist." ; fi
794
	
795
	# Make sure we have a valid URL format
796
        echo "${PBI_MKREPO_URL}" | grep -q -e "^http://" -e "^https://" -e "^ftp://"
797
	if [ $? -ne 0 ] ; then
798
		exit_err "Repo URL must begin with http://, https://, or ftp://"
799
	fi
800
	
777 801

  
778 802
}
779 803

  
......
828 852
                # If extracting to a alt-outdir, set it now
829 853
                PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
830 854
        
831
                if [ ! -z "${PBI_ALTEXTRACT_DIR}" ]; then
855
                if [ -n "${PBI_ALTEXTRACT_DIR}" ]; then
832 856
                        PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
833 857
                fi      
834 858
        else
......
856 880
                        ;;
857 881
                -r)     PBI_REMOTEFETCH="YES" 
858 882
			;;
883
                -R)     PBI_REMOTEFETCH="YES" 
884
			PBI_REMOTEFETCHONLY="YES"
885
			;;
859 886
                -v)     PBI_VERBOSE="YES" 
860 887
                        ;;
861 888
           --rArch)     
......
922 949
		# If extracting to a alt-outdir, set it now
923 950
		PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
924 951

  
925
		if [ ! -z "${PBI_ALTEXTRACT_DIR}" ]; then
952
		if [ -n "${PBI_ALTEXTRACT_DIR}" ]; then
926 953
			PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
927 954
		fi
928 955
	else
......
936 963
        while [ $# -gt 0 ]; do
937 964
                case "$1" in
938 965
                -c)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
939
                        if [ ! -z "${PBI_AB_CONFDIR}" ]; then usage_autob_pbi; fi
966
                        if [ -n "${PBI_AB_CONFDIR}" ]; then usage_autob_pbi; fi
940 967
                        shift
941 968
                        get_abspath "$1"
942 969
                        PBI_AB_CONFDIR="$_ABSPATH"
......
962 989

  
963 990
        --genpatch)     PBI_AB_GENPATCH="YES" 
964 991
                        ;;
992
        --pkgcache)     PBI_AB_PKGCACHE="YES" 
993
                        ;;
965 994
            --keep)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
966 995
                        shift; PBI_AB_ARCHIVENUM="$1"
967 996
			expr $PBI_AB_ARCHIVENUM + 1 >/dev/null 2>/dev/null
......
969 998
                        ;;
970 999
           --prune)     PBI_AB_PRUNE="YES" 
971 1000
                        ;;
1001
           --tmpfs)     PBI_AB_TMPFS="YES" 
1002
                        ;;
972 1003
            --sign)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
973 1004
                        shift; PBI_AB_SSLPRIVKEY="$1"
974 1005
                        ;;
......
1045 1076
        done
1046 1077

  
1047 1078
	# Make sure this port exists
1048
        if [ ! -z "${PBI_MAKEPORT}" -a ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ]; then
1079
        if [ -n "${PBI_MAKEPORT}" -a ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ]; then
1049 1080
		exit_err "No port (${PORTSDIR}/${PBI_MAKEPORT})"
1050 1081
	fi
1051 1082

  
1052 1083
	# Load the name / version from specified port
1053
        if [ ! -z "${PBI_MAKEPORT}" ]; then
1084
        if [ -n "${PBI_MAKEPORT}" ]; then
1054 1085
		get_pbi_progversion
1055 1086
		get_pbi_progname
1056 1087
        fi
......
1063 1094

  
1064 1095
# Override any pbi.conf values with passed command-line values
1065 1096
parse_cmdline_overrides() {
1066
	if [ ! -z "${PBI_CNAME}" ] ; then PBI_PROGNAME="${PBI_CNAME}" ; fi
1067
	if [ ! -z "${PBI_CVERSION}" ] ; then PBI_PROGVERSION="${PBI_CVERSION}" ; fi
1068
	if [ ! -z "${PBI_CWEB}" ] ; then PBI_PROGWEB="${PBI_CWEB}" ; fi
1069
	if [ ! -z "${PBI_CAUTHOR}" ] ; then PBI_PROGAUTHOR="${PBI_CAUTHOR}" ; fi
1070
	if [ ! -z "${PBI_CICON}" ] ; then PBI_PROGICON="${PBI_CICON}" ; fi
1097
	if [ -n "${PBI_CNAME}" ] ; then PBI_PROGNAME="${PBI_CNAME}" ; fi
1098
	if [ -n "${PBI_CVERSION}" ] ; then PBI_PROGVERSION="${PBI_CVERSION}" ; fi
1099
	if [ -n "${PBI_CWEB}" ] ; then PBI_PROGWEB="${PBI_CWEB}" ; fi
1100
	if [ -n "${PBI_CAUTHOR}" ] ; then PBI_PROGAUTHOR="${PBI_CAUTHOR}" ; fi
1101
	if [ -n "${PBI_CICON}" ] ; then PBI_PROGICON="${PBI_CICON}" ; fi
1071 1102
}
1072 1103

  
1073 1104
# Parse the command line
......
1078 1109
                        ;;
1079 1110
                -c)
1080 1111
                        if [ $# -eq 1 ]; then usage_make_pbi; fi
1081
                        if [ ! -z "${PBI_CONFDIR}" ]; then usage_make_pbi; fi
1112
                        if [ -n "${PBI_CONFDIR}" ]; then usage_make_pbi; fi
1082 1113
                        shift
1083 1114
			get_abspath "$1"
1084 1115
			PBI_CONFDIR="$_ABSPATH"
......
1097 1128
                        ;;
1098 1129
                --mkdebug)	MKDEBUG="YES"
1099 1130
                        ;;
1131
                --tmpfs)	MKTMPFS="YES"
1132
                        ;;
1100 1133
                -o)	if [ $# -eq 1 ]; then usage_make_pbi; fi
1101 1134
                        shift
1102 1135
			get_abspath "$1"
1103 1136
			PBI_CREATE_OUTDIR="$_ABSPATH"
1104 1137
                        ;;
1105 1138
                -p)	if [ $# -eq 1 ]; then usage_make_pbi; fi
1106
                        if [ ! -z "${PBI_MAKEPREFIX}" ]; then usage_make_pbi; fi
1139
                        if [ -n "${PBI_MAKEPREFIX}" ]; then usage_make_pbi; fi
1107 1140
                        shift; PBI_MAKEPREFIX="$1"
1108 1141
                        ;;
1109
            --sign)	if [ $# -eq 1 ]; then usage_create_pbi; fi
1142
            --pkgdir)	if [ $# -eq 1 ]; then usage_make_pbi; fi
1143
			shift
1144
			get_abspath "$1"
1145
			PBI_PKGCACHEDIR="$_ABSPATH"
1146
			PBI_PKGCACHE="YES"
1147
                        ;;
1148
            --sign)	if [ $# -eq 1 ]; then usage_make_pbi; fi
1110 1149
			shift
1111 1150
			get_abspath "$1"
1112 1151
			PBI_SSLPRIVKEY="$_ABSPATH"
......
1121 1160

  
1122 1161
	# Override some locations if working in chroot environment
1123 1162
	if [ "`basename $0`" = "pbi_makeport_chroot" ] ; then 
1124
		if [ ! -z "${PBI_CONFDIR}" ] ; then PBI_CONFDIR="/pbimodule" ; fi
1125
		if [ ! -z "${PBI_SSLPRIVKEY}" ] ; then PBI_SSLPRIVKEY="/privkey.pem" ; fi
1126
		if [ ! -z "${PBI_CREATE_OUTDIR}" ] ; then PBI_CREATE_OUTDIR="/pbiout" ; fi
1127
		if [ ! -z "${PORTSDIR}" ] ; then PORTSDIR="/usr/ports" ; fi
1163
		if [ -n "${PBI_CONFDIR}" ] ; then PBI_CONFDIR="/pbimodule" ; fi
1164
		if [ -n "${PBI_SSLPRIVKEY}" ] ; then PBI_SSLPRIVKEY="/privkey.pem" ; fi
1165
		if [ -n "${PBI_CREATE_OUTDIR}" ] ; then PBI_CREATE_OUTDIR="/pbiout" ; fi
1166
		if [ -n "${PORTSDIR}" ] ; then PORTSDIR="/usr/ports" ; fi
1167
	else
1168
	# If running as pbi_makeport
1169

  
1170
		# Make sure the PBI_PKGCACHEDIR exists
1171
		if [ -n "${PBI_PKGCACHEDIR}" -a ! -d "${PBI_PKGCACHEDIR}" ] ; then
1172
			exit_err "No such directory: ${PBI_PKGCACHEDIR}"
1173
		fi
1128 1174
	fi
1129 1175

  
1176

  
1130 1177
	# Make sure this port exists
1131 1178
	if [ ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ] ; then
1132 1179
		exit_err "No port (${PORTSDIR}/${PBI_MAKEPORT})"
1133 1180
	fi
1134 1181

  
1135 1182
	# Make sure we have a valid PBI_CONFDIR
1136
	if [ ! -z "${PBI_CONFDIR}" -a ! -d "${PBI_CONFDIR}" ] ; then
1183
	if [ -n "${PBI_CONFDIR}" -a ! -d "${PBI_CONFDIR}" ] ; then
1137 1184
		exit_err "Invalid confdir (${PBI_CONFDIR})"
1138 1185
	fi
1139 1186

  
1140 1187
	# Source the config file
1141
	if [ ! -z "${PBI_CONFDIR}" ]; then load_pbi_conffile ; fi
1188
	if [ -n "${PBI_CONFDIR}" ]; then load_pbi_conffile ; fi
1142 1189

  
1143 1190
        if [ -z "${PBI_MAKEPORT}" ]; then
1144 1191
                usage_make_pbi
......
1155 1202
     --enable-auto)	PBI_UPENABLEAUTO="YES" ;; 
1156 1203
      --update-all)	PBI_UPDATEAPP="ALL" ;; 
1157 1204
                 *)     if [ $# -gt 1 ]; then usage_update_pbi; fi
1158
			if [ ! -z "$PBI_UPDATEAPP" ] ; then usage_update_pbi ; fi
1205
			if [ -n "$PBI_UPDATEAPP" ] ; then usage_update_pbi ; fi
1159 1206
			if [ ! -e "${PBI_DBAPPDIR}/${1}" ] ; then
1160 1207
                                exit_err "can't find installed pbi (${1})"
1161 1208
                        fi
......
1165 1212
                shift
1166 1213
        done
1167 1214

  
1168
	if [ "${PBI_UPDATEAPP}" = "ALL" -a ! -z "${PBI_UPCHECK}" ] ; then
1215
	if [ "${PBI_UPDATEAPP}" = "ALL" -a -n "${PBI_UPCHECK}" ] ; then
1169 1216
                usage_update_pbi
1170 1217
        fi
1171 1218

  
1172 1219
	# Make sure we aren't trying to enable auto-updating for ALL
1173
	if [ "${PBI_UPDATEAPP}" = "ALL" -a ! -z "${PBI_UPENABLEAUTO}" ] ; then
1220
	if [ "${PBI_UPDATEAPP}" = "ALL" -a -n "${PBI_UPENABLEAUTO}" ] ; then
1174 1221
                usage_update_pbi
1175 1222
        fi
1176
	if [ -z "${PBI_UPDATEAPP}" -a ! -z "${PBI_UPENABLEAUTO}" ] ; then
1223
	if [ -z "${PBI_UPDATEAPP}" -a -n "${PBI_UPENABLEAUTO}" ] ; then
1177 1224
                usage_update_pbi
1178 1225
        fi
1179 1226

  
......
1210 1257
	chmod 664 ${PBI_DBDIRTYFILE}
1211 1258
}
1212 1259

  
1213
# Get the absolute path of a dir
1260
# Get the absolute path of a dir, even a realative dir. 'realpath' doesn't work here
1214 1261
get_abspath() {
1215 1262
	D=`dirname "$1"`
1216
     	B=`basename "$1"`
1263
	B=`basename "$1"`
1217 1264
	if [ "$D" = "/" ] ; then
1218 1265
		_ABSPATH="/$B"
1219 1266
	else
......
1229 1276
	FBSDMAJOR=`uname -r | cut -c 1`
1230 1277
        PROGBASE="/usr/local" 
1231 1278
	SYS_LOCALBASE="/usr/local"
1232
	PBI_APPDIR="/usr/pbi"
1233
	PBI_CHROOTFILE="${PBI_APPDIR}/.pbi-world.tbz"
1279
	if [ -z "${PBI_APPDIR}" -o "`basename $0`" = "pbi_makeport_chroot" ] ; then
1280
		PBI_APPDIR="/usr/pbi"
1281
        fi
1282
	PBI_WRAPPERFILE="${PBI_APPDIR}/.pbiwrapper"
1283
	PBI_CHROOTFILE="${PBI_APPDIR}/.pbi-world.txz"
1234 1284
	if [ `id -u` = "0" ] ; then 
1235 1285
		PBI_HASHDIR="${PBI_APPDIR}/.hashdir"
1236 1286
	else
......
1240 1290
	PBI_ETCCONF="${SYS_LOCALBASE}/etc/pbi.conf"
1241 1291
	PCBSD_ETCCONF="${SYS_LOCALBASE}/etc/pcbsd.conf"
1242 1292
	PBI_DEFAULT_ICON="${PROGBASE}/share/pbi-manager/icons/default.png"
1293
	PBI_DEFAULT_ICON_CHROOT="/default.png"
1243 1294
	PBI_PATCH_ICON="${PROGBASE}/share/pbi-manager/icons/patch.png"
1244 1295
	PBI_LDCONFIGFILE="${PROGBASE}/etc/ldpbiconfig"
1245 1296
	PBI_LDCONFIGRC="${PROGBASE}/etc/rc.d/ldpbiconfig"
......
1269 1320
	PBI_APPDESK_DIR=".${MOD_XDGDESK_DIR}"
1270 1321
	PBI_APPMENU_DIR=".${MOD_XDGMENU_DIR}"
1271 1322
	PBI_APPMIME_DIR=".${MOD_XDGMIME_DIR}"
1323
	PBI_BUILD_USERS=""
1324
	PBI_BUILD_GROUPS=""
1325
	PBI_INS_USERSFILE=".pbi-uids"
1326
	PBI_INS_GROUPSFILE=".pbi-gids"
1272 1327
	PBI_DESKADD="NO"
1273 1328
	PBI_MENUADD="NO"
1274 1329
	PBI_MIMEADD="NO"
1275 1330
	PBI_PATHADD="NO"
1276 1331
	PBI_DESKDEL="NO"
1332
	PBI_MAKECONF="/etc/pbi-make.conf"
1277 1333
	PBI_MENUDEL="NO"
1278 1334
	PBI_MIMEDEL="NO"
1279 1335
	PBI_PATHDEL="NO"
......
1298 1354
	PBI_PATCHVERSION=""
1299 1355
	PBI_PATCHTARGET=""
1300 1356
	PBI_REMOTEFETCH=""
1357
	PBI_REMOTEFETCHONLY=""
1301 1358
	PBI_RESOURCE_DIR="resources"
1302 1359
	PBI_SS_ICON="__PBI_ICON__"
1303 1360
	PBI_SS_ARCHIVE="__PBI_ARCHIVE__"
......
1314 1371
        # User overridable variables
1315 1372
	MKDELBUILD=""
1316 1373
	MKDEBUG=""
1374
	MKTMPFS=""
1317 1375
	PBI_AB_ARCHIVENUM=""
1318 1376
	PBI_AB_CONFDIR=""
1319 1377
	PBI_AB_GENPATCH="NO"
......
1321 1379
	PBI_AB_OUTDIR=""
1322 1380
	PBI_AB_SSLPRIVKEY=""
1323 1381
	PBI_AB_PRUNE=""
1382
	PBI_AB_TMPFS=""
1324 1383
	PBI_BUILDONLY="NO"
1325 1384
	PBI_CAUTHOR=""
1326 1385
	PBI_CBACKUP=""
......
1409 1468
		rm -rf "${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
1410 1469
		chflags -R noschg "${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
1411 1470
		rm -rf "${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
1412
		rm -rf /ramfs/build.$$ >/dev/null 2>/dev/null
1413 1471
	fi
1414 1472
	if [ -z "$PBI_CHROOTDIR" ] ; then return ; fi
1415 1473
	chroot_make_cleanup
......
1419 1477
load_pbi_conffile() {
1420 1478
  	if [ ! -d "${PBI_CONFDIR}" ] ; then return 0 ; fi
1421 1479
  	if [ -e "${PBI_CONFDIR}/${PBI_CONFFILE}" ] ; then
1422
		unset PBI_MAKEPORT PBI_BUILDKEY PBI_REQUIRESROOT PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_PROGICON PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_MAKEOPTS PBI_EXCLUDELIST PBI_AB_PRIORITY PBI_HASH_EXCLUDES
1480
		unset PBI_MAKEPORT PBI_BUILDKEY PBI_REQUIRESROOT PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_PROGICON PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_MAKEOPTS PBI_EXCLUDELIST PBI_AB_PRIORITY PBI_HASH_EXCLUDES PBI_AB_NOTMPFS PBI_PROGREVISION
1423 1481
		. ${PBI_CONFDIR}/${PBI_CONFFILE}
1424 1482
	fi
1425 1483
}
......
1429 1487

  
1430 1488
	if [ -z "${PBI_PROGVERSION}" ] ; then
1431 1489
		load_pbi_conffile
1490

  
1491
		# If we have PBI_PROGVERSION now set
1492
		if [ -n "${PBI_PROGVERSION}" ] ; then return 0 ; fi
1432 1493
	else
1433 1494
		return 0
1434 1495
	fi
1435 1496

  
1436
	if [ -z "${PBI_PROGVERSION}" -a ! -z "${PORTSDIR}" -a ! -z "${PBI_MAKEPORT}" ] ; then
1497
	if [ -z "${PBI_PROGVERSION}" -a -n "${PORTSDIR}" -a -n "${PBI_MAKEPORT}" ] ; then
1437 1498
		PORTVER="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V DISTVERSION 2>/dev/null`"
1438 1499

  
1439 1500
  		# Check if we have a portrevision to use in version number
1440 1501
  		PORTREV=""
1441 1502
  		PORTREV="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V PORTREVISION 2>/dev/null`"
1442
  		if [ ! -z "${PORTREV}" -a "${PORTREV}" != "0" ]
1503
  		if [ -n "${PORTREV}" -a "${PORTREV}" != "0" ]
1443 1504
 		then
1444 1505
   			PORTVER="${PORTVER}_${PORTREV}"
1445 1506
		fi
......
1450 1511
		        echo "make -C ${PORTSDIR}/${PBI_MAKEPORT} -V DISTVERSION"
1451 1512
		fi
1452 1513
	else
1514
		echo "PBI_PROGVERSION - $PBI_PROGVERSION - PORTSDIR - ${PORTSDIR} - $PBI_MAKEPORT - $PBI_MAKE_PORT - pbi - $pbi"
1453 1515
		exit_err "Failed to locate PBI_PROGVERSION"
1454 1516
	fi
1455 1517

  
1456 1518
	# If we have a REVISION, use it as well
1457
	if [ ! -z "$PBI_PROGREVISION" ] ; then
1519
	if [ -n "$PBI_PROGREVISION" ] ; then
1458 1520
		PBI_PROGVERSION="${PBI_PROGVERSION}_${PBI_PROGREVISION}"
1459 1521
	fi
1460 1522
}
......
1468 1530
		return 0
1469 1531
	fi
1470 1532

  
1471
	if [ -z "${PBI_PROGNAME}" -a ! -z "${PORTSDIR}" -a ! -z "${PBI_MAKEPORT}" ] ; then
1533
	if [ -z "${PBI_PROGNAME}" -a -n "${PORTSDIR}" -a -n "${PBI_MAKEPORT}" ] ; then
1472 1534
		PBI_PROGNAME="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V PORTNAME`"
1473 1535
	else
1474 1536
		exit_err "Failed to locate PBI_PROGNAME"
......
1483 1545

  
1484 1546
	tmp="`echo ${PBI_PROGNAME} | tr -d ' ' | tr '[A-Z]' '[a-z]'`"
1485 1547
	ARCH="`uname -m`"
1548
	if [ -n "${PBI_OSARCH}" ] ; then
1549
		ARCH="${PBI_OSARCH}"
1550
	fi
1486 1551
	if [ -z "${PBI_PROGDIRNAME}" ] ; then
1487 1552
		PBI_PROGDIRNAME="${tmp}-${ARCH}"
1488 1553
	fi
......
1510 1575
		echo "Cleaning up patch data..."
1511 1576
	fi
1512 1577

  
1513
	if [ ! -z "${_pbiNewDir}" -a -d "${_pbiNewDir}" -a "${_pbiNewDir}" != "/" ] ; then
1578
	if [ -n "${_pbiNewDir}" -a -d "${_pbiNewDir}" -a "${_pbiNewDir}" != "/" ] ; then
1514 1579
	 	rm -rf "${_pbiNewDir}" >/dev/null 2>/dev/null
1515 1580
	 	chflags -R noschg "${_pbiNewDir}" >/dev/null 2>/dev/null
1516 1581
	 	rm -rf "${_pbiNewDir}" >/dev/null 2>/dev/null
1517 1582
	fi
1518
	if [ ! -z "${_pbiOldDir}" -a -d "${_pbiOldDir}" -a "${_pbiOldDir}" != "/" ] ; then
1583
	if [ -n "${_pbiOldDir}" -a -d "${_pbiOldDir}" -a "${_pbiOldDir}" != "/" ] ; then
1519 1584
	 	rm -rf "${_pbiOldDir}" >/dev/null 2>/dev/null
1520 1585
	 	chflags -R noschg "${_pbiOldDir}" >/dev/null 2>/dev/null
1521 1586
	 	rm -rf "${_pbiOldDir}" >/dev/null 2>/dev/null
1522 1587
	fi
1523
	if [ ! -z "${_pbiPatchDir}" -a -d "${_pbiPatchDir}" -a "${_pbiPatchDir}" != "/" ] ; then
1588
	if [ -n "${_pbiPatchDir}" -a -d "${_pbiPatchDir}" -a "${_pbiPatchDir}" != "/" ] ; then
1524 1589
	 	rm -rf "${_pbiPatchDir}" >/dev/null 2>/dev/null
1525 1590
	 	chflags -R noschg "${_pbiPatchDir}" >/dev/null 2>/dev/null
1526 1591
	 	rm -rf "${_pbiPatchDir}" >/dev/null 2>/dev/null
......
1530 1595
# Check if we need to delete a remotely dl'd file
1531 1596
clean_remote_dl() {
1532 1597
	# If this was a remote fetch, remove dl'd file
1533
	if [ "$PBI_REMOTEFETCH" = "YES" -a ! -z "$PBI_FILENAME" ]; then 
1598
	if [ "$PBI_REMOTEFETCH" = "YES" -a -n "$PBI_FILENAME" ]; then 
1534 1599
		rm "$PBI_FILENAME" >/dev/null 2>/dev/null
1535 1600
	fi
1536 1601
}
......
1559 1624
	echo "NO_IGNORE=yes" >> ${MAKE_CONF}
1560 1625
	echo "PACKAGE_BUILDING=yes" >> ${MAKE_CONF}
1561 1626

  
1562
	# If a ramfs dir is present, lets use it
1563
	if [ -d "/ramfs" ] ; then 
1564
		mkdir /ramfs/build.$$
1565
		echo "WRKDIRPREFIX=/ramfs/build.$$" >> ${MAKE_CONF}
1627
	# If we plan on using TMPFS set it now
1628
	if [ "$MKTMPFS" = "YES" ] ; then 
1629
		echo "WRKDIRPREFIX=/tmpfs" >> ${MAKE_CONF}
1630
		echo "DEPENDS_CLEAN=YES" >> ${MAKE_CONF}
1631
	else
1632
		mkdir /usr/wrkdirprefix
1633
		echo "WRKDIRPREFIX=/usr/wrkdirprefix" >> ${MAKE_CONF}
1566 1634
	fi
1567 1635

  
1568

  
1569
	if [ ! -z "$PBI_MAKEOPTS" ] ; then
1636
	if [ -n "$PBI_MAKEOPTS" ] ; then
1570 1637
		# Check if we have custom make opts
1571 1638
		echo "${PBI_MAKEOPTS}" >> ${MAKE_CONF}
1572 1639
	fi
......
1579 1646
	# Make sure ldconfig is primed
1580 1647
	/etc/rc.d/ldconfig start
1581 1648

  
1649
	# Check if using ccache directory
1650
	if [ -d "/.ccache" ] ; then
1651
		echo "Enabling ccache..."
1652
		cd /usr/ports/devel/ccache 
1653
		make install clean
1654
		if [ $? -eq 0 ] ; then
1655
			# Setup environment variables
1656
			CCACHE_PATH="/usr/bin:${LOCALBASE}/bin"
1657
			export CCACHE_PATH
1658
			CCACHE_DIR="/.ccache"
1659
			export CCACHE_DIR
1660
			PATH="${LOCALBASE}/libexec/ccache:${PATH}"
1661
			export PATH
1662

  
1663
			# Setup make configuration
1664
			echo ".if !defined(NO_CCACHE)" >> ${MAKE_CONF}
1665
			echo "  CC=${LOCALBASE}/libexec/ccache/world/cc" >> ${MAKE_CONF}
1666
			echo "  CXX=${LOCALBASE}/libexec/ccache/world/c++" >> ${MAKE_CONF}
1667
			echo ".endif" >> ${MAKE_CONF}
1668
		else
1669
			echo "Failed installing ccache! Continuing without it..."
1670
		fi
1671
	fi
1672

  
1582 1673
	PATH="${PATH}:/usr/local/bin:/usr/local/sbin:${LOCALBASE}/bin:${LOCALBASE}/sbin"
1583 1674
	export PATH
1584 1675

  
......
1904 1995
	mv "${PBI_IT_ADDINDEX}" "${PBI_TMPDIR}/.indextmp"
1905 1996
	local _date=`date '+%s'`
1906 1997
	local _sha256=`sha256 -q ${PBI_FILENAME}`
1907
	echo "${_pbilow}:${PBI_APPARCH}:${PBI_PROGVERSION}:${_sha256}:${PBI_PROGMDATE}:${PBI_IT_ADDURL}:$_date:${PBI_IT_ADDBPVERS}:current" >>"${PBI_TMPDIR}/.indextmp"
1998
	local _psize=`du -k ${PBI_FILENAME} | cut -f 1`
1999
	echo "${_pbilow}:${PBI_APPARCH}:${PBI_PROGVERSION}:${_sha256}:${PBI_PROGMDATE}:${PBI_IT_ADDURL}:$_date:${PBI_IT_ADDBPVERS}:current:${_psize}:" >>"${PBI_TMPDIR}/.indextmp"
1908 2000
	sort ${PBI_TMPDIR}/.indextmp > "${PBI_IT_ADDINDEX}"
1909 2001
}
1910 2002

  
......
1948 2040
	_rArch=`uname -m`
1949 2041

  
1950 2042
	# Figure out which type of display we are doing
1951
	if [ ! -z "$PBI_BROWSE_LISTALLPBI" ] ; then
2043
	if [ -n "$PBI_BROWSE_LISTALLPBI" ] ; then
1952 2044
		echo "Using RepoID: $PBI_BROWSE_RID"
1953 2045
		echo "Listing all available PBIs"
1954 2046
		grep -i -e "^App=" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
1955
	elif [ ! -z "$PBI_BROWSE_CAT" ] ; then
2047
	elif [ -n "$PBI_BROWSE_CAT" ] ; then
1956 2048
		echo "Using RepoID: $PBI_BROWSE_RID"
1957 2049
		echo "Available PBIs for Category: $PBI_BROWSE_CAT"
1958 2050
		grep -i -e "^App=" -i -e ";${PBI_BROWSE_CAT};" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
1959
	elif [ ! -z "$PBI_BROWSE_SEARCH" ] ; then
2051
	elif [ -n "$PBI_BROWSE_SEARCH" ] ; then
1960 2052
		echo "Using RepoID: $PBI_BROWSE_RID"
1961 2053
		echo "Searching for: $PBI_BROWSE_SEARCH"
1962 2054
		grep -i -e "^App=" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
......
1971 2063
		aName=`echo $line | cut -d ';' -f 1 2>/dev/null`
1972 2064

  
1973 2065
		# Make sure this is from the correct category
1974
		if [ ! -z "$PBI_BROWSE_CAT" ] ; then
2066
		if [ -n "$PBI_BROWSE_CAT" ] ; then
1975 2067
			_cCheck=`echo $catCheck | tr '[:lower:]' '[:upper:]'`
1976 2068
			_cCheck2=`echo $PBI_BROWSE_CAT | tr '[:lower:]' '[:upper:]'`
1977 2069
			if [ "$_cCheck" != "$_cCheck2" ]; then 
......
2015 2107

  
2016 2108
		# Check for a translation to the description
2017 2109
		get_meta_trans "App" "$cName" "${PBI_BROWSE_METAFILE}"
2018
		if [ ! -z "$MTRANS" ] ; then
2110
		if [ -n "$MTRANS" ] ; then
2019 2111
			aDesc="$MTRANS"
2020 2112
		fi
2021 2113

  
2022 2114
		# Search the description / keywords
2023
		if [ ! -z "$PBI_BROWSE_SEARCH" ] ; then
2115
		if [ -n "$PBI_BROWSE_SEARCH" ] ; then
2024 2116
			echo "$aName,$aDesc,$aKeywords,$MTRANS" | grep -i "$PBI_BROWSE_SEARCH" >/dev/null 2>/dev/null
2025 2117
			if [ "$?" != "0" ]; then continue ; fi
2026 2118
		fi
......
2032 2124
		echo "------------------------------------"
2033 2125
		echo "Application: $aName"
2034 2126
		echo "Version: $PBI_UPNVER"
2035
		if [ ! -z "$PBI_BROWSE_LISTALLPBI" ] ; then
2127
		if [ -n "$PBI_UPSIZE" ] ; then
2128
			echo "Size: $PBI_UPSIZE"
2129
		fi
2130
		if [ -n "$PBI_BROWSE_LISTALLPBI" ] ; then
2036 2131
			echo "Category: $catCheck"
2037 2132
		fi
2038 2133
		echo "Created: `echo $PBI_UPMDATE`"
......
2078 2173
		
2079 2174
		# Check for a translation to the description
2080 2175
		get_meta_trans "Cat" "$cName" "${PBI_BROWSE_METAFILE}"
2081
		if [ ! -z "$MTRANS" ] ; then
2176
		if [ -n "$MTRANS" ] ; then
2082 2177
			cDesc="$MTRANS"
2083 2178
		fi
2084 2179

  
......
2112 2207
	for l in $lCheck
2113 2208
	do
2114 2209
		catTrans=`grep "^${tag}\[$l\]=${name}" ${metaFile}`	
2115
		if [ ! -z "$catTrans" ] ; then
2210
		if [ -n "$catTrans" ] ; then
2116 2211
			MTRANS=`echo $catTrans | cut -d ";" -f 2`
2117 2212
			return
2118 2213
		fi
......
2128 2223
	if [ -z "$PBI_LISTREPO_ID" ] ; then
2129 2224
		list_all_pbi_repo
2130 2225
	else
2131
		if [ ! -z "${PBI_LISTREPO_UP}" ]; then
2226
		if [ -n "${PBI_LISTREPO_UP}" ]; then
2132 2227
			require_root
2133 2228
			move_repo_up "${PBI_LISTREPO_ID}" 
2134 2229
			list_all_pbi_repo
2135
		elif [ ! -z "${PBI_LISTREPO_DOWN}" ] ; then
2230
		elif [ -n "${PBI_LISTREPO_DOWN}" ] ; then
2136 2231
			require_root
2137 2232
			move_repo_down "${PBI_LISTREPO_ID}"
2138 2233
			list_all_pbi_repo
2139
		elif [ ! -z "${PBI_LISTREPO_MIRROR}" ] ; then
2234
		elif [ -n "${PBI_LISTREPO_MIRROR}" ] ; then
2140 2235
			require_root
2141 2236
			change_repo_mirror "${PBI_LISTREPO_ID}"
2142 2237
			listrepo_details "${PBI_LISTREPO_ID}"
......
2290 2385
        newDir="${PBI_DBAPPDIR}/${_pbilow}-${PBI_PATCHVERSION}-${PBI_APPARCH}"
2291 2386
	mv "$oldDir" "$newDir"
2292 2387
	rm ${newDir}/*.sha1 >/dev/null 2>/dev/null
2388

  
2389
	# Register the app
2293 2390
	pbi_add_register_app	
2294 2391

  
2392
        # Check if we need to run a post-install.sh script again
2393
	if [ -e "${newDir}/${MOD_POSTINS}" ] ; then
2394
          export_script_vars
2395
          sh "${newDir}/${MOD_POSTINS}"
2396
        fi
2397

  
2295 2398
	# Cleanup after our selves
2296 2399
	if [ -d "$PBI_EXTRACTDIR" ] ; then
2297 2400
		echo "Cleaning up..."
......
2464 2567
	if [ "$_pFbsdVer" != "$_sFbsdVer" ] ; then
2465 2568
     		exit_err "\"${_pbilow}\" patch is for FreeBSD ${_sFbsdVer}.X only!"
2466 2569
	fi
2570

  
2571
	# Check the mdate of the pbi
2572
	_pMDate="`cat ${oldDir}/pbi_mdate`"
2573
	_sMDate="$PBI_PATCHMDATE"
2574
	if [ "$_pMDate" != "$_sMDate" ] ; then
2575
     		exit_err "\"${_pbilow}\" patch is for the $PBI_PATCHMDATE build!"
2576
	fi
2467 2577
}
2468 2578

  
2469 2579
# Start the pbi_add process
......
2566 2676
	echo "-----------------------------------------------------"
2567 2677
	echo "Name: ${PBI_PROGNAME}"
2568 2678

  
2569
	if [ ! -z "$PBI_PATCHVERSION" ] ; then
2679
	if [ -n "$PBI_PATCHVERSION" ] ; then
2570 2680
		echo "PatchTarget: $PBI_PATCHTARGET"
2571 2681
	fi
2572 2682

  
2573
	if [ ! -z "$PBI_INSTALLED_BY" ] ; then
2683
	if [ -n "$PBI_INSTALLED_BY" ] ; then
2574 2684
		echo "InstalledBy: $PBI_INSTALLED_BY"
2575 2685
	fi
2576 2686

  
......
2598 2708
		*) echo "Signature: <Unknown>" ;;
2599 2709
	esac
2600 2710

  
2601
	if [ ! -z "${PBI_REPO}" ] ; then
2711
	if [ -n "${PBI_REPO}" ] ; then
2602 2712
		local _rDesc="`cat ${PBI_DBREPODIR}/*.${PBI_REPO} | grep "Desc:" | sed 's|Desc: ||g'`"
2603 2713
		local _rID="`ls ${PBI_DBREPODIR}/*.${PBI_REPO}`"
2604 2714
		_rID=`basename $_rID | cut -d '.' -f 1`
......
2689 2799
	
2690 2800
	# Extract the header files 
2691 2801
	tar xvf "${PBI_FILENAME}" -C "${PBI_HEADER_TMPDIR}" >/dev/null 2>/dev/null
2692
	if [ "$?" != "0" ] ; then exit_err "Failed to read PBI header!" ; fi
2802
	if [ "$?" != "0" ] ; then exit_err "Failed to read PBI header! Possible corrupt PBI, or wrong PBI version for this OS." ; fi
2693 2803

  
2694 2804
}
2695 2805

  
......
2746 2856
	PBI_ENABLEAUTOUPDATE=""
2747 2857
        PBI_FBSDVER=""
2748 2858
	PBI_ORIGPROGDIRPATH=""
2859
	PBI_PATCHMDATE=""
2749 2860
	PBI_PATCHVERSION=""
2750 2861
	PBI_PATCHTARGET=""
2751 2862
	PBI_PROGNAME=""
......
2790 2901
        	PBI_REPO=`cat ${1}/pbi_repo`
2791 2902
	fi
2792 2903

  
2904
	# See if this patch is for a particular mdate
2905
	if [ -e "${1}/pbi_patchmdate" ] ; then
2906
        	PBI_PATCHMDATE=`cat ${1}/pbi_patchmdate`
2907
	fi
2908

  
2793 2909
	# See if this PBI was signed
2794 2910
	if [ -e "${1}/pbi_archivesum.sha1" ] ; then
2795 2911
		check_valid_sigs "${1}"
......
2813 2929
	mk_pbi_extract_dir
2814 2930
	pbi_extract_archive
2815 2931
	
2932
	pbi_add_check_gids
2933
	pbi_add_check_uids
2934

  
2816 2935
	pbi_add_run_script
2817 2936
	check_postinstall_script
2818 2937

  
......
2824 2943
	clean_remote_dl
2825 2944
}
2826 2945

  
2946
# Check for any GIDs we need to create
2947
pbi_add_check_gids() {
2948
	if [ ! -e "${PBI_PROGDIRPATH}/${PBI_INS_GROUPSFILE}" ] ; then return ; fi
2949
	runUID=`id -u`
2950

  
2951
	while read gidLine
2952
	do
2953
		gName=`echo $gidLine | cut -d ':' -f 1`
2954
		gID=`echo $gidLine | cut -d ':' -f 3`
2955
		gUsers=`echo $gidLine | cut -d ':' -f 4`
2956

  
2957
		# Is this group already on the system?
2958
		pw groupshow $gName >/dev/null 2>/dev/null
2959
		if [ $? -eq 0 ] ; then 
2960
			echo "Using existing group: $gName"
2961
		else
2962
			# Are we installing as root?
2963
			if [ "$runUID" != "0" ] ; then
2964
				echo "Please create group \"$gName\" manually or re-install PBI as root."
2965
			else
2966
				echo "Adding group: $gName"
2967
				pw groupadd $gName -g $gID;
2968
			fi
2969
		fi
2970

  
2971
		if [ -n "$gUsers" ] ; then
2972
			for gUser in `echo $gUsers | sed 's|,| |g'`
2973
			do
2974
				pw groupshow ${gName} | grep -qw ${gUser}
2975
				if [ $? -ne 0 ] ; then
2976
					# Are we installing as root?
2977
					if [ "$runUID" != "0" ] ; then
2978
						echo "Please add user \"$gUser\" to group \"$gName\" manually or re-install PBI as root."
2979
						continue
2980
					fi
2981

  
2982
					echo "Adding user ${gUser} to group ${gName}"
2983
					pw groupmod ${gName} -m ${gUser}
2984
				fi
2985
			done
2986
		fi
2987
	done < ${PBI_PROGDIRPATH}/${PBI_INS_GROUPSFILE}
2988
}
2989

  
2990
# Check for any UIDs we need to create
2991
pbi_add_check_uids() {
2992
	if [ ! -e "${PBI_PROGDIRPATH}/${PBI_INS_USERSFILE}" ] ; then return ; fi
2993
	runUID=`id -u`
2994

  
2995
	while read uidLine
2996
	do
2997
		uName=`echo $uidLine | cut -d ':' -f 1`
2998

  
2999
		# Is this user already on the system?
3000
		pw usershow $uName >/dev/null 2>/dev/null
3001
		if [ $? -eq 0 ] ; then echo "Using existing user: $uName"; continue ; fi
3002

  
3003
		# Are we installing as root?
3004
		if [ "$runUID" != "0" ] ; then
3005
			echo "Please create user \"$uName\" manually or re-install PBI as root."
3006
			continue
3007
		fi
3008

  
3009
		uID=`echo $uidLine | cut -d ':' -f 3`
3010
		gID=`echo $uidLine | cut -d ':' -f 4`
3011
		uClass=`echo $uidLine | cut -d ':' -f 5`
3012
		uGecos=`echo $uidLine | cut -d ':' -f 8`
3013
		uHomedir=`echo $uidLine | cut -d ':' -f 9 | sed "s|^/usr/local|${PBI_PROGDIRPATH}|"`
3014
		uShell=`echo $uidLine | cut -d ':' -f 10`
3015

  
3016
		echo "Adding user: $uName"
3017
		pw useradd $uName -u $uID -g $gID $uClass -c "$uGecos" -d $uHomedir -s $uShell;
3018

  
3019
		# Create homedir
3020
		case $uHomedir in 
3021
			/nonexistent|/var/empty) ;; 
3022
			*) install -d -g $gID -o $uID $uHomedir ;;
3023
		esac 
3024
	done < ${PBI_PROGDIRPATH}/${PBI_INS_USERSFILE}
3025
}
3026

  
2827 3027
add_hashdir_trigger() {
2828 3028
	get_dbdir
2829 3029
        _htrig=`echo ${APPDBDIR} | sed "s|${PBI_DBAPPDIR}|${PBI_DBHASHQUEUEDIR}|g"`
2830
	touch "${_htrig}"
3030
	if [ ! -e "${_htrig}" ] ; then
3031
		touch "${_htrig}"
3032
	fi
2831 3033
}
2832 3034

  
2833 3035
# Run the install script if exists
......
2865 3067
		file="`echo $hl | sed 's/:::.*$//g'`"
2866 3068

  
2867 3069
		# If we are trying to merge a PBI which was deleted, stop
2868
		if [ ! -z "${2}" -a -e "${2}" ] ; then
3070
		if [ -n "${2}" -a -e "${2}" ] ; then
2869 3071
			echo "HASHDONE - Deleted" 
2870 3072
			return
2871 3073
		fi
......
2959 3161
        open_header_tmp
2960 3162
	get_dbdir
2961 3163
	dir="${APPDBDIR}"
3164

  
3165
	# Make sure we remove any existing meta-data if forcing an installation
3166
	if [ "$PBI_FORCEADD" = "YES" ] ; then
3167
	  	tmp="`echo ${PBI_PROGNAME} | tr -d ' ' | tr '[A-Z]' '[a-z]'`"
3168
          	rm -rf ${PBI_DBAPPDIR}/${tmp}-*-${PBI_APPARCH}
3169
	fi
3170

  
2962 3171
	mkdir -p "${dir}"
2963 3172
	
2964 3173
        tar cvf - -C "${PBI_HEADER_TMPDIR}" . 2>/dev/null | tar xvf - -C "$dir" 2>/dev/null
2965 3174

  
2966 3175
	# If this was a patch, use the original path
2967
	if [ ! -z "${PBI_ORIGPROGDIRPATH}" ] ; then
3176
	if [ -n "${PBI_ORIGPROGDIRPATH}" ] ; then
2968 3177
		echo "${PBI_ORIGPROGDIRPATH}" >${dir}/pbi_installedpath
2969 3178
	else
2970 3179
		echo "${PBI_PROGDIRPATH}" >${dir}/pbi_installedpath
......
2972 3181

  
2973 3182
	# See which repo / key this PBI associates to, if any
2974 3183
	check_valid_sigs "${dir}"
2975
	if [ ! -z "$PBI_VALIDKEYSIG" ] ; then
3184
	if [ -n "$PBI_VALIDKEYSIG" ] ; then
2976 3185
		_rMd5="`echo ${PBI_VALIDKEYSIG} | cut -d '.' -f 1`"
2977 3186
		echo "$_rMd5" | sed "s|${PBI_DBKEYDIR}/||g" > ${dir}/pbi_repo
2978 3187
	fi
......
3099 3308
	tar="xvf -"
3100 3309

  
3101 3310
	if [ "$PBI_VERBOSE" = "YES" ] ; then
3311
		echo "TOTALFILES: ${PBI_ARCHIVE_COUNT}"
3102 3312
		tail +$PBI_SKIP_ARCHLINES "${PBI_FILENAME}" | tar ${tar} -C "${PBI_EXTRACTDIR}"
3103 3313
		err="$?"
3104 3314
	else
......
3129 3339
		exit_trap
3130 3340
	fi
3131 3341

  
3342
	PBI_CREATEONLY="YES"
3343

  
3132 3344
	load_pbi_conffile
3133 3345

  
3134 3346
	parse_cmdline_overrides
......
3215 3427
# Start looping through and creating a hash-list of files
3216 3428
mk_hash_list() {
3217 3429
  	if [ "${PBI_CREATE_HASHLIST}" = "NO" ] ; then return 0 ; fi
3430
	echo "Creating hash list..."
3218 3431

  
3219 3432
	hashfile="${PBI_STAGEDIR}/${PBI_HASHLIST}"
3220 3433

  
......
3246 3459

  
3247 3460
		# Check if this hash file is excluded
3248 3461
		_hfound="0"
3249
		if [ ! -z "${PBI_HASH_EXCLUDES}" ] ; then
3462
		if [ -n "${PBI_HASH_EXCLUDES}" ] ; then
3250 3463
			for _hexcl in ${PBI_HASH_EXCLUDES}
3251 3464
			do
3252 3465
				if [ "$_hexcl" = "$line" ] ; then
......
3270 3483
		fi
3271 3484
	done < ${tmp_hashdir}
3272 3485
	rm ${tmp_hashdir}
3273
	cd ~
3486
	cd /
3274 3487
}
3275 3488

  
3276 3489
# Parse any external link directives
3277 3490
mk_extlink_entries() {
3491
	echo "Creating external link entries..."
3278 3492
	init_tmpdir
3279 3493
	_extf="${PBI_CONFDIR}/${MOD_EXTLINKFILE}"
3280 3494
	_autoextf="${PBI_STAGEDIR}/${MOD_AUTOEXTLINKFILE}"
......
3302 3516
		_wraponly="NO"
3303 3517
		_crashhandle="YES"
3304 3518
		_keep="YES"
3519
		_linux="NO"
3305 3520
                echo $line | tr '\t' ' ' | tr -s ' ' | grep "^#" >/dev/null 2>/dev/null
3306 3521
                if [ "$?" != "0" ] ; then
3307 3522
                        src="`echo $line | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 1`"
......
3324 3539
				       nocrash) _crashhandle="NO" ;;
3325 3540
				          keep) _keep="YES" ;;
3326 3541
				       replace) _keep="NO" ;;
3542
				         linux) _bin="YES" ; _linux="YES" ;;
3327 3543
					*) echo "Warning: Unknown option \"$i\" in ${MOD_EXTLINKFILE}";;
3328 3544
				esac
3329 3545
				
......
3343 3559
				if [ "$?" = "0" ] ; then continue ; fi
3344 3560
				
3345 3561
				# Make the binary wrapper
3346
				mk_path_wrappers "$src" "$tar" "$_crashhandle" "$_wraponly"
3562
				mk_path_wrappers "$src" "$tar" "$_crashhandle" "$_wraponly" "$_linux"
3347 3563

  
3348 3564
				# This binary is done, save it now so we don't duplicate later
3349 3565
				_donewrap="$_donewrap #${src}#"
......
3386 3602
	tar="${2}"
3387 3603
	ch="${3}"
3388 3604
	onlywrap="${4}"
3605
	linwrap="${5}"
3389 3606

  
3390 3607
	# Check if the fake-bin wrapper already exists, and if so use
3391 3608
	# a different name
......
3393 3610
		fbin=`echo $bin | sed 's|/|-|g'`
3394 3611
	fi
3395 3612

  
3396
	# Save the wrapper location so we know what files to modify at install time
3397
	MOD_WRAPPERS="${PBI_FAKEBIN_DIR}/${fbin} ${MOD_WRAPPERS}"
3398

  
3399 3613
	# Make our link to the system localbase if its not a wrapper only
3400 3614
 	if [ "$onlywrap" != "YES" ] ; then	
3401 3615
		echo "ln -fs $PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${fbin} \$SYS_LOCALBASE/${tar}" \
3402 3616
			>> "${dir}/${PBI_INS_PATHSCRIPT}"
3403 3617
	fi
3404 3618

  
3405
	# Start making the wrapper script
3406
	echo "#!/bin/sh" > ${dir}/${fbin}
3407
	echo "PROGDIR=\"${PBI_PROGDIRPATH}\" ; export PROGDIR" >>${dir}/${fbin}
3408
	echo "PROGBIN=\"${bin}\" ; export PROGBIN" >>${dir}/${fbin}
3409

  
3410
	# Start the main code block
3411
	echo 'PATH="${PROGDIR}/bin:${PROGDIR}/sbin:${PROGDIR}/kde4/bin:${PROGDIR}/libexec:$PATH"; export PATH
3619
	# Copy the wrapper binary
3620
	cp ${PBI_WRAPPERFILE} ${dir}/${fbin}
3621
	chmod 755 ${dir}/${fbin}
3622

  
3623
	# Create the wrapper .pbiopt
3624
	echo "PROGDIR: ${PBI_PROGDIRPATH}" >${dir}/${fbin}.pbiopt
3625
	echo "TARGET: ${bin}" >>${dir}/${fbin}.pbiopt
3626

  
3627
	# Figure out the extra ldconfig dirs
3628
	LDCONFIGDIRS=""
3629
	if [ -d "${PBI_STAGEDIR}/libdata/ldconfig" ] ; then
3630
	  for _ldc in `ls ${PBI_STAGEDIR}/libdata/ldconfig 2>/dev/null`
3631
 	  do
3632
   	     while read TMP
3633
  	     do
3634
      	       echo $LDCONFIGDIRS | grep "${TMP}:" >/dev/null 2>/dev/null
3635
      	       if [ "$?" != "0" ]; then
3636
        	 LDCONFIGDIRS="${TMP}:${LDCONFIGDIRS}"
3637
     	       fi
3638
    	     done < ${PBI_STAGEDIR}/libdata/ldconfig/${_ldc}
3639
          done
3640
        fi
3412 3641

  
3413
# Check and parse any ldconfig entries
3414
LDCONFIGDIRS=""
3415
if [ -d "${PROGDIR}/libdata/ldconfig" ]
3416
then
3417
  for i in `ls ${PROGDIR}/libdata/ldconfig 2>/dev/null`
3418
  do
3419
    while read TMP
3420
    do
3421
      echo $LDCONFIGDIRS | grep "${TMP}:" >/dev/null 2>/dev/null
3422
      if [ "$?" != "0" ]
3423
      then
3424
        LDCONFIGDIRS="${TMP}:${LDCONFIGDIRS}"
3425
      fi
3426
    done < ${PROGDIR}/libdata/ldconfig/${i}
3427
  done
3428
fi
3429

  
3430
#Setup our LD_LIBRARY_PATH variable with all found lib dirs
3431
LD_LIBRARY_PATH="${LDCONFIGDIRS}:${PROGDIR}/lib/:${PROGDIR}/kde4/lib:${PROGDIR}/lib/qt4"
3432
LD_32_LIBRARY_PATH="${LDCONFIGDIRS}:${PROGDIR}/lib/:${PROGDIR}/kde4/lib:${PROGDIR}/lib/qt4"
3433
export LD_LIBRARY_PATH LD_32_LIBRARY_PATH
3434

  
3435
'>>${dir}/${fbin}
3436

  
3437
	# See if we need the crash-handler
3438
	if [ "$ch" = "YES" ] ; then
3439
		echo 'if [ ! -d "${HOME}/.pbi-logs" ] ; then mkdir ${HOME}/.pbi-logs ; fi
3440
STDLOG="${HOME}/.pbi-logs/$$stdout"
3441
STELOG="${HOME}/.pbi-logs/$$stderr"
3442
(((( ${PROGDIR}/${PROGBIN}  "$@" || pbi-crashhandler "${PROGBIN}" "${STDLOG}" "${STELOG}" )  \
3443
| tee $STDLOG) 3>&1 1>&2 2>&3 | tee $STELOG) 3>&1 1>&2 2>&3)
3444

  
3445
rm $STDLOG >/dev/null 2>/dev/null
3446
rm $STELOG >/dev/null 2>/dev/null' >>${dir}/${fbin}
3642
	# If this is marked as a linux app, make sure we point to the linux libs first
3643
	if [ "$linwrap" = "YES" ] ; then
3644
	  LDCONFIGDIRS="${PROGDIR}/linuxlib"
3645
	fi
3447 3646

  
3448
	else
3449
		echo '${PROGDIR}/${PROGBIN}  "$@"' >>${dir}/${fbin}
3450
	fi		
3647
	# Create the wrapper .ldhints
3648
	echo "${LDCONFIGDIRS}" >${dir}/${fbin}.ldhints
3451 3649
}
3452 3650

  
3453 3651
# Create any XDG script for install / deinstall
3454 3652
mk_xdg_scripts() {
3653
 	echo "Creating xdg scripts..."
3455 3654
  	mk_xdg_desktop_script
3456 3655
  	mk_xdg_menu_script
3457 3656
  	mk_xdg_mime_script
......
3600 3799

  
3601 3800
# Create the install script for the PBI
3602 3801
mk_install_script() {
3802
	echo "Creating install script..."
3603 3803
	if [ ! -d "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}" ] ; then mkdir -p "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}" ; fi
3604 3804
	insc="${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/.pbi-install.sh"
3605 3805
	echo "#!/bin/sh" > "$insc"
......
3619 3819
		echo '	ln -fs "${SYS_LOCALBASE}/lib/X11/fonts" "${PBI_PROGDIRPATH}/lib/X11/fonts"' >> "$insc"
3620 3820
		echo '	rm "${PBI_PROGDIRPATH}/lib/X11/icons" >/dev/null 2>/dev/null' >> "$insc"
3621 3821
		echo '	ln -fs "${SYS_LOCALBASE}/lib/X11/icons" "${PBI_PROGDIRPATH}/lib/X11/icons"' >> "$insc"
3822
		echo '	rm "${PBI_PROGDIRPATH}/share/icons" >/dev/null 2>/dev/null' >> "$insc"
3823
		echo '	ln -fs "${SYS_LOCALBASE}/share/icons" "${PBI_PROGDIRPATH}/share/icons"' >> "$insc"
3622 3824
		echo 'fi' >> "$insc"
3623 3825
	fi
3624 3826

  
3625
 	# Set permissions to executable on wrappers	
3626
	echo "MOD_WRAPPERS=\"$MOD_WRAPPERS\"" >> "$insc"
3627
	echo 'cd $PBI_PROGDIRPATH' >> "$insc"
3628
	echo "for i in \$MOD_WRAPPERS" >> "$insc"
3629
	echo "do" >> "$insc"
3630
	echo "  chmod 755 \$i" >> "$insc"
3631
	echo "done" >> "$insc"
3632

  
3633 3827
	# Add the binary wrapper sym-links
3634 3828
        if [ -e "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT}" ] ; then
3635 3829
		echo 'if [ `id -u` = "0" ] ; then ' >>${insc}
......
3651 3845

  
3652 3846
# Create the deinstall script for the PBI
3653 3847
mk_deinstall_script() {
3848
	echo "Creating deinstall script..."
3654 3849
	uisc="${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/.pbi-uninstall.sh"
3655 3850

  
3656 3851
	echo "#!/bin/sh" > "$uisc"
......
3659 3854

  
3660 3855
	# Remove the binary wrapper sym-links
3661 3856
        if [ -e "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT}" ] ; then
3662
		echo 'if [ `id -u` = "0" ] ; then ' >>${uins}
3857
		echo 'if [ `id -u` = "0" ] ; then ' >>${uisc}
3663 3858
		echo "	$PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT}" >>${uisc}
3664
		echo "fi" >>${uins}
3859
		echo "fi" >>${uisc}
3665 3860
	fi
3666 3861

  
3667 3862
	# Look for any XDG scripts
......
3689 3884

  
3690 3885
# Create a dir for staging the final archive
3691 3886
mk_stage_dir() {
3887
	local _excOpts=""
3888

  
3692 3889
	PBI_STAGEDIR="${PBI_PROGDIRPATH}/.stagedir"
3693 3890
	echo "Creating Stage Dir: ${PBI_STAGEDIR}"
3694
	if [ -e "${PBI_STAGEDIR}" ] ; then rm -rf "${PBI_STAGEDIR}" ; fi
3891
	if [ -e "${PBI_STAGEDIR}" ] ; then 
3892
		rm -rf "${PBI_STAGEDIR}" 2>/dev/null
3893
		chflags -R noschg ${PBI_STAGEDIR} 2>/dev/null
3894
		rm -rf "${PBI_STAGEDIR}" 2>/dev/null
3895
	fi
3695 3896
	mkdir -p ${PBI_STAGEDIR}
3696 3897

  
3697 3898
	# Build module list of excludes
3698
	if [ ! -z "$PBI_EXCLUDELIST" ] ; then
3899
	if [ -n "$PBI_EXCLUDELIST" ] ; then
3699 3900
		for excl in $PBI_EXCLUDELIST
3700 3901
		do
3701 3902
			if [ -z "$_excOpts" ] ; then
......
3712 3913
		--exclude make.conf.bak --exclude .keepports \
3713 3914
		-C "${PBI_PROGDIRPATH}" . 2>/dev/null \
3714 3915
		| tar xvpf - -C ${PBI_STAGEDIR} 2>/dev/null
3916

  
3715 3917
}
3716 3918

  
3717 3919
# Remove the stagedir
3718 3920
rm_stage_dir() {
3719
	cd ~
3921
	cd /
3720 3922
	PBI_STAGEDIR="${PBI_PROGDIRPATH}/.stagedir"
3721
	if [ -e "${PBI_STAGEDIR}" ] ; then rm -rf "${PBI_STAGEDIR}" ; fi
3923
	if [ -e "${PBI_STAGEDIR}" ] ; then 
3924
		rm -rf "${PBI_STAGEDIR}" 2>/dev/null
3925
		chflags -R noschg ${PBI_STAGEDIR} 2>/dev/null
3926
		rm -rf "${PBI_STAGEDIR}" 2>/dev/null
3927
	fi
3722 3928
}
3723 3929

  
3724 3930
# See if we need to clean the stagedir
......
3731 3937
	if [ "${PBI_USESYSFONTS}" != "NO" ] ; then
3732 3938
		rm -rf ${PBI_STAGEDIR}/etc/fonts >/dev/null 2>/dev/null
3733 3939
		rm -rf ${PBI_STAGEDIR}/lib/X11/fonts >/dev/null 2>/dev/null
3940
		rm -rf ${PBI_STAGEDIR}/lib/X11/icons >/dev/null 2>/dev/null
3941
		rm -rf ${PBI_STAGEDIR}/share/icons >/dev/null 2>/dev/null
3734 3942
	fi
3735 3943
}
3736 3944

  
......
3769 3977

  
3770 3978
# Start copying pbi details into header file
3771 3979
save_pbi_details_to_header() {
3772
	echo "${PBI_PROGDIRPATH}" > "${PBI_HEADERDIR}/pbi_defaultpath"
3980
	local _osArch="`uname -m`"
3981
	if [ -n "${PBI_OSARCH}" ] ; then
3982
		_osArch="${PBI_OSARCH}"
3983
	fi
3984

  
3985
	local _osRel="`uname -r`"
3986
	if [ -n "${PBI_OSREL}" ] ; then
3987
		_osRel="${PBI_OSREL}"
3988
	fi
3989

  
3990
	if [ "${PBI_CREATEONLY}" = "YES" ] ; then
3991
		_pbilow="`echo ${PBI_PROGNAME} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
3992
		echo "${PBI_APPDIR}/${_pbilow}-${_osArch}" > "${PBI_HEADERDIR}/pbi_defaultpath"
3993
	else	
3994
		echo "${PBI_PROGDIRPATH}" > "${PBI_HEADERDIR}/pbi_defaultpath"
3995
	fi
3773 3996
	echo "${PBI_PROGNAME}" > "${PBI_HEADERDIR}/pbi_name"
3774 3997
	echo "${PBI_PROGVERSION}" > "${PBI_HEADERDIR}/pbi_version"
3775 3998
	echo "${PBI_PROGAUTHOR}" > "${PBI_HEADERDIR}/pbi_author"
......
3806 4029
	fi
3807 4030

  
3808 4031
	# Copy over our icon
3809
	if [ ! -z "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
4032
	if [ -n "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
3810 4033
		# Get the file extension
3811 4034
		_iconExt=`echo "$PBI_PROGICON" | awk -F . '{print $NF}'`
3812
		cp "${PBI_STAGEDIR}/${PBI_PROGICON}" "${PBI_HEADERDIR}/pbi_icon.${_iconExt}"
4035
		cp "${PBI_STAGEDIR}/${PBI_PROGICON}" "${PBI_HEADERDIR}/pbi_icon.${_iconExt}" >/dev/null 2>/dev/null
3813 4036
	else
3814
		_iconExt=`echo "$PBI_DEFAULT_ICON" | awk -F . '{print $NF}'`
3815
		cp "${PBI_DEFAULT_ICON}" "${PBI_HEADERDIR}/pbi_icon.${_iconExt}"
4037
		_iconExt=`echo "$PBI_DEFAULT_ICON_CHROOT" | awk -F . '{print $NF}'`
4038
		cp "${PBI_DEFAULT_ICON_CHROOT}" "${PBI_HEADERDIR}/pbi_icon.${_iconExt}" >/dev/null 2>/dev/null
3816 4039
	fi
3817 4040

  
3818 4041
	# Check for any gui images
......
3824 4047
	fi
3825 4048

  
3826 4049
	# Save the uname details
3827
	echo "`uname -m`" > "${PBI_HEADERDIR}/pbi_arch"
3828
	echo "`uname -r`" > "${PBI_HEADERDIR}/pbi_fbsdver"
4050
	echo "${_osArch}" > "${PBI_HEADERDIR}/pbi_arch"
4051
	echo "${_osRel}" > "${PBI_HEADERDIR}/pbi_fbsdver"
3829 4052
	echo "${PROGVERSION}" > "${PBI_HEADERDIR}/pbi_createver"
3830 4053

  
3831 4054
	# Get the total number of files in the STAGEDIR
......
3854 4077

  
3855 4078
# All the pieces are ready, spit out the final PBI file
3856 4079
mk_output_pbi() {
3857
        if [ ! -z "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
4080
	if [ -z "${PBI_OSARCH}" ] ; then
4081
		PBI_OSARCH="`uname -m`"
4082
	fi
4083

  
4084
        if [ -n "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
3858 4085
                icon="${PBI_STAGEDIR}/${PBI_PROGICON}"
3859 4086
        else
3860
                icon="${PBI_DEFAULT_ICON}"
4087
                icon="${PBI_DEFAULT_ICON_CHROOT}"
3861 4088
        fi
3862 4089
	_pbilow="`echo ${PBI_PROGNAME} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
3863 4090

  
3864
	outfile="${PBI_CREATE_OUTDIR}/${_pbilow}-${PBI_PROGVERSION}-`uname -m`.pbi"
4091
	outfile="${PBI_CREATE_OUTDIR}/${_pbilow}-${PBI_PROGVERSION}-${PBI_OSARCH}.pbi"
3865 4092
	mark1="${PBI_CREATE_OUTDIR}/.pbimark1.$$"
3866 4093
	mark2="${PBI_CREATE_OUTDIR}/.pbimark2.$$"
3867 4094

  
......
3993 4220
run_remove_script() {
3994 4221
	uisc="${PBI_PROGDIRPATH}/${PBI_FAKEBIN_DIR}/.pbi-uninstall.sh"
3995 4222
	if [ ! -e "$uisc" ] ; then return 0 ; fi
3996
	
4223

  
4224
	# If not running as root, be sure to cleanup path links
4225
	if [ "`id -u`" != "0" ]; then
4226
	 	cat ${PBI_PROGDIRPATH}/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT} | grep 'rm "$SYS_LOCALBASE/bin' | sed 's|$SYS_LOCALBASE|${HOME}|g' >${PBI_TMPDIR}/.binlnks
4227
         	while read lnk
4228
          	do
4229
               	 	/bin/sh -c "${lnk}"
4230
          	done <${PBI_TMPDIR}/.binlnks
4231
          	rm ${PBI_TMPDIR}/.binlnks
4232
        fi
3997 4233
        export_script_vars
3998 4234
	if [ "$PBI_VERBOSE" = "YES" ] ; then
3999 4235
       		sh "${uisc}"
......
4002 4238
	fi
4003 4239
}
4004 4240

  
4241
# Function to check the supplied $1 dir for any mounts before we
4242
# do a rm -rf
4243
umount_before_rm()
4244
{
4245
   	if [ -z "${1}" ] ; then return 0 ; fi
4246

  
4247
        local _ddir="$1"
4248
        echo "$_ddir" | rev | grep -q '^/'	
4249
	if [ $? -ne 0 ] ; then
4250
	   _ddir="${_ddir}/"
4251
	fi
4252
	
4253
	mount | grep -q "on ${_ddir}"
4254
	if [ $? -ne 0 ] ; then return 0; fi
4255

  
4256
        for i in `mount | grep "on ${_ddir}" | awk '{print $3}'`
4257
	do
4258
	   umount -f ${i} >/dev/null 2>/dev/null
4259
	   if [ $? -ne 0 ] ; then 
4260
		exit_err "Could not umount ${i} before rm -rf, bailing!"
4261
	   fi
4262
	done
4263
	return 0
4264
}
4265

  
4005 4266
# Remove the pbi directory
4006 4267
remove_pbidir() {
4007 4268
	if [ -z "${PBI_PROGDIRPATH}" ] ; then return 0 ; fi
......
4010 4271
	if [ "$PBI_VERBOSE" = "YES" ] ; then
4011 4272
		echo "Removing: ${PBI_PROGDIRPATH}"
4012 4273
	fi
4274

  
4275
        # Make sure we are unmounted
4276
        umount_before_rm "${PBI_PROGDIRPATH}"
4277
	
4013 4278
	rm -rf "${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
4014 4279

  
4015 4280
	# Do we have leftovers?
......
4054 4319
	# Running as user add to ~/bin
4055 4320
	init_tmpdir
4056 4321
	if [ ! -d "${HOME}/bin" ] ; then mkdir -p "${HOME}/bin"; fi
4057
	cat ${1}/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT} | grep "${1}/${PBI_FAKEBIN_DIR}" | sed 's|$SYS_LOCALBASE|${HOME}|g' >${PBI_TMPDIR}/.binlnks
4322
	cat ${1}/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT} | grep "${1}/${PBI_FAKEBIN_DIR}" | grep '$SYS_LOCALBASE/bin' | sed 's|$SYS_LOCALBASE|${HOME}|g' >${PBI_TMPDIR}/.binlnks
4058 4323
	while read lnk
4059 4324
	do
4060 4325
		/bin/sh -c "${lnk}"
......
4163 4428
# Start the PBID daemon
4164 4429
do_pbid() {
4165 4430

  
4166
	_pbid_log="/var/log/pbid.log"
4431
	# Allow user supplied logfile
4432
        if [ -z "${PBID_LOGFILE}" ] ; then
4433
	  _pbid_log="/var/log/pbid.log"
4434
	else
4435
          _pbid_log="${PBID_LOGFILE}"
4436
        fi
4167 4437

  
4168 4438
	# Set verbosity 
4169 4439
	_redir="&1"
......
4196 4466
		check_autoupdate_pbis "$_pbid_log" "$_redir"
4197 4467

  
4198 4468
		# Check if we need to merge files into the hashdir
4199
		if [ ! -z "`ls ${PBI_DBHASHQUEUEDIR}`" ] ; then
4469
		if [ -n "`ls ${PBI_DBHASHQUEUEDIR}`" ] ; then
4200 4470
			init_tmpdir
4201 4471
			for _hpbi in `ls ${PBI_DBHASHQUEUEDIR}`
4202 4472
			do
......
4455 4725
# Begins the port make
4456 4726
start_pbi_makeport()
4457 4727
{
4458
	cd /usr/ports/${PBI_MAKEPORT}
4459
	make clean
4460
	make
4461
	make install
4462
	if [ "$?" != "0" ] ; then
4463
		if [ "$MKDEBUG" = "YES" ] ; then
4464
			echo "Failed! Running /bin/sh for debugging, type 'exit' to finish."
4465
			/bin/sh
4466
		fi
4467
		make clean
4468
		exit_err "make install of ${PBI_MAKEPORT} failed!"
4469
	fi
4470
	make clean
4728
	do_port_build "/usr/ports/${PBI_MAKEPORT}"
4471 4729
}
4472 4730

  
4473 4731
# Prune any ports which aren't required for runtime
......
4533 4791
		if [ ! -d "/usr/ports/${port}" ] ; then
4534 4792
			exit_err "/usr/ports/${port} does not exist!"
4535 4793
		fi
4536
  		cd /usr/ports/${port}
4537
		make clean
4538
		make
4539
		make install
4540
		if [ "$?" != "0" ] ; then
4541
			if [ "$MKDEBUG" = "YES" ] ; then
4542
				echo "Failed! Running /bin/sh for debugging, type 'exit' to finish."
4543
				/bin/sh
4544
			fi
4545
			make clean
4546
			exit_err "make install of ${port} failed!"
4547
		fi
4548
		make clean
4794
		do_port_build "/usr/ports/${port}"
4549 4795
	done
4550 4796

  
4551 4797
}
......
4560 4806
		if [ ! -d "/usr/ports/${port}" ] ; then
4561 4807
			exit_err "/usr/ports/${port} does not exist!"
4562 4808
		fi
4563
  		cd /usr/ports/${port}
4564
		make clean
4565
		make
4566
		make install
4567
		if [ "$?" != "0" ] ; then
4568
			if [ "$MKDEBUG" = "YES" ] ; then
4569
				echo "Failed! Running /bin/sh for debugging, type 'exit' to finish."
4570
				/bin/sh
4571
			fi
4572
			make clean
4573
			exit_err "make install of ${port} failed!"
4574
		fi
4575
		make clean
4809
		do_port_build "/usr/ports/${port}"
4576 4810
	done
4577 4811

  
4578 4812
}
......
4590 4824
	check_enable_disable_auto
4591 4825

  
4592 4826
	# Stop here if we are just enabling / disabling auto-update
4593
	if [ ! -z "$PBI_UPENABLEAUTO" ] ; then return 0 ; fi
4827
	if [ -n "$PBI_UPENABLEAUTO" ] ; then return 0 ; fi
4594 4828

  
4595 4829
	start_update_checks
4596 4830
	if [ "$?" != "0" ] ; then rm_tmpdir ; exit 1 ; fi
4597 4831

  
4598 4832
	# Stop here if only doing update checks
4599
	if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
4833
	if [ -n "${PBI_UPCHECK}" ]; then return 0 ; fi
4600 4834

  
4601 4835
  	require_root_or_group
4602 4836

  
......
4623 4857

  
4624 4858
        # See which repo / key this PBI associates to, if any
4625 4859
	check_valid_sigs "${1}"
4626
	if [ "$?" = "0" -a ! -z "$PBI_VALIDKEYSIG" ] ; then
4860
	if [ "$?" = "0" -a -n "$PBI_VALIDKEYSIG" ] ; then
4627 4861
		_rMd5="`echo ${PBI_VALIDKEYSIG} | cut -d '.' -f 1`"
4628 4862
		echo "$_rMd5" | sed "s|${PBI_DBKEYDIR}/||g" > ${1}/pbi_repo
4629 4863
	fi
......
4788 5022
		# Now fetch the file
4789 5023
		sFile="${PBI_DBICONDIR}/${_repoMd5}-${iName}.${ext}"
4790 5024
		fetch -o "${sFile}" "${aIcon}" >/dev/null 2>/dev/null
5025
		if [ $? -ne 0 ]; then
5026
		  # Wait a moment before trying the next
5027
		  sleep 40 
5028
		fi
4791 5029
		
4792
		# Wait a sec
4793
		sleep 1
4794

  
4795 5030
	done < ${_repoMeta}
4796 5031
}
4797 5032

  
......
4819 5054
	PBI_UPCSUM=""
4820 5055
	PBI_UPMDATE=""
4821 5056
	PBI_UPREPO=""
5057
	PBI_UPSIZE=""
4822 5058

  
4823 5059
	# If we are looking for the current app, set _uver accordingly
4824 5060
	if [ "$_uver" = "current" ] ; then
......
4849 5085
		PBI_UPPATCHES="`echo $_upLine | cut -d ':' -f 8`"
4850 5086
		PBI_UPCSUM="`echo $_upLine | cut -d ':' -f 4`"
4851 5087
		PBI_UPMDATE="`echo $_upLine | cut -d ':' -f 5`"
5088
		PBI_UPSIZE="`echo $_upLine | cut -d ':' -f 8`"
4852 5089
		PBI_UPMIRROR="`cat ${PBI_DBMIRRORDIR}/${_rMd5} 2>/dev/null`"
4853 5090
		PBI_UPREPO="${_rMd5}"
4854 5091

  
4855
		if [ ! -z "${PBI_UPNVER}" ] ; then break; fi
5092
		if [ -n "${PBI_UPNVER}" ] ; then break; fi
4856 5093
		if [ "${_urepo}" != "AUTO" ] ; then break; fi
4857 5094

  
4858 5095
	done
......
4861 5098
	if [ -z "$PBI_UPNVER" ] ; then return 1 ; fi
4862 5099

  
4863 5100
	# See if this update is newer than the installed date
4864
	if [ ! -z "$_omdate" ] ; then
5101
	if [ -n "$_omdate" ] ; then
4865 5102
		nDay=`echo $PBI_UPMDATE | cut -d ' ' -f 1`
4866 5103
		nHour=`echo $PBI_UPMDATE | cut -d ' ' -f 2`
4867 5104
		oDay=`echo $_omdate | cut -d ' ' -f 1`
......
4887 5124

  
4888 5125
# Start PBI update process
4889 5126
do_pbi_update() {
4890
	if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
5127
	if [ -n "${PBI_UPCHECK}" ]; then return 0 ; fi
4891 5128

  
4892 5129
	if [ "$PBI_UPDATEAPP" = "ALL" ] ; then
4893 5130
		# Loop and check all PBIs for updates
......
4921 5158
pbi_add_fetch_remote() {
4922 5159
	# Set the target program we want to download
4923 5160
	_rtar="$PBI_FILENAME"
5161
	unset PBI_FILENAME
4924 5162

  
4925 5163
	# Check if the user overrode the arch / versions we want to install
4926 5164
	_rArch=`uname -m`
4927
	if [ ! -z "$PBI_ADD_ALTARCH" ] ; then _rArch=$PBI_ADD_ALTARCH ; fi
5165
	if [ -n "$PBI_ADD_ALTARCH" ] ; then _rArch=$PBI_ADD_ALTARCH ; fi
4928 5166

  
4929 5167
	_rVer="current"
4930
	if [ ! -z "$PBI_ADD_ALTVER" ] ; then _rVer=$PBI_ADD_ALTVER ; fi
5168
	if [ -n "$PBI_ADD_ALTVER" ] ; then _rVer=$PBI_ADD_ALTVER ; fi
4931 5169

  
4932 5170

  
4933 5171
	check_pbi_update "$_rtar" "nodisplay" \
......
4946 5184
	# Now overwrite the PBI_FILENAME and let us proceed to regular install
4947 5185
	PBI_FILENAME="$PBI_UPDLFILE"
4948 5186

  
5187
	# If we are only fetching, finish up now
5188
	if [ "$PBI_REMOTEFETCHONLY" = "YES" ] ; then
5189
		mv $PBI_FILENAME ./`basename ${PBI_UPFILE}`
5190
		echo "PBI saved to ./`basename ${PBI_UPFILE}`"
5191
		exit_trap
5192
	fi
5193

  
4949 5194
}
4950 5195

  
4951 5196
# Update the targed PBI
......
5063 5308
	_dl_loc="${PBI_APPDIR}/.`basename $PBI_UPFILE`.$$"
5064 5309

  
5065 5310
	# Have a patch file to download instead, make that the active file to try
5066
	if [ ! -z "$_tPatch" ] ; then
5311
	if [ -n "$_tPatch" ] ; then
5067 5312
		_bDir=`dirname $PBI_UPFILE`
5068 5313
		_uFile="${_bDir}/${_tPatch}"
5069 5314
	else
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff