Skip to content
This repository
Browse code

Add the ability to sync a PBIs meta-data with a repos meta-file

  • Loading branch information...
commit 607d79b2fc97ea3d8821fa8386bf7da0419b9b72 1 parent 8bea84f
Kris Moore authored October 08, 2013

Showing 1 changed file with 76 additions and 1 deletion. Show diff stats Hide diff stats

  1. 77  src-sh/pbi-manager10/pbi-manager
77  src-sh/pbi-manager10/pbi-manager
@@ -249,6 +249,15 @@ EOF
249 249
 	exit_trap
250 250
 }
251 251
 
  252
+usage_mt_syncpbi() {
  253
+        cat <<EOF
  254
+usage: `basename $0` syncpbi pbifile metafile
  255
+
  256
+This command will sync the meta-data from a PBI into the repo metafile
  257
+                
  258
+EOF
  259
+	exit_trap
  260
+}
252 261
 
253 262
 usage_it_rem() {
254 263
         cat <<EOF
@@ -271,6 +280,7 @@ usage: `basename $0` [options] metafile
271 280
 Options:
272 281
   add   	-- Add a new entry to the specified metafile
273 282
   rem    	-- Remove an entry in the metafile
  283
+  syncpbi    	-- Sync meta-data from a PBI file
274 284
 
275 285
 EOF
276 286
 	exit_trap
@@ -517,6 +527,13 @@ parse_makepatch_pbi_cmdline() {
517 527
 parse_mt_pbi_cmdline() {
518 528
 
519 529
 	case $1 in
  530
+      	syncpbi) PBI_MT_MODE="SYNCPBI" ; shift ; 
  531
+		PBI_MT_PBIFILE="$1"
  532
+		PBI_MT_METAFILE="$2"
  533
+		if [ -z "${PBI_MT_PBIFILE}" ] ; then usage_mt_syncpbi ; fi
  534
+		if [ -z "${PBI_MT_METAFILE}" ] ; then usage_mt_syncpbi ; fi
  535
+		return
  536
+		;;
520 537
   	   add)	PBI_MT_MODE="ADD" ; shift ; 
521 538
 		while [ $# -gt 0 ]; do
522 539
                 	case "$1" in
@@ -2018,10 +2035,39 @@ make_pbi_repo() {
2018 2035
 	rm_tmpdir
2019 2036
 }
2020 2037
 
  2038
+do_pbi_mt_syncpbi()
  2039
+{
  2040
+	# First load values from the target PBI
  2041
+	PBI_FILENAME="${PBI_MT_PBIFILE}"
  2042
+	load_info_from_header
  2043
+
  2044
+	mFlags="add --app"
  2045
+	if [ -n "$PBI_PROGAUTHOR" ] ; then mFlags="$mFlags -a \"${PBI_PROGAUTHOR}\""; fi
  2046
+	if [ -n "$PBI_CATEGORY" ] ; then mFlags="$mFlags -c \"${PBI_CATEGORY}\""; fi
  2047
+	if [ -n "$PBI_LICENSE" ] ; then mFlags="$mFlags -l \"${PBI_LICENSE}\""; fi
  2048
+	if [ -n "$PBI_TAGS" ] ; then mFlags="$mFlags -k \"${PBI_TAGS}\""; fi
  2049
+	if [ -n "$PBI_ICONURL" ] ; then mFlags="$mFlags -i \"${PBI_ICONURL}\""; fi
  2050
+	if [ -n "$PBI_PROGWEB" ] ; then mFlags="$mFlags -u \"${PBI_PROGWEB}\""; fi
  2051
+	if [ -n "$PBI_PROGTYPE" ] ; then mFlags="$mFlags -t \"${PBI_PROGTYPE}\""; fi
  2052
+	if [ -n "$PBI_DESC" ] ; then mFlags="$mFlags -d \"`echo $PBI_DESC | sed 's|;||g'`\""; fi
  2053
+	if [ -n "$PBI_PROGTYPE" ] ; then mFlags="$mFlags -t \"$PBI_PROGTYPE\""; fi
  2054
+	if [ "$PBI_REQUIRESROOT" = "YES" ] ; then mFlags="$mFlags -r"; fi
  2055
+
  2056
+
  2057
+	# Add the app
  2058
+	echo "pbi_metatool ${mFlags} -n \"${PBI_PROGNAME}\" `realpath ${PBI_MT_METAFILE}`" >/tmp/.pbiCmd.$$
  2059
+	chmod 755 /tmp/.pbiCmd.$$
  2060
+	/tmp/.pbiCmd.$$
  2061
+	err=$?
  2062
+	#rm /tmp/.pbiCmd.$$
  2063
+	exit $err
  2064
+}
  2065
+
2021 2066
 # Init the metatool
2022 2067
 pbi_mt_init() {
2023 2068
 	parse_mt_pbi_cmdline "$@"
2024 2069
 	case $PBI_MT_MODE in
  2070
+	    SYNCPBI) do_pbi_mt_syncpbi ;;
2025 2071
 		ADD) if [ "$PBI_MT_TYPE" = "CAT" ] ; then
2026 2072
 			do_pbi_mt_add_cat
2027 2073
 		     else
@@ -2055,8 +2101,10 @@ do_pbi_mt_add_app() {
2055 2101
 	# Remove any duplicate name
2056 2102
 	do_pbi_mt_rem_app "${PBI_MT_ADDNAME}" "${PBI_MT_METAFILE}"
2057 2103
 
  2104
+	local _date=`date '+%s'`
  2105
+
2058 2106
 	cp ${PBI_MT_METAFILE} ${PBI_TMPDIR}/.meta.$$
2059  
-	echo "App=${PBI_MT_ADDNAME};${PBI_MT_ADDCAT};${PBI_MT_ADDICON};${PBI_MT_ADDAUTHOR};${PBI_MT_ADDURL};${PBI_MT_ADDLIC};${PBI_MT_ADDTYPE};${PBI_MT_ADDKEYWORDS};${PBI_MT_ADDDESC};$PBI_MT_REQUIRESROOT;" \
  2107
+	echo "App=${PBI_MT_ADDNAME};${PBI_MT_ADDCAT};${PBI_MT_ADDICON};${PBI_MT_ADDAUTHOR};${PBI_MT_ADDURL};${PBI_MT_ADDLIC};${PBI_MT_ADDTYPE};${PBI_MT_ADDKEYWORDS};${PBI_MT_ADDDESC};$PBI_MT_REQUIRESROOT;${_date}" \
2060 2108
 	>> ${PBI_TMPDIR}/.meta.$$
2061 2109
 	sort ${PBI_TMPDIR}/.meta.$$ > "${PBI_MT_METAFILE}"
2062 2110
 	rm ${PBI_TMPDIR}/.meta.$$
@@ -3046,6 +3094,9 @@ load_info_from_dir() {
3046 3094
 	PBI_DESC=""
3047 3095
 	PBI_SHORTDESC=""
3048 3096
 	PBI_TAGS=""
  3097
+	PBI_PROGTYPE=""
  3098
+	PBI_CATEGORY=""
  3099
+	PBI_ICONURL=""
3049 3100
 	PBI_LICENSE=""
3050 3101
 
3051 3102
 	PBI_ORIGPROGDIRPATH="`cat ${1}/pbi_defaultpath`"
@@ -3066,6 +3117,15 @@ load_info_from_dir() {
3066 3117
 	if [ -e "${1}/pbi_tags" ] ; then
3067 3118
                 PBI_TAGS="`cat ${1}/pbi_tags`"
3068 3119
         fi
  3120
+	if [ -e "${1}/pbi_type" ] ; then
  3121
+                PBI_PROGTYPE="`cat ${1}/pbi_type`"
  3122
+        fi
  3123
+	if [ -e "${1}/pbi_category" ] ; then
  3124
+                PBI_CATEGORY="`cat ${1}/pbi_category`"
  3125
+        fi
  3126
+	if [ -e "${1}/pbi_iconurl" ] ; then
  3127
+                PBI_ICONURL="`cat ${1}/pbi_iconurl`"
  3128
+        fi
3069 3129
 	if [ -e "${1}/pbi_desc" ] ; then
3070 3130
                 PBI_DESC="`cat ${1}/pbi_desc`"
3071 3131
         fi
@@ -4295,6 +4355,15 @@ save_pbi_details_to_header() {
4295 4355
 	if [ -n "$PBI_TAGS" ] ; then
4296 4356
 		echo "$PBI_TAGS" > ${PBI_HEADERDIR}/pbi_tags
4297 4357
 	fi
  4358
+	if [ -n "$PBI_PROGTYPE" ] ; then
  4359
+		echo "$PBI_PROGTYPE" > ${PBI_HEADERDIR}/pbi_type
  4360
+	fi
  4361
+	if [ -n "$PBI_CATEGORY" ] ; then
  4362
+		echo "$PBI_CATEGORY" > ${PBI_HEADERDIR}/pbi_category
  4363
+	fi
  4364
+	if [ -n "$PBI_ICONURL" ] ; then
  4365
+		echo "$PBI_ICONURL" > ${PBI_HEADERDIR}/pbi_iconurl
  4366
+	fi
4298 4367
 	if [ -n "$PBI_DESC" ] ; then
4299 4368
 		echo "$PBI_DESC" > ${PBI_HEADERDIR}/pbi_desc
4300 4369
 	fi
@@ -6842,6 +6911,12 @@ load_pkg_metadata()
6842 6911
 	if [ -z "$PBI_PROGWEB" ] ; then
6843 6912
 		PBI_PROGWEB="`pkg query '%w' ${PBI_MAKEPORT}`"
6844 6913
 	fi
  6914
+	if [ -z "$PBI_CATEGORY" ] ; then
  6915
+		PBI_CATEGORY="`pkg query '%C' ${PBI_MAKEPORT} | head -n 1`"
  6916
+	fi
  6917
+	if [ -z "$PBI_PROGTYPE" ] ; then
  6918
+		PBI_PROGTYPE="Text"
  6919
+	fi
6845 6920
 }
6846 6921
 
6847 6922
 # Check if we need to save a list of GROUPS to create at install

0 notes on commit 607d79b

Please sign in to comment.
Something went wrong with that request. Please try again.