-
Notifications
You must be signed in to change notification settings - Fork 26
/
make-helper.bsh
executable file
·1427 lines (1271 loc) · 42.5 KB
/
make-helper.bsh
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/bash
## Copyright (C) 2012 - 2018 ENCRYPTED SUPPORT LP <adrelanos@riseup.net>
## See the file COPYING for copying conditions.
## genmkfile - make-helper-bsh - version 1.7
## This is a copy.
## master location:
## https://github.com/Whonix/genmkfile/blob/master/usr/share/genmkfile/make-helper.bsh
make_init() {
cd "$GENMKFILE_ROOT_DIR"
}
make_deinit() {
true
}
make_parse_cmd() {
## Thanks to:
## http://mywiki.wooledge.org/BashFAQ/035
local matched="false"
local deb
while :
do
case $1 in
help)
matched="true"
make_function_run make_help
exit 0
shift
;;
all)
matched="true"
make_function_run make_all "$@"
exit 0
shift
;;
dist)
matched="true"
make_function_run make_dist
exit 0
shift
;;
test)
matched="true"
make_function_run make_test
exit 0
shift
;;
undist)
matched="true"
make_function_run make_undist
exit 0
shift
;;
debdist)
matched="true"
make_function_run make_debdist
exit 0
shift
;;
undebdist)
matched="true"
make_function_run make_undebdist
exit 0
shift
;;
manpages)
matched="true"
make_function_run make_manpages
exit 0
shift
;;
uch)
matched="true"
make_function_run make_uch
exit 0
shift
;;
install)
matched="true"
make_function_run make_install
exit 0
shift
;;
deb-build-dep)
matched="true"
make_function_run make_deb-build-dep
exit 0
shift
;;
deb-run-dep)
matched="true"
make_function_run make_deb-run-dep
exit 0
shift
;;
deb-all-dep)
matched="true"
make_function_run make_deb-all-dep
exit 0
shift
;;
deb-pkg)
matched="true"
deb="true"
shift
;;
deb-pkg-signed)
matched="true"
make_deb_signed="true"
shift
;;
deb-pkg-source)
matched="true"
make_deb_source="true"
shift
;;
deb-pkg-install)
matched="true"
make_function_run make_deb-pkg-install
exit 0
shift
;;
deb-install)
matched="true"
make_function_run make_deb-install
exit 0
shift
;;
deb-icup)
matched="true"
make_function_run make_deb-icup
exit 0
shift
;;
deb-remove)
matched="true"
make_function_run make_deb-remove
exit 0
shift
;;
deb-purge)
matched="true"
make_function_run make_deb-purge
exit 0
shift
;;
deb-pkg)
matched="true"
deb="true"
shift
;;
deb-clean)
matched="true"
make_function_run make_deb-clean
shift
;;
deb-cleanup)
matched="true"
make_function_run make_deb-cleanup
shift
;;
lintian)
matched="true"
make_function_run make_lintian
shift
;;
dput-ubuntu-ppa)
matched="true"
make_function_run make_dput-ubuntu-ppa
shift
;;
clean)
matched="true"
make_function_run make_clean
exit 0
shift
;;
distclean)
matched="true"
make_function_run make_clean
exit 0
shift
;;
checkout)
matched="true"
make_function_run make_checkout
exit 0
shift
;;
installcheck)
matched="true"
make_function_run make_installcheck
exit 0
shift
;;
installsim)
matched="true"
make_function_run make_installsim
exit 0
shift
;;
uninstallcheck)
matched="true"
make_function_run make_uninstallcheck
exit 0
shift
;;
uninstall)
matched="true"
make_function_run make_uninstall
exit 0
shift
;;
uninstallsim)
matched="true"
make_function_run make_uninstallsim
exit 0
shift
;;
deb-chl-bumpup-major)
matched="true"
make_function_run make_deb-chl-bumpup-major
exit 0
shift
;;
deb-chl-bumpup-manual)
matched="true"
make_function_run make_deb-chl-bumpup-manual
exit 0
shift
;;
deb-uachl-bumpup-major)
matched="true"
make_function_run make_deb-uachl-bumpup-major
exit 0
shift
;;
deb-uachl-bumpup-manual)
matched="true"
make_function_run make_deb-uachl-bumpup-manual
exit 0
shift
;;
git-tag-show)
matched="true"
make_function_run make_git_tag_show
exit 0
shift
;;
git-tag-sign)
matched="true"
make_function_run make_git_tag_sign
exit 0
shift
;;
git-tag-verify)
matched="true"
make_function_run make_git_tag_verify
exit 0
shift
;;
git-tag-check)
matched="true"
make_function_run make_git_tag_check
exit 0
shift
;;
git-commit-verify)
matched="true"
make_function_run make_git_commit_verify_current
exit 0
shift
;;
git-verify)
matched="true"
make_function_run make_git_verify
exit 0
shift
;;
git-tag-push)
matched="true"
make_function_run make_git_tag_push
exit 0
shift
;;
git-tag-show-latest)
matched="true"
make_function_run make_git_tag_show_latest
exit 0
shift
;;
git-tag-push-latest)
matched="true"
make_function_run make_git_tag_push_latest
exit 0
shift
;;
reprepro-add)
matched="true"
make_function_run make_reprepro-add
exit 0
shift
;;
reprepro-remove)
matched="true"
make_function_run make_reprepro-remove
exit 0
shift
;;
--)
shift
break
;;
-*)
echo "unknown option: $1" >&2
exit 1
;;
*)
break
;;
esac
done
## If there are input files (for example) that follow the options, they
## will remain in the "$@" positional parameters.
if [ ! "$matched" = "true" ]; then
make_function_run "$@"
fi
if [ "$deb" = "true" ]; then
make_function_run make_deb-pkg "$@"
exit 0
fi
if [ "$make_deb_signed" = "true" ]; then
make_function_run make_deb-pkg-signed "$@"
exit 0
fi
if [ "$make_deb_source" = "true" ]; then
make_function_run make_deb-pkg-source "$@"
exit 0
fi
}
make_dependencies_filter_helper() {
temp="$@"
for to_remove in '${misc:Depends}' '${python:Depends}' '|' ; do
temp="${temp//"$to_remove"/""}"
done
echo "$temp"
}
make_get_variables() {
## Deterministic.
LC_ALL=C.UTF-8
TZ=UTC
export LC_ALL TZ
## TODO
package_build_result_temp_folder="/home/user/whonix_binary/packages_temp"
package_build_pkg_src_temp_folder="/home/user/whonix_binary/packages_temp"
local temp dpkg_line
if ! command -v dpkg-parsechangelog >/dev/null ; then
true 'dpkg-parsechangelog not found. Do you have the "build-essential" package installed?
To install all dependencies, try running:
sudo make deb-all-dep
'
exit 1
fi
make_debian_control_file_relative_path="debian/control"
make_debian_control_file_absolute_path="$(realpath "$make_debian_control_file_relative_path")"
test -f "$make_debian_control_file_absolute_path"
make_debian_changelog_file_relative_path="debian/changelog"
make_debian_changelog_file_absolute_path="$(realpath "$make_debian_changelog_file_relative_path")"
test -f "$make_debian_changelog_file_absolute_path"
## Thanks to jakob for the perl lines.
## http://unix.stackexchange.com/users/20977/jakob
## http://unix.stackexchange.com/a/215919/49297
make_deb_build_dependencies="$(perl -ne 'next if /^#/; $p=(s/^Build-Depends:\s*/ / or (/^ / and $p)); s/,|\n|\([^)]+\)//mg; print if $p' < "$make_debian_control_file_absolute_path")"
make_deb_build_dependencies="$(make_dependencies_filter_helper "$make_deb_build_dependencies")"
make_deb_runtime_dependencies="$(perl -ne 'next if /^#/; $p=(s/^Depends:\s*/ / or (/^ / and $p)); s/,|\n|\([^)]+\)//mg; print if $p' < "$make_debian_control_file_absolute_path")"
make_deb_runtime_dependencies="$(make_dependencies_filter_helper "$make_deb_runtime_dependencies")"
while read -r -d $'\n' dpkg_line; do
## Example dpkg_line:
## Version: 0.1-1
read -r first second _ <<< "$dpkg_line"
## Example first:
## Version:
## Example second:
## 3:0.1-1
first="${first,,}"
## Example first:
## version
if [ "$first" = "version:" ]; then
make_changelog_version="$second"
## Example make_changelog_version:
## 3:0.1-1
make_pkg_revision="${second#*-}"
## Example make_pkg_revision:
## 1
temp="${second%-*}"
## Example temp:
## 3:0.1
make_pkg_version="${temp#*:}"
## Example make_pkg_version:
## 0.1
make_epoch="${second%:*}"
## Example make_epoch:
## 3
break
fi
done < <( dpkg-parsechangelog )
make_pkg_version_with_revision="${make_pkg_version}-${make_pkg_revision}"
if [ "$make_pkg_version" = "" ]; then
true "ERROR: variable make_pkg_version is empty."
exit 1
fi
dpkg_print_architecture="$(dpkg --print-architecture)"
## debian/control:
## Script packages (example: sdwdate):
## Architecture: all
## Compiled packages (example: kloak):
## Architecture: any
local architecture_keyword architecture_setting architecture_grep
if [ "$architecture" = "" ]; then
architecture_grep="$(cat "$make_debian_control_file_absolute_path" | grep "Architecture:")"
read -r architecture_keyword architecture_setting _ <<< "$architecture_grep"
if [ "$architecture_setting" = "" ]; then
true 'ERROR: architecture_grep is empty.'
elif [ "$architecture_setting" = "all" ]; then
architecture="all"
else
architecture="$dpkg_print_architecture"
fi
fi
local grep_line a package
grep_line="$(grep "Source:" "$make_debian_control_file_absolute_path")"
read -r a package _ <<< "$grep_line"
make_source_package_name="$package"
## Source package name may or may not match binary package name.
make_package_list="$make_source_package_name"
make_package_debs_files_list=""
## Example: grep_output
## Package: anon-shared-packages-dependencies
## Package: anon-shared-packages-recommended
while read -r -d $'\n' grep_line; do
read -r a package _ <<< "$grep_line"
temp="${package}_${make_pkg_version}-${make_pkg_revision}_${architecture}.deb"
if [ "$make_use_cowbuilder" = "true" ]; then
temp="$package_build_result_temp_folder/$temp"
else
temp="../$temp"
fi
make_package_debs_files_list="$make_package_debs_files_list $temp"
if [ "$package" = "$make_source_package_name" ]; then
continue
fi
make_package_list="$make_package_list $package"
done < <( grep "Package:" "$make_debian_control_file_absolute_path" )
true "make_package_list: $make_package_list"
true "make_package_debs_files_list: $make_package_debs_files_list"
make_main_deb_file_name="${package}_${make_pkg_version}-${make_pkg_revision}_${architecture}.deb"
make_main_deb_file="../$make_main_deb_file_name"
make_main_dsc_file_name="${make_source_package_name}_${make_pkg_version}-${make_pkg_revision}.dsc"
## TODO: do not hardcode amd64
if [ "$make_use_cowbuilder" = "true" ]; then
make_main_dsc_file="$package_build_pkg_src_temp_folder/$make_main_dsc_file_name"
make_main_changes_file="$package_build_result_temp_folder/${make_source_package_name}_${make_pkg_version}-${make_pkg_revision}_amd64.changes"
else
make_main_dsc_file="../$make_main_dsc_file_name"
make_main_changes_file="../${make_source_package_name}_${make_pkg_version}-${make_pkg_revision}_amd64.changes"
fi
make_debian_tarball_file_name="${make_source_package_name}_${make_pkg_version}-${make_pkg_revision}.debian.tar.xz"
make_debian_tarball="$DISTDIR/$make_debian_tarball_file_name"
if [ "$make_debdist_tolower" = "false" ]; then
true
else
make_debian_tarball_file_name="${make_debian_tarball_file_name,,}"
make_debian_tarball="${make_debian_tarball,,}"
fi
make_debian_tarball_absolute_path="$(realpath "$make_debian_tarball")"
make_upstream_tarball_relative_path_file_name="${make_source_package_name}_${make_pkg_version}.orig.tar.xz"
make_upstream_tarball_relative_path="$DISTDIR/$make_upstream_tarball_relative_path_file_name"
if [ "$make_upstream_tarball_relative_path_tolower" = "false" ]; then
true
else
make_upstream_tarball_relative_path_file_name="${make_upstream_tarball_relative_path_file_name,,}"
make_upstream_tarball_relative_path="${make_upstream_tarball_relative_path,,}"
fi
make_upstream_tarball_real_path="$(realpath "$make_upstream_tarball_relative_path")"
make_upstream_tarball_source_folder_name="${make_source_package_name}-${make_pkg_version}"
}
make_get_destdir() {
if [ "$DESTDIR" = "" ]; then
DESTDIR="/"
fi
if type -t make_hook_at_the_end_of_get_destdir ; then
make_hook_at_the_end_of_get_destdir
fi
}
make_get_distdir() {
if [ "$DISTDIR" = "" ]; then
DISTDIR=".."
fi
}
make_help() {
set +x
echo "\
make help
Show this help.
make dist
Create package-version.tar.xz from source files in \$DISTDIR (default \"..\").
make undist
Delete package-version.tar.xz from source files in \$DISTDIR (default \"..\").
make debdist
Create debian.tar.xz from source files in \$DISTDIR (default \"..\").
make undebdist
Delete debian.tar.xz from source files in \$DISTDIR (default \"..\").
make manpages
Create man page from man source folder, which will be stored in debian/tmp-man folder.
make uch
Store upstream changelog from git log in changelog.upstream.
make install
Copying the files from the source tree to system-wide directories.
make installsim
Simulate copying the files from the source tree to system-wide directories.
make deb-build-dep
Install build dependencies listed in debian/control under Build-Depends using apt-get.
Various environment variables supported.
make deb-run-dep
Install runtime dependencies listed in debian/control under Depends using apt-get.
Various environment variables supported.
make deb-all-dep
Combination of deb-build-dep and deb-build-dep.
make deb-pkg
Create a deb, which will be stored in parent folder.
make deb-pkg-install
Create a deb, which will be stored in parent folder, and install it.
make deb-install
Install deb from parent folder.
make deb-icup
Combination of make deb-pkg, make deb-pkg-install and make deb-pkg-cleanup.
icup stands for install and cleanup.
make deb-remove
apt-get remove make_source_package_name
make deb-purge
apt-get purge make_source_package_name
make deb-clean
Delete temporary debhelper files.
make deb-cleanup
Same as make deb-clean and deletes debuild artifacts from parent folder.
make dput-ubuntu-ppa
Upload to Ubuntu ppa. Requires functional .dput.cf.
make clean
Currently same as make deb-clean.
make distclean
Currently same as make clean.
make checkout
Fetch from git.
make installcheck
Check if source files match installed files.
make uninstallcheck
Check if make uninstall removed all files.
make uninstall
Delete all installed files.
make uninstallsim
Simulate what make uninstall would do.
make deb-chl-bumpup-manual
Manual upstream version number in debian/changelog.
make deb-uachl-bumpup-manual
Combination of make uch and make deb-chl-bumpup.
make deb-chl-bumpup-major
Major bump upstream version number in debian/changelog.
make deb-uachl-bumpup-major
Combination of make uch and make deb-chl-bumpup.
make git-tag-show
echo the current git tag to stdout.
make git-tag-sign
git tag (-s) sign latest pkg_version_with_revision from debian/changelog. Only a repository sanity check. Not for security purposes!
make git-tag-verify
git tag (-v) verify latest pkg_version_with_revision from debian/changelog. Only a repository sanity check. Not for security purposes!
make git-tag-check
Check if current git tag is a signed git tag. Only a repository sanity check. Not for security purposes!
make git-commit-verify
Check if current git head is a signed git commit. Only a repository sanity check. Not for security purposes!
make git-verify
Combination of tag-check and commit-verify. Only a repository sanity check. Not for security purposes!
make git-tag-push
git push latest pkg_version_with_revision from debian/changelog. (Environment variable make_git_tag_push_targets, that defaults to 'origin'.)
make git-tag-show-latest
echo recent git tag to stdout.
make git-tag-push-latest
git push most recent git tag. (Environment variable make_git_tag_push_targets, that defaults to 'origin'.)
make reprepro-add
Add main deb package using reprepro wrapper (Environment variable make_reprepro_wrapper, that default to 'reprepro'.)
to repository (Environment variable make_reprepro_codename, that defaults to 'local'.).
make reprepro-remove
Delete."
}
make_all() {
if [ -f "$PWD/Makefile_orig" ]; then
make -f "$PWD/Makefile_orig" all "$@"
fi
}
make_dist() {
make_function_run make_undist
#find "." -not -iwholename '*.git*' -exec touch --no-dereference --date="Wed Sep 30 16:30:05 UTC 2015" {} +
## No longer using --transform because that does not work with symlinks.
## (Important for 'corridor' package.)
find \
"." \
-not -iwholename '*.git*' \
-print0 \
| tar \
--null \
--no-recursion \
--create \
--verbose \
--owner=0 --group=0 --numeric-owner \
--mode=go=rX,u+rw,a-s \
--sort=name \
--mtime='2015-10-21 00:00Z' \
--xz \
--file="$make_upstream_tarball_real_path" \
-T \
-
strip-nondeterminism "$make_upstream_tarball_real_path"
test -f "$make_upstream_tarball_real_path"
}
make_debdist() {
make_function_run make_undebdist
#find "." -not -iwholename '*.git*' -exec touch --no-dereference --date="Wed Sep 30 16:30:05 UTC 2015" {} +
## Not using `dpkg-source` since that does not support any other output dir than '../'.
find \
debian \
-print0 \
| tar \
--null \
--no-recursion \
--create \
--verbose \
--owner=0 --group=0 --numeric-owner \
--mode=go=rX,u+rw,a-s \
--sort=name \
--mtime='2015-10-21 00:00Z' \
--xz \
--file="$make_debian_tarball_absolute_path" \
-T \
-
strip-nondeterminism "$make_debian_tarball_absolute_path"
test -f "$make_debian_tarball_absolute_path"
}
make_undist() {
make_function_run make_get_distdir
make_function_run make_get_variables
rm --force "$make_upstream_tarball_relative_path"
}
make_undebdist() {
make_function_run make_get_distdir
make_function_run make_get_variables
rm --force "$make_debian_tarball_absolute_path"
}
make_test() {
## Automatically run by debhelper. To prevent debhelper from failing,
## implemented a dummy function here.
true "INFO: $FUNCNAME not implemented"
}
make_manpages() {
shopt -s globstar dotglob nullglob
local i source_folder filename_without_ronn_file_extension base_name
for i in "$PWD/man/"*".ronn"; do
if [ -d "$i" ]; then
continue
fi
base_name="${i##*/}"
filename_without_ronn_file_extension="${base_name%.*}"
mkdir --parents "$PWD/debian/tmp-man/$source_folder"
true "${bold}${cyan}INFO: Creating man page $PWD/debian/tmp-man/$filename_without_ronn_file_extension ${reset}"
ronn \
--manual="orjail Documentation" \
--organization="orjail" \
< "$i" \
> "$PWD/debian/tmp-man/$filename_without_ronn_file_extension"
done
shopt -u globstar dotglob nullglob
}
make_uch() {
git log > "$PWD/changelog.upstream"
test -f "$PWD/changelog.upstream"
}
make_clean() {
if [ -f "$PWD/Makefile_orig" ]; then
make -f "$PWD/Makefile_orig" clean
fi
make_function_run make_deb-clean
}
make_deb-shared-dep() {
local apt_get_exit_code="0"
sudo \
apt-get \
${APTGETOPT[@]} \
$apt_sourcelist_empty \
$apt_sourceparts \
$apt_unattended_opts \
--yes \
--no-install-recommends \
install \
$make_deb_shared_dependencies \
|| { apt_get_exit_code="$?" ; true; };
exit "$apt_get_exit_code"
}
make_deb-build-dep() {
make_function_run make_get_variables
make_deb_shared_dependencies="$make_deb_build_dependencies"
make_function_run make_deb-shared-dep
}
make_deb-run-dep() {
make_function_run make_get_variables
make_deb_shared_dependencies="$make_deb_runtime_dependencies"
make_function_run make_deb-shared-dep
}
make_deb-all-dep() {
make_function_run make_get_variables
make_deb_shared_dependencies="$make_deb_build_dependencies $make_deb_runtime_dependencies"
make_function_run make_deb-shared-dep
}
make_deb-pkg_shared() {
if [ "$make_use_cowbuilder" = "true" ]; then
make_function_run make_get_variables
mkdir -p "$package_build_result_temp_folder"
mkdir -p "$package_build_pkg_src_temp_folder"
DISTDIR="$package_build_pkg_src_temp_folder"
make_function_run make_deb-cleanup
make_function_run make_dist
make_function_run make_debdist
pushd "$package_build_pkg_src_temp_folder"
## Creates make_main_dsc_file.
dpkg-source \
-c"$make_debian_control_file_absolute_path" \
-l"$make_debian_changelog_file_absolute_path" \
--format="3.0 (custom)" \
--target-format="3.0 (quilt)" \
-b / \
"$make_debian_tarball_absolute_path" \
"$make_upstream_tarball_real_path"
test -f "$make_main_dsc_file"
true "COWBUILDER_PREFIX: $COWBUILDER_PREFIX"
if [ ! "$whonix_build_apt_stable_release" = "" ]; then
[ -n "$make_cowbuilder_distribution" ] || make_cowbuilder_distribution="$whonix_build_apt_stable_release"
else
[ -n "$make_cowbuilder_distribution" ] || make_cowbuilder_distribution="$(lsb_release --short --codename)"
fi
## Whonix build script sets variable `make_cowbuilder_mirror`.
if [ ! "$whonix_build_apt_sources_mirror" = "" ]; then
[ -n "$make_cowbuilder_mirror" ] || make_cowbuilder_mirror="$whonix_build_apt_sources_mirror"
else
## apt-cacher-ng support
if [ "$REPO_PROXY" = "http://127.0.0.1:3142" ]; then
[ -n "$make_cowbuilder_mirror" ] || make_cowbuilder_mirror="http://HTTPS///deb.debian.org/debian"
fi
if [ "$REPO_PROXY" = "http://127.0.0.1:3142/" ]; then
[ -n "$make_cowbuilder_mirror" ] || make_cowbuilder_mirror="http://HTTPS///deb.debian.org/debian"
fi
[ -n "$make_cowbuilder_mirror" ] || make_cowbuilder_mirror="https://deb.debian.org/debian"
fi
## COWBUILDER_PREFIX could set variables such as http_proxy.
## Whonix build script sets:
## COWBUILDER_PREFIX+=" env http_proxy=${REPO_PROXY}"
## which results in:
## sudo env http_proxy=http://127.0.0.1:3142 cowbuilder [...]
sudo \
$COWBUILDER_PREFIX \
cowbuilder \
--build "$make_main_dsc_file" \
--distribution "$make_cowbuilder_distribution" \
--mirror "$make_cowbuilder_mirror" \
--extrapackages "$make_deb_build_dependencies" \
--buildresult "$package_build_result_temp_folder"
popd
else
make_function_run make_deb-cleanup
make_function_run make_dist
if ! command -v debuild >/dev/null ; then
true "ERROR: debuild not found. Do you have the 'devscripts' package installed?
To install all dependencies, try running:
sudo make deb-all-dep
"
exit 1
fi
if ! dpkg-checkbuilddeps ; then
true "ERROR: dpkg-checkbuilddeps reported missing build dependencies.
To install all dependencies, try running:
sudo make deb-all-dep
"
exit 1
fi
## Using --no-lintian, because debuild does not exist with a non-zero exit
## code, should lintian find an error. Therefore running lintian afterwards.
debuild \
--no-lintian \
-sa \
$make_debuild_maybe_unsigned_opts \
"$@"
fi
if [ "$make_use_lintian" = "false" ]; then
true "INFO: make_use_lintian=false - skipping lintian."
elif [ "$make_use_lintian" = "true" ]; then
true "INFO: make_use_lintian=true - running lintian..."
make_function_run make_lintian
else
true "INFO: make_use_lintian='' - Autodetecting if lintian is installed..."
if command -v lintian >/dev/null 2>&1 ; then
true "INFO: lintian auto detected, using it..."
make_function_run make_lintian
else
true "INFO: lintian not installed, skipping."
fi
fi
if [ "$make_use_debsign" = "true" ]; then
debsign $make_debsign_opts "$make_main_changes_file"
## sanity test
gpg --verify "$make_main_changes_file"
fi
for package in $make_package_debs_files_list; do
test -f "$package"
true "INFO: You can find your deb file here: $package"
done
}
make_lintian_on_warning() {
if [ "$make_use_lintian" = "true" ]; then
true "ERROR: lintian warning. Failing closed."
if [ "$make_lintian_exit_code" = "0" ]; then
exit 1
else
exit "$make_lintian_exit_code"
fi
else
true "WARNING: lintian warning. Failing open."
fi
}
make_lintian() {
test -f "$make_main_changes_file"
if [ "$DEBUILD_LINTIAN_OPTS" = "" ]; then
export DEBUILD_LINTIAN_OPTS="--quiet --pedantic --info --display-info"
fi
local make_lintian_exit_code="0"
lintian_output="$(lintian $genmkfile_lintian_pre_opts $DEBUILD_LINTIAN_OPTS $genmkfile_lintian_post_opts "$make_main_changes_file" 2>&1 || { make_lintian_exit_code="$?" ; true; };)"
if [ ! "" = "$lintian_output" ]; then
make_lintian_on_warning
fi
if [ ! "$make_lintian_exit_code" = "0" ] ; then
make_lintian_on_warning
fi
true "INFO: lintian ok."
}
make_deb-pkg() {
make_debuild_maybe_unsigned_opts="-us -uc"
make_function_run make_deb-pkg_shared "$@"
}
make_deb-pkg-signed() {
make_use_debsign="true"
make_function_run make_deb-pkg_shared "$@"
}
make_deb-pkg-source() {
make_debuild_maybe_unsigned_opts="-S"
make_function_run make_deb-pkg_shared "$@"
}
make_deb-install() {
local package
make_function_run make_get_variables
for package in $make_package_debs_files_list; do
if [ ! -f "$package" ]; then
true "ERROR: File $package does not exist. Have you run \"make deb-pkg\" already?"
exit 1
fi
sudo dpkg -i "$package"
done
}
make_deb-remove() {
make_function_run make_get_variables
sudo apt-get remove "$make_source_package_name"
}
make_deb-purge() {
make_function_run make_get_variables
sudo apt-get purge "$make_source_package_name"
}
make_deb-pkg-install() {
make_function_run make_deb-pkg
make_function_run make_deb-install
}
make_deb-icup() {
make_function_run make_deb-pkg-install
make_function_run make_deb-cleanup
}
make_deb-clean() {
make_function_run make_get_variables
if [ -d "debian/tmp" ]; then
rm --recursive "debian/tmp"
fi
if [ -d "debian/tmp-man" ]; then
rm --recursive "debian/tmp-man"
fi
if [ -d "deb_dist" ]; then
rm --recursive "deb_dist"
fi