This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
pbi-manager
executable file
·7871 lines (6632 loc) · 225 KB
/
pbi-manager
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# Copyright 2013 iXsystems (Kris Moore)
# All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
usage_add_pbi() {
cat <<EOF
usage: `basename $0` [options] pbi
Options:
-e -- Extract Only
-f -- Force install, overwriting existing installation
-g -- Get and show path to icon / images for gui installer
-i -- Display information about this PBI
-l -- Display LICENSE text
-o outdir -- Extract to target directory
-r -- Fetch and install PBI
-R -- Fetch install file and save to disk (Do not install)
-v -- Enable verbose output
--checkscript -- Display any custom install / removal scripts
--licagree -- Agree to LICENSE terms for installation
--meta -- Display any custom meta-file supplied with the PBI
--no-checksum -- Skip the checksum verification during installation
--no-checksig -- Ignore signature verification and force install
--no-hash -- Disable using shared hash folder for PBI
--rArch arch -- Used with -r to specify the specific PBI machine type
--rVer ver -- Used with -r to specify the specific PBI version
--repo repoid -- Used with -r to specify the specific repo to pull from
EOF
exit_trap
}
usage_autob_pbi() {
cat <<EOF
usage: `basename $0` [options]
Options:
-c confdir -- Directory to traverse looking for meta-data modules <required>
-d portdir -- Use different ports dir (Default: /usr/ports)
-h script -- Call the following helper script after each build
-o outdir -- Where to place the finished PBI file(s) <required>
-p <num> -- Number of PBI builds to run concurrently (Defaults to 1)
-32 -- Build i386 PBIs on amd64 host
-32fallback -- On amd64 host, build 32bit PBIs if only i386 can be built
--genpatch -- Generate patch files (*.pbp) from archived PBIs to current
--keep <num> -- Keep <num> old versions in archive folder for each built PBI
--prune -- Remove files from 'outdir' that no longer have a module
--pkgbuild -- Build the PBIs using packages from PKGNG
--tmpfs -- Use TMPFS for port WRKDIRPREFIX
--sign key -- Sign the PBI(s) with specified openssl key
EOF
exit_trap
}
usage_create_pbi() {
cat <<EOF
usage: `basename $0` [options] pbidir
Options:
-a author -- Application Author
-b -- Make a backup of an already installed PBI
-c confdir -- PBI configuration meta-data directory
-d portdir -- Use different ports dir (Default: /usr/ports)
-i icon -- Application Icon, relative to pbidir/
-n name -- Application Name
-o outdir -- Output directory for finished .pbi file
-p port -- Pull name / version from FreeBSD Port
-r version -- Application Version
-w url -- Application Website
--meta file -- Include the specified <file> inside the PBI header
for display with "pbi_add --meta"
--no-hash -- Disable using shared hash folder for PBI
--sign key -- Sign the PBI with specified openssl key
EOF
exit_trap
}
usage_delete_pbi() {
cat <<EOF
usage: `basename $0` [options] pbi
Options:
-v -- Enable verbose output
--clean-hdir -- Perform a full cleaning of hash dir (Does not remove any PBIs)
EOF
exit_trap
}
usage_make_pbi() {
cat <<EOF
usage: `basename $0` [options] port
Options:
-B -- Build-only, do not run pbi_create when finished
-c confdir -- PBI configuration meta-data directory
-d portdir -- Use different ports dir (Default: /usr/ports)
-k -- Keep build files, don't delete when finished
-o outdir -- Where to place the finished PBI file
-p prefix -- Specify alternate PBI Compile PREFIX
-32 -- Build i386 PBI on amd64 host
--delbuild -- Delete existing build dirs if they exist
--meta file -- Include the specified meta file in the PBI header
--mkdebug -- Drop to debug shell if port make fails
--pkgbuild -- Build PBI from PKGNG package repo
--tmpfs -- Use TMPFS for port WRKDIRPREFIX
--no-prune -- Do not prune non REQUIREDBY ports
--sign key -- Sign the PBI with specified openssl key
EOF
exit_trap
}
usage_icon_pbi() {
cat <<EOF
usage: `basename $0` [options] pbi
Options:
add-desktop -- Add desktop icons
add-menu -- Add menu icons
add-mime -- Add mime registration
add-pathlnk -- Add PATH links
del-desktop -- Remove desktop icons
del-menu -- Remove menu icons
del-mime -- Remove mime registration
del-pathlnk -- Remove PATH links
EOF
exit_trap
}
usage_info_pbi() {
cat <<EOF
usage: `basename $0` [options] pbi
Options:
-a -- Show all installed PBIs
-v -- Enable verbose output
EOF
exit_trap
}
usage_makepatch_pbi() {
cat <<EOF
usage: `basename $0` [options] oldpbi newpbi
Options:
-o outdir -- Save the .PBP file to outdir
--tmpfs -- Use TMPFS for extracting PBIs
--sign key -- Sign the PBI with specified openssl key
--no-checksig -- Ignore signature verification and force install
EOF
exit_trap
}
usage_addrepo_pbi() {
cat <<EOF
usage: `basename $0` <Repo File>
EOF
exit_trap
}
usage_deleterepo_pbi() {
cat <<EOF
usage: `basename $0` <Repo ID>
EOF
exit_trap
}
usage_mt_add() {
cat <<EOF
usage: `basename $0` add [options] metafile
Options:
--cat -- Adding a new category metadata
--app -- Adding a new application metadata
-a author -- Application author
-c category -- Application category
-d desc -- Description for application / category (Required)
-i icon -- URL pointing to 64x64 PNG application / category icon (Required)
-k keywords -- Application keywords for searching
-l license -- Application license type
Example: BSD, GPL, Commercial
-m email -- Port / Application Maintainer
-n name -- Application / category name (Required)
-t type -- Application interface type
Example; Graphical, Text, Service
-u url -- Application homepage URL
-r -- Application must be installed as root
-s shortdesc -- Short description for application
EOF
exit_trap
}
usage_it_add() {
cat <<EOF
usage: `basename $0` add [options] indexfile
Options:
-b vers -- Mark previous versions as having binary diff patches available
I.E. (2.7.3,2.8.1,2.8.2)
-f pbifile -- The PBI file we are adding to the index (Required)
-k num -- The number of previous versions of this PBI to keep in the index
-u fileurl -- The URL to this PBI on the mirror server(s) (Required)
EOF
exit_trap
}
usage_mt_rem() {
cat <<EOF
usage: `basename $0` rem [options] metafile
Options:
--cat -- Removing category metadata
--app -- Removing application metadata
-n name -- The name we are removing from the metafile (Required)
EOF
exit_trap
}
usage_mt_syncpbi() {
cat <<EOF
usage: `basename $0` syncpbi pbifile metafile
This command will sync the meta-data from a PBI into the repo metafile
EOF
exit_trap
}
usage_it_rem() {
cat <<EOF
usage: `basename $0` rem [options] indexfile
Options:
-m arch -- The PBI architecture to remove (Required)
I.E. (i386,amd64,etc)
-n pbiname -- The PBI name we are removing from the index (Required)
-v version -- The version of the PBI to remove (Required)
EOF
exit_trap
}
usage_mt_unknown() {
cat <<EOF
usage: `basename $0` [options] metafile
Options:
add -- Add a new entry to the specified metafile
rem -- Remove an entry in the metafile
syncpbi -- Sync meta-data from a PBI file
EOF
exit_trap
}
usage_it_unknown() {
cat <<EOF
usage: `basename $0` [options] indexfile
Options:
add -- Add a new entry to the specified indexfile
rem -- Remove an entry in the indexfile
EOF
exit_trap
}
usage_browse_pbi() {
cat <<EOF
usage: `basename $0` [options] [repoid]
Options:
-c category -- List PBIs from the specified category
-s search -- Search for the specified string
--listcats -- List the available categories in this repository
EOF
exit_trap
}
usage_listrepo_pbi() {
cat <<EOF
usage: `basename $0` [options] [repoid]
Options:
--down -- Move the specified repoid down in priority
--mirror url -- Change the target repoid's mirror url
--up -- Move the specified repoid up in priority
EOF
exit_trap
}
usage_makerepo_pbi() {
cat <<EOF
usage: `basename $0` [options] [outdir]
Options:
--desc description -- Description for this new repo
--key key -- Path to the public key file for this repo
--url url -- Base URL for fetching the INDEX files
--mirror mirrorurl -- Mirror url(s) for fetching PBIs, use ',' as
seperator for multiple
EOF
exit_trap
}
usage_patch_pbi() {
cat <<EOF
usage: `basename $0` [options] pbp
Options:
-e -- Extract Only
-g -- Get and show path to icon / images for gui installer
-i -- Display information about this PBI
-o outdir -- Extract to target directory
--checkscript -- Display any custom install / removal scripts
--no-checksig -- Ignore signature verification and force install
--no-hash -- Disable using shared hash folder for PBI
EOF
exit_trap
}
# update usage
usage_update_pbi() {
cat <<EOF
usage: `basename $0` [options] pbi
Options:
-c -- Check-only, do not update target PBI
--check-all -- Perform a full check of all PBIs for updates
--disable-auto -- Disable auto-updating for the target PBI
--enable-auto -- Enable auto-updating for the target PBI
--update-all -- Update all PBIs to latest versions
EOF
exit_trap
}
# Parse the command line for info
parse_delete_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-v) PBI_VERBOSE="YES"
;;
--clean-hdir) pbi_clean_hashdir
exit_trap
;;
*) if [ $# -gt 1 ]; then usage_delete_pbi; fi
if [ ! -e "${PBI_DBAPPDIR}/${1}" ] ; then
find_pbi_namematch "$1"
if [ -z "$PBI_NAMEMATCH" ] ; then
exit_err "can't find installed pbi (${1})"
fi
PBI_DELETENAME="$PBI_NAMEMATCH"
else
PBI_DELETENAME="$1"
fi
;;
esac
shift
done
if [ -z "${PBI_DELETENAME}" ];then usage_delete_pbi; fi
}
find_pbi_namematch()
{
_fLow="`echo ${1} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
PBI_NAMEMATCH=""
for i in `ls -d ${PBI_DBAPPDIR}/* 2>/dev/null`
do
if [ ! -e "$i/pbi_name" ] ; then continue ; fi
_tLow="`cat $i/pbi_name | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
if [ "$_tLow" = "$_fLow" ] ; then
PBI_NAMEMATCH="`basename ${i}`"
break
fi
done
}
# Parse the command line for icon
parse_icon_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
add-desktop) PBI_DESKADD="YES" ;;
add-menu) PBI_MENUADD="YES" ;;
add-mime) PBI_MIMEADD="YES" ;;
add-pathlnk) PBI_PATHADD="YES" ;;
del-desktop) PBI_DESKDEL="YES" ;;
del-menu) PBI_MENUDEL="YES" ;;
del-mime) PBI_MIMEDEL="YES" ;;
del-pathlnk) PBI_PATHDEL="YES" ;;
*)
if [ $# -gt 1 ]; then usage_icon_pbi; fi
if [ ! -e "${PBI_DBAPPDIR}/${1}" ] ; then
find_pbi_namematch "$1"
if [ -z "$PBI_NAMEMATCH" ] ; then
exit_err "can't find installed pbi (${1})"
fi
PBI_ICONTARGETAPP="${PBI_NAMEMATCH}"
else
PBI_ICONTARGETAPP="$1"
fi
;;
esac
shift
done
if [ -z "${PBI_ICONTARGETAPP}" ] ; then
usage_icon_pbi
fi
}
# Parse the command line for pbid
parse_pbid_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-v) PBI_VERBOSE="YES"
;;
--refresh) # Schedule us to refresh the index
echo "Your meta and index files will begin refreshing in a moment..."
echo "Details available in /var/log/pbid.log"
rm ${PBI_DBINDEXDIR}/*.time >/dev/null 2>/dev/null
if [ -e "${PROGBASE}/etc/rc.d/pbid" ]; then
${PROGBASE}/etc/rc.d/pbid restart >/dev/null 2>/dev/null
fi
exit 0
;;
esac
shift
done
}
# Parse the command line for info
parse_info_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-a) PBI_INFONAME="--ALL--"
;;
-i) PBI_INFOINDEX="YES"
;;
-v) PBI_VERBOSE="YES"
;;
*)
if [ $# -gt 1 ]; then usage_info_pbi; fi
if [ ! -e "${PBI_DBAPPDIR}/${1}" ] ; then
find_pbi_namematch "$1"
if [ -z "$PBI_NAMEMATCH" ] ; then
exit_err "can't find installed pbi (${1})"
fi
PBI_INFONAME="$PBI_NAMEMATCH"
else
PBI_INFONAME="$1"
fi
;;
esac
shift
done
if [ -z "${PBI_INFONAME}" ] ; then
PBI_INFONAME="--ALL--"
fi
}
# Parse the command line for patching
parse_makepatch_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-o) if [ $# -eq 1 ]; then usage_makepatch_pbi; fi
shift; PBI_PATCHOUTDIR="$1"
;;
--sign) if [ $# -eq 1 ]; then usage_makepatch_pbi; fi
shift; PBI_SSLPRIVKEY="$1"
;;
--tmpfs) PBI_MP_TMPFS="YES"
;;
--no-checksig) PBI_SKIPSIGVERIFY="YES" ;;
*) if [ $# -gt 2 ]; then usage_makepatch_pbi; fi
PBI_OLDFILENAME="$1"
shift
PBI_FILENAME="$1"
;;
esac
shift
done
if [ -z "${PBI_FILENAME}" ]; then usage_makepatch_pbi ; fi
if [ -z "${PBI_OLDFILENAME}" ]; then usage_makepatch_pbi ; fi
if [ -z "${PBI_PATCHOUTDIR}" ]; then PBI_PATCHOUTDIR=`pwd` ; fi
# Load all the information about this PBI / PBP
load_info_from_header
}
# Parse the command line for editing a meta file
parse_mt_pbi_cmdline() {
case $1 in
syncpbi) PBI_MT_MODE="SYNCPBI" ; shift ;
PBI_MT_PBIFILE="$1"
PBI_MT_METAFILE="$2"
if [ -z "${PBI_MT_PBIFILE}" ] ; then usage_mt_syncpbi ; fi
if [ -z "${PBI_MT_METAFILE}" ] ; then usage_mt_syncpbi ; fi
return
;;
add) PBI_MT_MODE="ADD" ; shift ;
while [ $# -gt 0 ]; do
case "$1" in
--cat) PBI_MT_TYPE="CAT" ;;
--app) PBI_MT_TYPE="APP" ;;
-m) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_MAINTAINER="$1"
;;
-n) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDNAME="$1"
;;
-i) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDICON="$1"
;;
-d) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDDESC="$1"
;;
-s) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDSHORTDESC="$1"
;;
-c) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDCAT="$1"
;;
-a) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDAUTHOR="$1"
;;
-u) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDURL="$1"
;;
-l) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDLIC="$1"
;;
-t) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDTYPE="$1"
;;
-k) if [ $# -eq 1 ]; then usage_mt_add; fi
shift; PBI_MT_ADDKEYWORDS="$1"
;;
-r) PBI_MT_REQUIRESROOT="YES"
;;
*) if [ $# -gt 1 ]; then usage_mt_add; fi
PBI_MT_METAFILE="$1"
;;
esac
shift
done
if [ -z "${PBI_MT_METAFILE}" ] ; then usage_mt_add ; fi
;;
rem) PBI_MT_MODE="REM" ; shift ;
while [ $# -gt 0 ]; do
case "$1" in
--cat) PBI_MT_TYPE="CAT" ;;
--app) PBI_MT_TYPE="APP" ;;
-n) if [ $# -eq 1 ]; then usage_mt_rem; fi
shift; PBI_MT_REMNAME="$1"
;;
*) if [ $# -gt 1 ]; then usage_mt_rem; fi
PBI_MT_METAFILE="$1"
;;
esac
shift
done
if [ -z "${PBI_MT_METAFILE}" ] ; then usage_mt_rem ; fi
;;
*) usage_mt_unknown ;;
esac
if [ ! -f "${PBI_MT_METAFILE}" ] ; then
exit_err "No such file ${PBI_MT_METAFILE}"
fi
# Sanity check the values
case ${PBI_MT_MODE} in
ADD) # Check the common values
if [ -z "${PBI_MT_ADDNAME}" ] ; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDDESC}" ] ; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDICON}" ] ; then usage_mt_add ; fi
if [ "$PBI_MT_TYPE" = "CAT" ]; then
elif [ "$PBI_MT_TYPE" = "APP" ]; then
if [ -z "${PBI_MT_ADDCAT}" ]; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDAUTHOR}" ]; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDURL}" ]; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDLIC}" ]; then usage_mt_add ; fi
if [ -z "${PBI_MT_ADDTYPE}" ]; then usage_mt_add ; fi
else
usage_mt_add
fi
;;
REM) if [ "$PBI_MT_TYPE" != "CAT" -a "$PBI_MT_TYPE" != "APP" ]
then
usage_mt_rem
fi
if [ -z "${PBI_MT_REMNAME}" ] ; then usage_mt_rem ; fi
;;
esac
}
# Parse the command line for editing a index file
parse_it_pbi_cmdline() {
case $1 in
add) PBI_IT_MODE="ADD" ; shift ;
while [ $# -gt 0 ]; do
case "$1" in
-b) if [ $# -eq 1 ]; then usage_it_add; fi
shift; PBI_IT_ADDBPVERS="$1"
;;
-f) if [ $# -eq 1 ]; then usage_it_add; fi
shift; PBI_IT_ADDFILE="$1"
;;
-k) if [ $# -eq 1 ]; then usage_it_add; fi
shift; PBI_IT_ADDKEEP="$1"
;;
-u) if [ $# -eq 1 ]; then usage_it_add; fi
shift; PBI_IT_ADDURL="$1"
;;
*) if [ $# -gt 1 ]; then usage_it_add; fi
PBI_IT_ADDINDEX="$1"
;;
esac
shift
done
;;
rem) PBI_IT_MODE="REM" ; shift ;
while [ $# -gt 0 ]; do
case "$1" in
-m) if [ $# -eq 1 ]; then usage_it_rem; fi
shift; PBI_IT_REMARCH="$1"
;;
-n) if [ $# -eq 1 ]; then usage_it_rem; fi
shift; PBI_IT_REMNAME="$1"
;;
-v) if [ $# -eq 1 ]; then usage_it_rem; fi
shift; PBI_IT_REMVER="$1"
;;
*) if [ $# -gt 1 ]; then usage_it_rem; fi
PBI_IT_REMINDEX="$1"
;;
esac
shift
done
;;
*) usage_it_unknown ;;
esac
# Sanity check the values
case ${PBI_IT_MODE} in
ADD) if [ -z "${PBI_IT_ADDFILE}" ] ; then usage_it_add ; fi
if [ -z "${PBI_IT_ADDURL}" ] ; then usage_it_add ; fi
if [ -z "${PBI_IT_ADDINDEX}" ] ; then usage_it_add ; fi
if [ ! -f "${PBI_IT_ADDFILE}" ] ; then
exit_err "No such file ${PBI_IT_ADDFILE}"
fi
if [ ! -f "${PBI_IT_ADDINDEX}" ] ; then
exit_err "No such file ${PBI_IT_ADDINDEX}"
fi
if [ -n "${PBI_IT_ADDKEEP}" ] ; then
expr ${PBI_IT_ADDKEEP} + 1 >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
exit_err "-k option must be a integer!"
fi
fi
;;
REM) if [ -z "${PBI_IT_REMNAME}" ] ; then usage_it_rem ; fi
if [ -z "${PBI_IT_REMVER}" ] ; then usage_it_rem ; fi
if [ -z "${PBI_IT_REMARCH}" ] ; then usage_it_rem ; fi
if [ -z "${PBI_IT_REMINDEX}" ] ; then usage_it_rem ; fi
;;
esac
}
# Parse the command line for browsing a repo
parse_browse_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
--listcats) PBI_BROWSE_LISTCATS="YES" ;;
--viewall) PBI_BROWSE_LISTALLPBI="YES" ;;
-c) if [ $# -eq 1 ]; then usage_browse_pbi; fi
shift; PBI_BROWSE_CAT="$1"
;;
-s) if [ $# -eq 1 ]; then usage_browse_pbi; fi
shift; PBI_BROWSE_SEARCH="$1"
;;
*) if [ $# -gt 1 ]; then usage_browse_pbi; fi
PBI_BROWSE_RID="$1"
;;
esac
shift
done
# Get / check the repoid
if [ -n "${PBI_BROWSE_RID}" ] ; then
ls ${PBI_DBREPODIR}/${PBI_BROWSE_RID}.* >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
exit_err "The specified repoid ${PBI_BROWSE_RID} does not exist!"
fi
else
for _repo in `ls ${PBI_DBREPODIR} 2>/dev/null`
do
PBI_BROWSE_RID=`echo $_repo | cut -d '.' -f 1`
break;
done
if [ -z "$PBI_BROWSE_RID" ] ; then exit_err "No available repos!" ; fi
fi
PBI_BROWSE_REPOMD5=`ls ${PBI_DBREPODIR}/${PBI_BROWSE_RID}.* 2>/dev/null | cut -d '.' -f 2`
PBI_BROWSE_METAFILE=`ls ${PBI_DBINDEXDIR}/${PBI_BROWSE_REPOMD5}*meta 2>/dev/null`
if [ -z "${PBI_BROWSE_METAFILE}" ] ; then
exit_err "The specified repo has no meta-file."
fi
}
# Parse the command line for listing repos
parse_listrepo_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
--up) PBI_LISTREPO_UP="YES" ;;
--down) PBI_LISTREPO_DOWN="YES" ;;
--mirror) if [ $# -eq 1 ]; then usage_listrepo_pbi; fi
shift; PBI_LISTREPO_MIRROR="$1"
;;
*) if [ $# -gt 1 ]; then usage_listrepo_pbi; fi
PBI_LISTREPO_ID="$1"
;;
esac
shift
done
if [ "${PBI_LISTREPO_UP}" = "YES" -a "${PBI_LISTREPO_DOWN}" = "YES" ]; then
exit_err "Options --up and --down can't both be used at once!"
fi
if [ "${PBI_LISTREPO_UP}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
exit_err "Missing Repo ID to move up in priority."
fi
if [ "${PBI_LISTREPO_DOWN}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
exit_err "Missing Repo ID to move down in priority."
fi
if [ -n "${PBI_LISTREPO_MIRROR}" -a -z "${PBI_LISTREPO_ID}" ]; then
exit_err "Missing Repo ID to change a specific mirror URL."
fi
if [ -n "${PBI_LISTREPO_ID}" ] ; then
ls ${PBI_DBREPODIR}/${PBI_LISTREPO_ID}.* >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
exit_err "The specified repoid ${PBI_LISTREPO_ID} does not exist!"
fi
fi
}
# Parse the command line for adding a new repo file
parse_addrepo_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
*) if [ $# -gt 1 ]; then usage_addrepo_pbi; fi
PBI_ADDREPO_FILE="$1"
;;
esac
shift
done
if [ -z "$PBI_ADDREPO_FILE" ] ; then
usage_addrepo_pbi
fi
if [ ! -f "$PBI_ADDREPO_FILE" ] ; then
exit_err "Repo file ${PBI_ADDREPO_FILE} does not exist!"
fi
}
# Parse the command line for deleting a repo
parse_deleterepo_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
*) if [ $# -gt 1 ]; then usage_deleterepo_pbi; fi
PBI_DELREPO_ID="$1"
;;
esac
shift
done
if [ -z "$PBI_DELREPO_ID" ] ; then
usage_deleterepo_pbi
fi
}
# Parse the command line for making a new repo file
parse_makerepo_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
--key) if [ $# -eq 1 ]; then usage_makerepo_pbi; fi
shift; PBI_MKREPO_KEY="$1"
;;
--url) if [ $# -eq 1 ]; then usage_makerepo_pbi; fi
shift; PBI_MKREPO_URL="$1"
;;
--desc) if [ $# -eq 1 ]; then usage_makerepo_pbi; fi
shift; PBI_MKREPO_DESC="$1"
;;
--mirror) if [ $# -eq 1 ]; then usage_makerepo_pbi; fi
shift; PBI_MKREPO_MIRROR="$1"
;;
*) if [ $# -gt 1 ]; then usage_makerepo_pbi; fi
PBI_MKREPO_OUTDIR="$1"
;;
esac
shift
done
if [ -z "${PBI_MKREPO_DESC}" ]; then usage_makerepo_pbi ; fi
if [ -z "${PBI_MKREPO_KEY}" ]; then usage_makerepo_pbi ; fi
if [ -z "${PBI_MKREPO_MIRROR}" ]; then usage_makerepo_pbi ; fi
if [ -z "${PBI_MKREPO_URL}" ]; then usage_makerepo_pbi ; fi
if [ -z "${PBI_MKREPO_OUTDIR}" ]; then PBI_MKREPO_OUTDIR="${HOME}"; fi
if [ ! -f "${PBI_MKREPO_KEY}" ]; then exit_err "The key file ${PBI_MKREPO_KEY} does not exist." ; fi
# Make sure we have a valid URL format
echo "${PBI_MKREPO_URL}" | grep -q -e "^http://" -e "^https://" -e "^ftp://"
if [ $? -ne 0 ] ; then
exit_err "Repo URL must begin with http://, https://, or ftp://"
fi
}
# Parse the command line for patching
parse_patch_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-e) PBI_EXTRACTONLY="YES"
;;
-g) PBI_ADD_GUIDISPLAY="YES"
;;
-i) PBI_ADD_INFODISPLAY="YES"
;;
-o)
if [ $# -eq 1 ]; then usage_patch_pbi; fi
shift; PBI_ALTEXTRACT_DIR="$1"
;;
--checkscript) PBI_CHECKSCRIPTS="YES" ;;
--no-hash) PBI_DISABLEHASHDIR="YES" ;;
--no-checksum) PBI_SKIPCHECKSUM="YES" ;;
--no-checksig) PBI_SKIPSIGVERIFY="YES" ;;
*) if [ $# -gt 1 ]; then usage_patch_pbi; fi
PBI_FILENAME="$1"
;;
esac
shift
done
if [ -z "${PBI_FILENAME}" ]; then usage_patch_pbi ; fi
# Get the absolute patch to the file
get_abspath "$PBI_FILENAME"
PBI_FILENAME="$_ABSPATH"
if [ ! -e "${PBI_FILENAME}" ]; then usage_patch_pbi ; fi
# Load all the information about this PBI / PBP
load_info_from_header
# Make sure this isn't a patch file
is_pbi_patch
if [ "$?" = "1" ] ; then
exit_err "This is not a PBP patch file"
fi
if [ -z "${PBI_ORIGPROGDIRPATH}" ]; then usage_patch_pbi ; fi
# Lastly set PBI_PROGDIRNAME
PBI_PROGDIRNAME="`echo ${PBI_ORIGPROGDIRPATH} | rev | cut -d '/' -f 1 | rev`"
if [ "${PBI_EXTRACTONLY}" = "YES" ] ; then
# If extracting to a alt-outdir, set it now
PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
if [ -n "${PBI_ALTEXTRACT_DIR}" ]; then
PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
fi
else
# Set the extraction dir
PBI_PROGDIRPATH="${PBI_ORIGPROGDIRPATH}-patch"
fi
}
# Parse the command line for adding
parse_add_pbi_cmdline() {
while [ $# -gt 0 ]; do
case "$1" in
-e) PBI_EXTRACTONLY="YES"
;;
-f) PBI_FORCEADD="YES"
;;
-g) PBI_ADD_GUIDISPLAY="YES"
;;
-i) PBI_ADD_INFODISPLAY="YES"
;;
--meta) PBI_ADD_METADISPLAY="YES"
;;
-l) PBI_ADD_LICDISPLAY="YES"
;;
-o) if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ALTEXTRACT_DIR="$1"
;;
-r) PBI_REMOTEFETCH="YES"
;;
-R) PBI_REMOTEFETCH="YES"
PBI_REMOTEFETCHONLY="YES"
;;
-v) PBI_VERBOSE="YES"
;;
--rArch)
if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ADD_ALTARCH="$1"
;;
--rVer)
if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ADD_ALTVER="$1"
;;
--checkscript) PBI_CHECKSCRIPTS="YES" ;;
--licagree) PBI_LICAGREE="YES" ;;
--no-hash) PBI_DISABLEHASHDIR="YES" ;;
--no-checksum) PBI_SKIPCHECKSUM="YES" ;;
--no-checksig) PBI_SKIPSIGVERIFY="YES" ;;
--repo) if [ $# -eq 1 ]; then usage_add_pbi; fi
shift; PBI_ADDREPO_ID="$1"
;;
*)
if [ $# -gt 1 ]; then usage_add_pbi; fi
# If there is no file, try fetching from repo
if [ ! -e "${1}" ] ; then PBI_REMOTEFETCH="YES"; fi
PBI_FILENAME="$1"
;;
esac
shift
done
if [ -z "${PBI_FILENAME}" ]; then usage_add_pbi ; fi
# If we are doing a remote fetch / install then do it now
if [ "$PBI_REMOTEFETCH" = "YES" ] ; then
if [ -z "${PBI_ADDREPO_ID}" ] ; then
PBI_ADDREPO_ID="AUTO"
else
ls ${PBI_DBREPODIR}/${PBI_ADDREPO_ID}.* >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
exit_err "No such repo ID: ${PBI_DELREPO_ID}"
fi
fi
# Start fetching file
pbi_add_fetch_remote
fi
# Load all the information about this PBI
load_info_from_header