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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029
|
% This file was generated with po4a. Translate the source file.
%
\documentclass[10pt,final]{beamer}
\mode<presentation> \usetheme{debian}
\usepackage{debiantutorial.zh_TW}\hypersetup{unicode}\usepackage[whole]{bxcjkjatype}\setminchofont{DroidSansFallbackFull.ttf}\setgothicfont{DroidSansFallbackFull.ttf}
\hypersetup{bookmarks}
\title{Debian 套件打包教學指南}
\author[]{Lucas Nussbaum\\{\small\texttt{packaging-tutorial@packages.debian.org}}}
\date{\footnotesize version 0.29 -- 2021-11-03}
\begin{document}
\frame{\titlepage}
\begin{frame}{關於此教學指南}
\begin{itemize}
\item 目標: \textbf{瞭解 Debian 套件打包的相關知識}
\begin{itemize}
\hbr
\item 修改既有套件
\hbr
\item 新增自有套件
\hbr
\item 和 Debian 社群進行交流
\hbr
\item 成為 Debian 進階使用者
\end{itemize}
\br
\item 這份教學指南針對重要功能進行介紹, 但也許會有疏漏之處
\begin{itemize}
\item 所以你需要閱讀更多文件
\end{itemize}
\br
\item 文件大部份的內容也適用於 Debian 衍生的 Linux發行版
\begin{itemize}
\hbr
\item 其中包含 Ubuntu
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{大綱}
\tableofcontents[hideallsubsections]
\end{frame}
\section{介紹}
\subsection{Debian}
\begin{frame}{Debian}
\begin{itemize}
\item \textbf{GNU/Linux 發行版}
\br
\item 第一個以 GNU 開源精神進行開發的主要發行版
\br
\item \textbf{非營利}, 由超過1000個志願者協同開發而成
\br
\item 三個主要特色:
\begin{itemize}
\item \textbf{品質} -- 卓越的技術文化\\ {\small\sl 準備好才會發行}
\hbr
\item \textbf{自由} -- 開發者以及使用者皆遵循 \textsl{社會契約}\\ 並發揚自1993年起開始倡導的自由軟體文化
\hbr
\item \textbf{獨立} -- Debian 不被任何一間公司所擁有\\ 決策過程一切透明化 (\textsl{行動至上} + \textsl{民主})
\end{itemize}
\br
\item 對於\textbf{業餘開發者} 來說最大的意義: 因本身喜愛而去完成這些事
\end{itemize}
\end{frame}
\subsection{Debian 套件}
\begin{frame}{Debian 套件}
\begin{itemize}
\item \textbf{.deb} 檔案 (二進制 套件)
\br
\item 以有效且合宜的方法來向使用者發佈軟體
\br
\item 是兩個最常見的套件格式之一 (另一個為 RPM)
\br
\item 一般來說:
\begin{itemize}
\item Debian 有 30,000 個二進制套件\\ $\rightarrow$ 絕大部份的自由軟體皆已經打包並放進 Debian!
\hbr
\item 支援 12 種 CPU 架構, 其中包含 2 個非 Linux 相關(Hurd; KFreeBSD)
\hbr
\item Debian 被其衍生120個發行版所使用
\end{itemize}
\end{itemize}
\end{frame}
\subsection{Deb 套件格式}
\begin{frame}[fragile=singleslide]{Deb 套件格式}
\begin{itemize}
\item \texttt{.deb} 檔案: 是 \texttt{ar} 靜態函式庫格式
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ ar tv wget_1.12-2.1_i386.deb
rw-r--r-- 0/0 4 Sep 5 15:43 2010 debian-binary
rw-r--r-- 0/0 2403 Sep 5 15:43 2010 control.tar.gz
rw-r--r-- 0/0 751613 Sep 5 15:43 2010 data.tar.gz
\end{lstlisting} \begin{itemize}
\item \texttt{debian-binary}: deb檔案格式的版本, \texttt{"2.0\textbackslash{}n"}
\item \texttt{control.tar.gz}: 描述套件相關資訊的檔案\\ {\small \texttt{\textbf{control},
md5sums, (pre|post)(rm|inst), triggers, shlibs}, \ldots}
\item \texttt{data.tar.gz}: 套件裡的資料
\end{itemize}
\br
\item 你可以手動製作 \texttt{.deb} 檔案 \\ {\footnotesize
\url{http://tldp.org/HOWTO/html\_single/Debian-Binary-Package-Building-HOWTO/}}
\br
\item 但大部份的人不會使用那種方法
\end{itemize}
\br
\centerline{\textbf{這份教學指南: 以 Debian 風格來製作 Debian 套件}}
\end{frame}
\subsection{開發必需之工具}
\begin{frame}{開發必需之工具}
\begin{itemize}
\item 一台能以 root 權限存取的 Debian (or Ubuntu) 系統
\br
\item 一些必需套件:
\begin{itemize}
\item \textbf{build-essential}: 和 Debian 套件有相依性並假定已安裝在開發者的機器上 (不需在套件中的 control
欄位特別指定 \texttt{Build-Depends:} )
\begin{itemize}
\item 相依 \textbf{dpkg-dev} 套件, 其中包含基本 Debian 特定工具, 以便於製作 Debian 套件
\end{itemize}
\hbr
\item \textbf{devscripts}: 此套件提供許多便於開發的腳本給 Debian 維護者
\end{itemize}
\end{itemize}
\br
還有一些接著會提到的工具, 比如說 \textbf{debhelper}, \textbf{cdbs}, \textbf{quilt},
\textbf{pbuilder}, \textbf{sbuild}, \textbf{lintian},
\textbf{svn-buildpackage}, \textbf{git-buildpackage},
\ldots\\當需要使用時,可安裝上述套件.
\end{frame}
\subsection{一般打包套件的流程}
\begin{frame}{一般打包套件的流程}
\begin{center}
\begin{tikzpicture}[
node1/.style={shape=rectangle,draw=rouge,fill=debianbackgroundblue,thick},
arr/.style={very thick}, command/.style={text=rouge,font=\ttfamily}, ]
\node[node1] (www) at (0, 0) {Web}; \node[node1] (us) at (2.5, 0) {上游程式碼};
\node[node1] (da) at (-2.5, 0) {Debian 鏡像站}; \node[node1] (sp) at (0, -2)
{原始程式套件}; \draw[arr,<-,dashed,thick] (sp) -- (2.5,-2) node[right=0cm,text
width=2.98cm,text centered,font=\small\sl] {這階段會完成大部份手動操作}; \node[node1]
(bin) at (0, -4) {一個或多個二進制套件}; \draw[arr,<-,dashed,thick] (bin) -- (3.5,-4)
node[right,text centered,font=\small\ttfamily\sl] {.deb\normalfont};
\draw[arr,->] (us) -- (sp) node[pos=0.5,right,command] {dh\_make};
\draw[arr,->] (da) -- (sp) node[pos=0.5,left,command] {apt-get source};
\draw[arr,->] (www) -- (sp) node[pos=0.5,left,command] {dget}; \draw[arr,->]
(sp) -- (bin) node[pos=0.5,right,text width=6cm] {\textttc{debuild}
(透過\textttc{lintian}建立並測試套件) 或者 \textttc{dpkg-buildpackage}}; \draw[arr,->]
(bin) -- (1,-6) node[pos=0.5,right] {安裝(\textttc{debi})}; \draw[transparent]
(bin) -- (-1,-6) node[pos=0.5,left,opaque] {上傳(\textttc{dput})};
\draw[arr,->,rounded corners] (bin) -- (-1,-6) -- (-4.5,-6) -- (-4.5,0) --
(da); \useasboundingbox (-4,-6) rectangle (6,0); \end{tikzpicture}
\end{center}
\end{frame}
\subsection{重包 dash 套件}
\begin{frame}{範例: 重包 dash 套件}
\begin{enumerate}
\item 安裝重包 dash 套件所需的必要套件以及 devscripts 套件\\ {\texttt{sudo apt-get build-dep
dash}\\ (需要將\texttt{deb-src} 設定到 \texttt{/etc/apt/sources.list})}\\
{\texttt{sudo apt-get install -{}-no-install-recommends devscripts
fakeroot}}
\hbr
\item 創建並進入一個工作目錄:\\ \texttt{mkdir /tmp/debian-tutorial ; cd /tmp/debian-tutorial}
\hbr
\item 把 \texttt{dash} 原始碼套件下載下來\\ \texttt{apt-get source dash}\\ {\small (務必確保
\texttt{deb-src} 已加入 \texttt{/etc/apt/sources.list})}
\hbr
\item 構建套件\\ {\texttt{cd dash-*\\ debuild -us -uc}} ~~~(\texttt{-us -uc}
代表不使用GPG來簽署套件)
\hbr
\item 確認已正常運行
\begin{itemize}
\item 會看到一些新產生的 \texttt{.deb} 檔案在上一層資料夾中
\end{itemize}
\hbr
\item 接著看\texttt{debian/} 目錄
\begin{itemize}
\item 這是實際打包套件的地方
\end{itemize}
\end{enumerate}
\end{frame}
\section{製作原始碼套件}
\subsection{原始碼套件基礎知識}
\begin{frame}{原始碼套件}
\begin{itemize}
\item 一個原始碼套件可產生多個二進制套件\\ {\small 舉例來說 \texttt{\bfseries libtar} 原始碼會產出
\texttt{\bfseries libtar0} 跟 \texttt{\bfseries libtar-dev} 二進制套件} \hbr
\item 套件分成兩種類型: (若不確定套件種類屬於哪一種, 請使用非原生)
\begin{itemize}
\small
\item 原生套件: 通常指的是在 Debian 上固有的特定軟體(\textsl{dpkg}, \textsl{apt})
\item 非原生套件: 在 Debian 以外發展的軟體
\end{itemize}
\hbr
\item 主要檔案: \texttt{.dsc} (描述資料內容)
\hbr
\item 其他檔案則相依於原始碼格式版本
\begin{itemize}
\item 1.0 or 3.0 (原生): \texttt{package\_version.tar.gz}
\hbr
\item 1.0 (非原生):
\begin{itemize}
\item \texttt{pkg\_ver.orig.tar.gz}: 上游原始碼
\item \texttt{pkg\_debver.diff.gz}: 針對 Debian 環境而進行客制修改的補丁
\end{itemize}
\hbr
\item 3.0 (quilt):
\begin{itemize}
\item \texttt{pkg\_ver.orig.tar.gz}: 上游原始碼
\item \texttt{pkg\_debver.debian.tar.gz}: 針對 Debian 環境而進行客制修改的 tarball 檔
\end{itemize}
\end{itemize}
\end{itemize}
\hbr
(可參考\texttt{dpkg-source(1)} 有更詳盡的解說)
\end{frame}
\begin{frame}[fragile=singleslide]{原始碼套件範例}
\begin{lstlisting}[basicstyle=\ttfamily\small]
Format: 3.0 (quilt)
Source: wget
Binary: wget
Architecture: any
Version: 1.12-2.1
Maintainer: Noel Kothe <noel@debian.org>
Homepage: http://www.gnu.org/software/wget/
Standards-Version: 3.8.4
Build-Depends: debhelper (>> 5.0.0), gettext, texinfo,
libssl-dev (>= 0.9.8), dpatch, info2man
Checksums-Sha1:
50d4ed2441e67[..]1ee0e94248 2464747 wget_1.12.orig.tar.gz
d4c1c8bbe431d[..]dd7cef3611 48308 wget_1.12-2.1.debian.tar.gz
Checksums-Sha256:
7578ed0974e12[..]dcba65b572 2464747 wget_1.12.orig.tar.gz
1e9b0c4c00eae[..]89c402ad78 48308 wget_1.12-2.1.debian.tar.gz
Files:
141461b9c04e4[..]9d1f2abf83 2464747 wget_1.12.orig.tar.gz
e93123c934e3c[..]2f380278c2 48308 wget_1.12-2.1.debian.tar.gz
\end{lstlisting}
\end{frame}
\subsection{取回原始碼套件}
\begin{frame}{取回一個既有的原始碼套件}
\begin{itemize}
\item 從 Debian 檔案庫裡面下載:
\begin{itemize}
\item \texttt{apt-get source \textsl{package}}
\item \texttt{apt-get source \textsl{package=version}}
\item \texttt{apt-get source \textsl{package/release}}
\end{itemize}
(需要加入 \texttt{deb-src} 的設定到 \texttt{sources.list})
\br
\item 透過網路下載:
\begin{itemize}
\item \texttt{dget \textsl{url-to.dsc}}
\item \texttt{dget
http://snapshot.debian.org/archive/debian-archive/\\20090802T004153Z/debian/dists/bo/main/source/web/\\
wget\_1.4.4-6.dsc}\\ (\href{http://snapshot.debian.org/}{\ttfamily
snapshot.d.o} 提供 自2005年開始的 Debian套件)
\end{itemize}
\br
\item 透過 Debian 版本控制系統下載:
\begin{itemize}
\item \texttt{debcheckout \textsl{package}}
\end{itemize}
\br
\item 下載後, 使用 \texttt{dpkg-source -x \textsl{file.dsc}}解壓縮即可
\end{itemize}
\end{frame}
\subsection{創建一個基本原始碼套件}
\begin{frame}{創建一個基本原始碼套件}
\begin{itemize}
\item 從上游下載原始碼\\ (\textsl{上游原始碼} = 來自軟體原始開發者)
\hbr
\item 將檔案改名成
\texttt{<\textsl{source\_package}>\_<\textsl{upstream\_version}>.orig.tar.gz}\\
(範例: \texttt{simgrid\_3.6.orig.tar.gz})
\hbr
\item 解開此 tar 檔
\hbr
\item 將目錄改名為 \texttt{<\textsl{source\_package}>-<\textsl{upstream\_version}>}\\
(範例: \texttt{simgrid-3.6})
\hbr
\item \texttt{cd \texttt{<\textsl{source\_package}>-<\textsl{upstream\_version}>}
\&\& dh\_make}\\ (來自 \textbf{dh-make} 套件)
\hbr
\item 對於特定套件, 有除了 \texttt{dh\_make} 以外的方法, 舉例為: \textbf{dh-make-perl},
\textbf{dh-make-php}, \ldots \hbr
\item 已新增\texttt{debian/} 目錄, 裡面有許多檔案
\end{itemize}
\end{frame}
\subsection{在 debian/ 裡的檔案}
\begin{frame}{在 debian/ 裡的檔案}
透過修改 \texttt{debian/} 中的檔案來定義所有打包的動作
\hbr
\begin{itemize}
\item 主要的檔案:
\begin{itemize}
\item \textbf{control} -- 描述套件相關資訊的檔案 (相依性, 等等...)
\item \textbf{rules} -- 定義如何構建此套件
\item \textbf{copyright} -- 關於此套件的版權宣告
\item \textbf{changelog} --有關此 Debian 套件的修改歷程
\end{itemize}
\hbr
\item 其他檔案:
\begin{itemize}
\item compat
\item watch
\item dh\_install* targets\\ {\small *.dirs, *.docs, *.manpages, \ldots}
\item 維護者所使用的腳本\\ {\small *.postinst, *.prerm, \ldots}
\item source/format
\item patches/ -- 如果你需要修改上游原始碼
\end{itemize}
\hbr
\item 許多檔案的格式都是基於 RFC 822 (信的表頭)
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{debian/changelog}
\begin{itemize}
\item 列出 Debian 套件的修改歷程
\item 訂定現在的套件版本
\begin{center}
\begin{tikzpicture}
\draw (0,0) node[above right] {\large 1.2.1.1-5}; \draw
[decorate,decoration={brace}] (2,0) -- (1.45,0) node[at start,below,text
width=1.6cm,text centered] {\small Debian 修訂版}; \draw
[decorate,decoration={brace}] (1.4,0) -- (0,0) node[midway,below,text
width=1.6cm,text centered] { \small 上游版本};
\end{tikzpicture}
\end{center}
\item 可以手動編輯或者透過 \textttc{dch}
\begin{itemize}
\item 為一個新的發行版創建一條歷程記錄\textttc{dch -i}
\end{itemize}
\item 具備特殊格式並自動將 Debian 或 Ubuntu 的缺陷結案\\ Debian: \texttt{Closes:~\#595268};
Ubuntu: \texttt{LP:~\#616929}
\item 安裝在 \texttt{/usr/share/doc/\textit{package}/changelog.Debian.gz}
\end{itemize}
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
mpich2 (1.2.1.1-5) unstable; urgency=low
* Use /usr/bin/python instead of /usr/bin/python2.5. Allow
to drop dependency on python2.5. Closes: #595268
* Make /usr/bin/mpdroot setuid. This is the default after
the installation of mpich2 from source, too. LP: #616929
+ Add corresponding lintian override.
-- Lucas Nussbaum <lucas@debian.org> Wed, 15 Sep 2010 18:13:44 +0200
\end{lstlisting}
\end{frame}
\begin{frame}[fragile=singleslide]{debian/control}
\hbr
\begin{itemize}
\item 描述套件相關資訊的檔案
\begin{itemize}
\item 對於原始碼套件本身
\item 對於每個從原始碼套件建置而成的二進制套件
\end{itemize}
\hbr
\item 套件名稱, 種類, 優先度, 維護者, 上傳者, 建置相依性, 相依性, 相關描述, 網頁 \hbr
\item 相關文件: Debian Policy 第 5 章\\
\url{https://www.debian.org/doc/debian-policy/ch-controlfields}
\end{itemize}
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
Source: wget
Section: web
Priority: important
Maintainer: Noel Kothe <noel@debian.org>
Build-Depends: debhelper (>> 5.0.0), gettext, texinfo,
libssl-dev (>= 0.9.8), dpatch, info2man
Standards-Version: 3.8.4
Homepage: http://www.gnu.org/software/wget/
Package: wget
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: retrieves files from the web
Wget is a network utility to retrieve files from the Web
\end{lstlisting}
\end{frame}
\begin{frame}{Architecture: all or any}
有兩種二進制套件:
\hbr
\begin{itemize}
\item 套件內容會隨著不同的 Debian 平台架構而有所差異
\begin{itemize}
\item 範例: C 程式
\item \texttt{debian/control} 中描述 \texttt{Architecture:\ any}
\begin{itemize}
\item 或者只運行在某些特定的平台架構中:\\ \texttt{Architecture:\ amd64 i386 ia64 hurd-i386}
\end{itemize}
\item buildd.debian.org: 上傳後會自動構建其他架構的套件
\item 命名為\texttt{\textsl{package}\_\textsl{version}\_\textsl{architecture}.deb}
\end{itemize}
\br
\item 套件內容在不同的 Debian 平台架構上皆相同
\begin{itemize}
\item 範例: Perl 函式庫
\item \texttt{debian/control} 中描述 \texttt{Architecture:\ all}
\item 命名為\texttt{\textsl{package}\_\textsl{version}\_\textbf{all}.deb}
\end{itemize}
\end{itemize}
\br
一個原始碼套件可以產生多個平台架構 \texttt{Architecture:\ any} 以及 \texttt{Architecture:\ all}
二進制套件
\end{frame}
\begin{frame}[fragile=singleslide]{debian/rules}
\hbr
\begin{itemize}
\item Makefile
\br
\item 構建 Debian 套件的介面
\br
\item 詳細文件在 Debian Policy, 章節 4.8中\\ {\small
\url{https://www.debian.org/doc/debian-policy/ch-source\#s-debianrules}}
\br
\item 必要的 targets:
\begin{itemize}
\item \texttt{build, build-arch, build-indep}: 必須執行所有設定並進行編譯
\hbr
\item \texttt{binary, binary-arch, binary-indep}: 構建二進制套件
\begin{itemize}
\item \texttt{dpkg-buildpackage} 會呼叫 \texttt{binary} 構建所有套件, 或者呼叫
\texttt{binary-arch} 構建特定 \texttt{Architecture:~any} 套件
\end{itemize}
\hbr
\item \texttt{clean}: 清理原始碼目錄
\end{itemize}
\end{itemize}
\end{frame}
\subsection{協助打包的幫手}
\begin{frame}{協助打包的幫手 -- debhelper}
\begin{itemize}
\item 可以直接在 \texttt{debian/rules} 中撰寫 shell code
\item 然而更好的作法 (被大部份套件所採用): 使用 \textsl{打包幫手}
\item 最常見的方法: \textbf{debhelper} (大約被 98\% 的套件所採用)
\item 目標:
\begin{itemize}
\item 將常使用的任務拆解, 並轉化為標準工具, 最後適用於所有套件上
\item 當修正打包錯誤時, 可以適用於所有的套件
\end{itemize}{\footnotesize dh\_installdirs, dh\_installchangelogs, dh\_installdocs,
dh\_install, dh\_installdebconf, dh\_installinit, dh\_link, dh\_strip,
dh\_compress, dh\_fixperms, dh\_perl, dh\_makeshlibs, dh\_installdeb,
dh\_shlibdeps, dh\_gencontrol, dh\_md5sums, dh\_builddeb, \ldots}
\begin{itemize}
\item 由 \texttt{debian/rules} 所呼叫
\item 透過 \texttt{debian/}中的指令參數或檔案來進行配置的動作
\end{itemize}{\footnotesize \ttfamily \textsl{package}.docs, \textsl{package}.examples,
\textsl{package}.install, \textsl{package}.manpages, \ldots} \hbr
\item 有第三方小幫手可以協助打包套件: \textbf{python-support}, \textbf{dh\_ocaml}, \ldots \hbr
\item \texttt{debian/compat}: Debhelper 相容性版本
\begin{itemize}
\item 定義 dh\_* 明確行為
\item 新語法: \texttt{Build-Depends: debhelper-compat (= 13)}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{debian/rules 使用 debhelper (1/2)}
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize,escapeinside=\{\}]
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
build:
$(MAKE)
#docbook-to-man debian/packagename.sgml > packagename.1
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
$(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/packagename.
$(MAKE) DESTDIR=$(CURDIR)/debian/packagename install
\end{lstlisting}
\end{frame}
\begin{frame}[fragile=singleslide]{debian/rules using debhelper (2/2)}
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize,escapeinside=\{\}]
# Build architecture-independent files here.
binary-indep: build install
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
\end{lstlisting}
\end{frame}
\begin{frame}[fragile=singleslide]{CDBS}
\hbr
\begin{itemize}
\item 即使在套件裡使用 debhelper, 還是會有冗餘的事情要處理
\hbr
\item 第二層的小幫手能夠拆解共同的功能
\begin{itemize}
\item 舉例: 使用 \texttt{./configure \&\& make \&\& make install} 或者 CMake 進行建構
\end{itemize}
\hbr
\item CDBS:
\begin{itemize}
\item 源自 2005, 基於 advanced \textsl{GNU make} magic
\item 文件: \texttt{/usr/share/doc/cdbs/}
\item 可支援 Perl, Python, Ruby, GNOME, KDE, Java, Haskell, \ldots
\item 但有些使用者不喜歡使用:
\begin{itemize}
\item 有時難以產生客製化套件:\\ "\textsl{makefile以及環境參數相當複雜}"
\item 比明文的 debhelper還慢 (會有許多不必要 \texttt{dh\_*}相關的呼叫)
\end{itemize}
\end{itemize}
\end{itemize}
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize,escapeinside=\{\}]
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
# add an action after the build
build/mypackage::
/bin/bash debian/scripts/foo.sh
\end{lstlisting}
\end{frame}
\begin{frame}[fragile=singleslide]{Dh (又名 Debhelper 7, 或者 dh7)}
\begin{itemize}
\item 源自2008年, 預期 \textsl{取代CDBS }
\hbr
\item \textbf{dh} 指令呼叫 \texttt{dh\_*}
\hbr
\item 簡易化 \textsl{debian/rules}, 只列出需覆蓋的地方
\hbr
\item 比 CDBS 更容易進行客製化
\hbr
\item 文件: manpages (\texttt{debhelper(7)}, \texttt{dh(1)}) + DebConf9 的簡報投影片\\
\url{http://kitenet.net/~joey/talks/debhelper/debhelper-slides.pdf}
\end{itemize}
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- --with-kitchen-sink
override_dh_auto_build:
make world
\end{lstlisting}
\end{frame}
\begin{frame}{Classic debhelper vs CDBS vs dh}
\hbr
\begin{itemize}
\item 心佔率:\\ Classic debhelper: 15\% \hskip 1em CDBS: 15\% \hskip 1em dh: 68\%
\hbr
\item 究竟該採用哪一種方法呢?
\begin{itemize}
\item 或許每一種都需要瞭解
\item 必須瞭解 debhelper 以使用 dh 以及 CDBS
\item 你也許需要修改 CDBS 套件
\end{itemize}
\hbr
\item 對於新套件, 該使用哪一種方法呢?
\begin{itemize}
\item \textbf{dh} (只有它的心佔率是呈現上升)
\item 參考 \url{https://trends.debian.net/\#build-systems}
\end{itemize}
\end{itemize}
\hbr
\end{frame}
\section{構建並測試套件}
\subsection{構建套件}
\begin{frame}{構建套件}
\begin{itemize}
\item \textttc{apt-get build-dep mypackage}\\ 安裝 \textsl{build-dependencies}
(適用於套件已在 Debian 中)\\ 或者 \textttc{mk-build-deps -ir} (適用於套件尚未上傳到 Debian 中)
\br
\item \textttc{debuild}: 透過 \texttt{lintian} 進行構建, 測試, 並使用 GPG 進行簽署
\br
\item 又或者可以直接呼叫 \textttc{dpkg-buildpackage}
\begin{itemize}
\item 通常使用 \texttt{dpkg-buildpackage -us -uc}
\end{itemize}
\br
\item 在小型且乾淨環境中構建套件較為適合
\begin{itemize}
\item \textttc{pbuilder} -- 使用 \textsl{chroot}來協助構建套件好的文件:
\url{https://wiki.ubuntu.com/PbuilderHowto}\\ (最佳化: \textttc{cowbuilder}
\textttc{ccache} \textttc{distcc})
\hbr
\item \textttc{schroot} 和 \textttc{sbuild}: 被 Debian build daemons 所使用\\ (不若
\texttt{pbuilder} 簡單, 但能使用 LVM 快照功能\\ 參照:
\url{https://help.ubuntu.com/community/SbuildLVMHowto} )
\end{itemize}
\br
\item 產生 \texttt{.deb} 檔案以及 \texttt{.changes} 檔案
\begin{itemize}
\item \texttt{.changes}: 描述構建哪些東西; 用來上傳套件
\end{itemize}
\end{itemize}
\end{frame}
\subsection{安裝以及測試套件}
\begin{frame}{安裝以及測試套件}
\begin{itemize}
\item 本地安裝套件: \textttc{debi} (使用\texttt{.changes} 來得知需安裝哪些) \br
\item 列出套件的內容: \texttt{{\color{rouge}debc} ../mypackage<TAB>.changes} \br
\item 和前一版的套件比較:\\ \texttt{{\color{rouge}debdiff} ../mypackage\_1\_*.changes
../mypackage\_2\_*.changes}\\ 或比較原始碼差異:\\ \texttt{{\color{rouge}debdiff}
../mypackage\_1\_*.dsc ../mypackage\_2\_*.dsc}\\
\br
\item 透過 \texttt{lintian} (靜態分析工具): 來確認套件\\ \texttt{{\color{rouge}lintian}
../mypackage<TAB>.changes}\\ \texttt{lintian -i}: 提示更多錯誤訊息 \\
\texttt{lintian -EviIL +pedantic}: 顯示更多問題\br
\item 上傳套件到 Debian (\textttc{dput}) (需要設定) \br
\item 可透過 \textttc{reprepro}的指令管理私有Debian 檔案庫\\ 文件:
\url{https://mirrorer.alioth.debian.org/}
\end{itemize}
\end{frame}
\section{實際演練 1: 修改 grep 套件}
\begin{frame}{實際演練 1: 修改 grep 套件}
\begin{enumerate}
\item 前往 \url{http://ftp.debian.org/debian/pool/main/g/grep/} 並且下載版本 2.12-2 的套件
\begin{itemize}
\item 如果原始碼套件沒有自動解開, 請使用下列指令 \texttt{dpkg-source~-x~grep\_*.dsc}
\end{itemize}
\item 注意 \texttt{debian/}中的檔案.
\begin{itemize}
\item 原始碼套件產生多少二進制套件?
\item 這個套件使用哪一種打包小幫手?
\end{itemize}
\hbr
\item 構建套件
\hbr
\item 先修改套件. 並在changelog中添加一個條目並且遞增版本號碼.
\hbr
\item 接著將 perl-regexp 功能移除 (位於 \texttt{./configure} 中的選項)
\hbr
\item 重新構建套件
\hbr
\item 使用 debdiff 來比較原始和新套件中差異
\hbr
\item 安裝新構建的套件
\end{enumerate}
\end{frame}
\section{進階打包主題}
\subsection{debian/copyright}
\begin{frame}[fragile=singleslide]{debian/copyright}
\hbr
\begin{itemize}
\item 原始碼以及打包的著作權和授權條款資訊
\item 一般都是以 text 檔案格式編寫
\item 新的機器可讀格式
{\small\url{https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/}}
\end{itemize}
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: X Solitaire
Source: ftp://ftp.example.com/pub/games
Files: *
Copyright: Copyright 1998 John Doe <jdoe@example.com>
License: GPL-2+
This program is free software; you can redistribute it
[...]
.
On Debian systems, the full text of the GNU General Public
License version 2 can be found in the file
`/usr/share/common-licenses/GPL-2'.
Files: debian/*
Copyright: Copyright 1998 Jane Smith <jsmith@example.net>
License:
[LICENSE TEXT]
\end{lstlisting}
\end{frame}
\subsection{修改上游的原始碼}
\begin{frame}{修改上游的原始碼}
通常發生於:
\begin{itemize}
\item 需要修正缺陷或者新增 Debian 客製化修改
\hbr
\item 從新的上游發行版中移值補丁回來
\end{itemize}
\br
列出可實行的方法:
\begin{itemize}
\item 直接修改檔案
\begin{itemize}
\item 簡單
\item 但是沒有修改歷程等相關文件可供追蹤
\end{itemize}
\hbr
\item 使用補丁系統
\begin{itemize}
\item 讓修改更容易的回到上游
\item 能夠分享給相關衍生性版本
\item 讓修改更具有揭露性\\ \url{http://patch-tracker.debian.org/} (目前無法使用)
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{補丁系統}
\begin{itemize}
\item 原則: 修改需以補丁的型式存放在 \texttt{debian/patches/}
\br
\item 在構建時可選擇是否引入補丁
\br
\item 以往有數種實作方法 -- \textsl{simple-patchsys} (\textsl{cdbs}), \textsl{dpatch},
\textbf{\textsl{quilt}}
\begin{itemize}
\item 每一個皆支援兩個 \texttt{debian/rules} targets:
\begin{itemize}
\item \texttt{debian/rules patch}: 引入所有補丁
\item \texttt{debian/rules unpatch}: 卸載所有補丁
\end{itemize}
\hbr
\item 更多文件可參照: \url{https://wiki.debian.org/debian/patches}
\end{itemize}
\br
\item \textbf{新的原始碼套件格式和內建補丁系統: 3.0 (quilt)}
\begin{itemize}
\item 建議的解決方案
\hbr
\item 你需要學習 \textsl{quilt}\\
\url{https://perl-team.pages.debian.net/howto/quilt.html}
\hbr
\item 補丁系統相容工具 \texttt{devscripts}: \texttt{edit-patch}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{補丁的相關文件}
\begin{itemize}
\item 補丁一開頭即為標準檔頭
\br
\item DEP-3 文件 - Patch Tagging Guidelines\\ \url{http://dep.debian.net/deps/dep3/}
\end{itemize}
\vfill
\seprule
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
Description: Fix widget frobnication speeds
Frobnicating widgets too quickly tended to cause explosions.
Forwarded: http://lists.example.com/2010/03/1234.html
Author: John Doe <johndoe-guest@users.alioth.debian.org>
Applied-Upstream: 1.2, http://bzr.foo.com/frobnicator/revision/123
Last-Update: 2010-03-29
--- a/src/widgets.c
+++ b/src/widgets.c
@@ -101,9 +101,6 @@ struct {
\end{lstlisting}
\end{frame}
\subsection{安裝以及卸載的相關動作}
\begin{frame}{安裝以及卸載的相關動作}
\begin{itemize}
\item 只解壓縮套件, 有時會略感不足
\hbr
\item 新增/ 刪除系統使用者, 啟動/停止服務, 控制 \textsl{alternatives}
\hbr
\item 在 \textsl{maintainer scripts}完成\\ \texttt{preinst, postinst, prerm, postrm}
\begin{itemize}
\item 有些共同的動作可以被 debhelper 所生成
\end{itemize}
\hbr
\item 文件:
\begin{itemize}
\item Debian維護手冊, 第6章\\ {\footnotesize
\url{https://www.debian.org/doc/debian-policy/ch-maintainerscripts}}
\hbr
\item Debian 開發者參考, 第6.4章\\ {\scriptsize
\url{https://www.debian.org/doc/developers-reference/best-pkging-practices.html}}
\hbr
\item {\footnotesize
\url{https://people.debian.org/~srivasta/MaintainerScripts.html}}
\end{itemize}
\br
\item 提示使用者
\begin{itemize}
\item 務必使用 \textbf{debconf}
\hbr
\item 文件: \texttt{debconf-devel(7)} (\texttt{debconf-doc} 套件)
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{監看上游版本}
\begin{itemize}
\item 在 \texttt{debian/watch} 中指定要監看的位址 (參考 \texttt{uscan(1)})
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
version=3
http://tmrc.mit.edu/mirror/twisted/Twisted/(\d\.\d)/ \
Twisted-([\d\.]*)\.tar\.bz2
\end{lstlisting}
\br
\item 有一些可自動追蹤上游版本的系統, 會透過 dashboards 的方式來通知維護者. 例:
\url{https://tracker.debian.org/} 以及 \url{https://udd.debian.org/dmd/}
\br
\item \texttt{uscan}: 執行手動確認
\br
\item \texttt{uupdate}: 讓你的套件更新到最新的上游版本
\end{itemize}
\end{frame}
\subsection{使用版本控制系統來進行打包 (SVN, Git)}
\begin{frame}[fragile=singleslide]{使用版本控制系統來進行打包}
\begin{itemize}
\item 有數種工具可以來協助管理 branches and tags 以進行打包的動作:\\ \texttt{svn-buildpackage},
\texttt{git-buildpackage}
\hbr
\item 範例: \texttt{git-buildpackage}
\begin{itemize}
\item \texttt{upstream} 分支使用 \texttt{upstream/\textsl{version}} 標籤來追蹤上游
\item \texttt{master} 分支追蹤 Debian 套件
\item \texttt{debian/\textsl{version}} 會對每個上傳進行標籤
\item \texttt{pristine-tar} 分支能夠重新構建上游壓縮檔
\end{itemize}
文件:
\url{http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.html}
\hbr
\item \texttt{Vcs-*} 在 \texttt{debian/control} 的欄位能夠定位目錄
\begin{itemize}
\item \url{https://wiki.debian.org/Salsa}
\end{itemize}
\end{itemize}
\begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
Vcs-Browser: https://salsa.debian.org/debian/devscripts
Vcs-Git: https://salsa.debian.org/debian/devscripts.git
\end{lstlisting}
\begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libwww-perl
Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libwww-perl.git
\end{lstlisting}
\begin{itemize}
\item VCS 相容介面: \texttt{debcheckout}, \texttt{debcommit}, \texttt{debrelease}\\
\begin{itemize}
\item \texttt{debcheckout grep} $\rightarrow$ 從Git checks out 原始碼套件出來
\end{itemize}
\end{itemize}
\end{frame}
\subsection{向前移值套件}
\begin{frame}{向前移值套件}
\begin{itemize}
\item 目標: 在舊有系統上使用較新的套件版本\\ 例: 使用 \textsl{mutt} from Debian \textsl{unstable} on
Debian \textsl{stable}
\br
\item 一般來說:
\begin{itemize}
\item 從 Debian unstable 抓原始碼套件
\hbr
\item 透過修改讓套件可以構建且正常運行在 Debian stable 上
\begin{itemize}
\item 有時簡單 (不需任何修改)
\item 有時困難
\item 有時不可行 (有太多無法解決的相依性問題)
\end{itemize}
\end{itemize}
\br
\item Debian project 提供部份向前相容的套件\\ \url{http://backports.debian.org/}
\end{itemize}
\end{frame}
\section{維護 Debian 套件}
\subsection{Debian 檔案庫和 suites}
\begin{frame}{Debian 檔案庫和 suites}
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[
people/.style={shape=ellipse,draw,thick},
suite/.style={shape=rectangle,draw},
devel/.style={fill=red!30!white},
test/.style={fill=orange!30!white},
prod/.style={fill=green!30!white,node distance=2cm},
internal/.style={},
old/.style={fill=gray!30!white},
veryold/.style={fill=gray!70!white},
arr/.style={very thick},
uploads/.style={decorate,decoration={snake,amplitude=.4mm,segment length=2mm,post length=1mm}},
migrations/.style={};
command/.style={text=rouge,font=\ttfamily},
legend/.style={font=\small}
]
\draw node[suite,prod] (sec) {security}; \draw node[suite,prod,right=of sec]
(su) {stable-updates}; \draw node[suite,prod,right=of su] (st) {stable};
\draw node[suite,old,node distance=0.3cm,below=of st] (os) {oldstable};
\draw node[suite,veryold,node distance=0.3cm,below=of os] (ar)
{archive.d.o}; \draw node[suite,prod,right=of st] (bp) {backports}; \draw
node[suite,test] (spu) at ($(su) + (-0.6,2.5)$) {stable-proposed-updates};
\draw node[suite,internal] (sn) at ($(st) + (-1.8,1.4)$) {stable-new}; \draw
node[suite,test,node distance=1.5cm,above=of st] (te) {testing}; \draw
node[suite,devel,above=of te] (sid) {unstable}; \draw node[suite,devel]
(exp) at ($(sid) + (2.5,0.5)$) {experimental}; \draw node[suite,devel] (tpu)
at ($(te)!0.5!(sid) + (2.5,0)$) {testing-proposed-updates}; \draw
node[people,above=of sid] (dd) {developer}; \draw node[people,node
distance=3cm,left=of dd] (secteam) {security team}; \draw[arr,uploads,->]
(dd) -- (sid); \draw[arr,uploads,->] (dd) -- (exp);
\draw[arr,uploads,->,bend right=8] (dd) to (tpu); \draw[arr,uploads,->]
(secteam) -- (sid); \draw[arr,uploads,->] (secteam) -- (sec);
\draw[arr,uploads,->] (dd) to (spu); \draw[arr,uploads,->] plot [smooth,
tension=0.75] coordinates { (dd.east) ($(exp.north east)+(0.1,0.1)$)
($(tpu.east)+(0.2,0)$) ($(bp.north east) + (-0.4,0)$) };
\draw[arr,migrations,->] (tpu) -- (te); \draw[arr,migrations,->] (sid) --
(te); \draw[arr,migrations,->] (te) -- (st) node
[midway,align=left,midway,right,font=\footnotesize] {stable\\ release};
\draw[arr,migrations,->] (sec) -- (sn); \draw[arr,migrations,->] (sn) to
node [pos=0.2] (spulabel) {} (st); \draw
node[font=\footnotesize,align=right] at ($(spulabel) + (-0.4,-0.45)$)
{stable \\ point \\ release}; \draw[arr,migrations,->] (spu) to (sn);
\draw[arr,migrations,->] (spu) -- (su); \draw[arr,migrations,->] (st) --
(os); \draw[arr,migrations,->] (os) -- (ar); \coordinate (legend) at
(-2,-1); \draw[arr,uploads,->] (legend) -- ($(legend) + (0.7,0)$) node
[right,legend] {package uploads}; \coordinate[node distance=1.1em,below=of
legend] (legend2); \draw[arr,migrations,->] (legend2) -- ($(legend2) +
(0.7,0)$) node [right,legend] {package migrations between suites};
\coordinate[node distance=1.5em,below=of legend2] (legend3); \draw
node[right,suite,devel,legend] (ldev) at (legend3) {development}; \draw
node[node distance=0.1cm,right=of ldev,suite,test,legend] (ltest) {test};
\draw node[node distance=0.1cm,right=of ltest,suite,internal,legend] (lint)
{internal}; \draw node[node distance=0.1cm,right=of lint,suite,prod,legend]
(lprod) {production}; \draw ($(legend.north west) + (-0.1,0.25)$) rectangle
($(lprod.south east) + (0.1,-0.1)$); \draw
node[font=\bf,red!70!white,align=center] (tnext) at ($(te.east) + (2,-0.1)$)
{preparation of \\ next release}; \draw
node[font=\bf,green!70!black,align=center] (tsrm) at ($(sec.north east) +
(1,1)$) {stable\\release\\management}; \pgfdeclarelayer{background}
\pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}
\begin{pgfonlayer}{background}
\fill[red!10!white] plot [smooth cycle,tension=0.55] coordinates {
($(sid.north west) + (-0.1,0.1)$) ($(exp.north east)+(0.1,0.1)$)
($(tpu.south east)+(0.1,-0.1)$) ($(tnext.south) + (0.6,0)$) ($(te.south
west) + (0.1,-0.1)$) }; \fill[green!10!white] plot [smooth
cycle,tension=0.55] coordinates { ($(spu.north west) + (-0.1,0.1)$)
($(spu.north east)+(0.1,0.1)$) ($(sn.north east)+(0.1,0.1)$) ($(st.north
east) + (0.1,0.5)$) ($(bp.north east) + (0.1,0.1)$) ($(bp.south east) +
(0.1,-0.1)$) ($(sec.south west) + (-0.1,-0.1)$) };
\end{pgfonlayer}
\end{tikzpicture}
}
\end{center}
\begin{flushright}
\tiny 基於 Antoine Beaupr\'e 的圖片
\url{https://salsa.debian.org/debian/package-cycle}~~~~~~~~~~~~
\end{flushright}
\end{frame}
\begin{frame}{開發用的 Suites}
\begin{itemize}
\item 每個套件之新版本會被上傳至 \textbf{unstable} (\textbf{sid})
\hbr
\item 套件會基於幾項準則從 \textbf{unstable} 移至 \textbf{testing} (例如,在unstable 已經有 10
天而且沒有發生 regressions)
\hbr
\item 新套件也可被上傳至:
\begin{itemize}
\item \textbf{experimental} (給 \textsl{experimental} 套件所使用, 像是當新版本還沒準備要取代在
unstable 的版本時)
\hhbr
\item \textbf{testing-proposed-updates}, 更新 \textbf{testing} 的版本而不透過
\textbf{unstable} (這很少被使用)
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{凍結和發行}
\begin{itemize}
\item 在發行週期的某些時刻, 發行團隊會決定進行 \textsl{freeze} 測試: 停止從 "\textbf{unstable} 到
\textbf{testing} 的自動移轉, 並且改用人工審核
\br
\item 當發行團隊認為 \textbf{testing} 已經準備發行時:
\begin{itemize}
\item \textbf{testing} suite 會變成新的 \textbf{stable} suite
\hhbr
\item 同樣地, 舊的 \textbf{stable} 會變成 \textbf{oldstable}
\hhbr
\item 不支援的發行則會被移到 \texttt{archive.debian.org}
\end{itemize}
\br
\item 參考 \url{https://release.debian.org/}
\end{itemize}
\end{frame}
\begin{frame}{Stable release suites and management}
\begin{itemize}
\item 許多 suites 是用來提供穩定發行的套件:
\hhbr
\begin{itemize}
\item \textbf{stable}: 主要的 suite
\hbr
\item \textbf{security} 更新為 \texttt{security.debian.org} 所提供的 suite, 並被安全團隊所使用,
更新消息會公佈在 \texttt{debian-security-announce} mailing list
\hbr
\item \textbf{stable-updates}: 跟安全無關, 但是需要被緊急安裝的更新(不需等待下次的小版本更新): 如防毒的資料庫,
時區相關套件等等, 會公佈在 \texttt{debian-stable-announce} mailing list
\hbr
\item \textbf{backports}: 新的上游版本, 會基於在 \textbf{testing} 的版本
\end{itemize}
\hbr
\item \textbf{stable} suite 每幾個月會有 \textsl{穩定小版本更新} (只有包含 bug 修復)
\hhbr
\begin{itemize}
\item 目標是下次穩定小版本更新的套件會被上傳到 \textbf{stable-proposed-updates} 並被發行團隊審核
\end{itemize}
\hbr
\item \textbf{oldstable} 的發行也擁有相同的 suites 組合
\end{itemize}
\end{frame}
\subsection{一些為 Debian 貢獻的方法}
\begin{frame}{一些為 Debian 貢獻的方法}
\begin{itemize}
\item \textbf{不建議} 提供貢獻的方法:
\begin{enumerate}
\item 打包自有應用程式
\item 放進 Debian
\item 消失
\end{enumerate}
\br
\item \textbf{較建議} 提供貢獻的方法:
\begin{itemize}
\item 實際參與打包群組
\begin{itemize}
\item 許多群組專注於特定套件, 且皆需要協助
\item 列出可用群組 \url{https://wiki.debian.org/Teams}
\item 從更有經驗的貢獻者身上學習
\end{itemize}
\br
\item 認養現有但無人維護之套件 (\textsl{orphaned packages})
\br
\item 將新的軟體帶進 Debian
\begin{itemize}
\item 必須是有用或者有趣的
\item Debian 原有套件是否就可以滿足需求?
\end{itemize}
\end{itemize}
\end{itemize}
\end{frame}
\subsection{認養無人維護的套件}
\begin{frame}{認養無人維護的套件}
\hbr
\begin{itemize}
\item Debian 有許多尚待維護的套件
\hbr
\item 完整清單以及流程: \url{https://www.debian.org/devel/wnpp/}
\hbr
\item 將 \texttt{wnpp-alert} 安裝到機器上,並可更進一步的安裝 \texttt{how-can-i-help}
\hbr
\item 不同的狀態:
\begin{itemize}
\small
\item \textbf{O}rphaned: 此套件目前被遺棄中 \\ 歡迎認領
\hbr
\item \textbf{RFA}: \textbf{R}equest \textbf{F}or \textbf{A}dopter\\ 此套件維護中,
但維護者在尋找繼任者\\ 歡迎認養, 但禮貌上先以電子郵件知會現任維護者
\hbr
\item \textbf{ITA}: \textbf{I}ntent \textbf{T}o \textbf{A}dopt\\ 有人意圖認養此套件\\
但你依然可以提出協助的需求!
\hbr
\item \textbf{RFH}: \textbf{R}equest \textbf{F}or \textbf{H}elp\\ 維護者尋求協助中
\end{itemize}
\hbr
\item 有些無人維護的套件沒有被偵測到\arr 不是被遺棄的套件
\hbr
\item 若有任何疑問, 請到 \texttt{debian-qa@lists.debian.org} 提出 \\ 或者前往
\texttt{irc.debian.org}裡的頻道 \texttt{\#debian-qa}詢問
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{認領套件: 範例}
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize,escapeinside=\{\}]
From: You <you@yourdomain>
To: 640454@bugs.debian.org, control@bugs.debian.org
Cc: Francois Marier <francois@debian.org>
Subject: ITA: verbiste -- French conjugator
retitle 640454 ITA: verbiste -- French conjugator
owner 640454 !
thanks
Hi,
I am using verbiste and I am willing to take care of the package.
Cheers,
You
\end{lstlisting}
\begin{itemize}
\item 有禮貌的連絡上一任維護者 (尤其套件狀態為 RFA 而不是 orphaned)
\item 適時的和上游專案有所連繫
\end{itemize}
\end{frame}
\subsection{將你的套件放入 Debian}
\begin{frame}{將你的套件放入 Debian}
\begin{itemize}
\item 不需要具備任何官方身份就可以將你的套件放進 Debian
\begin{enumerate}
\item 使用 \texttt{reportbug wnpp} 送出 \textbf{ITP} bug (\textbf{I}ntent \textbf{T}o
\textbf{P}ackage)
\hbr
\item 準備好原始碼套件
\hbr
\item 找一位 Debian Developer 來協助確認你的套件
\end{enumerate}
\br
\item 官方身份 (當你具備許多打包維護的經驗):
\begin{itemize}
\item \textbf{Debian Maintainer (DM):}\\ 允許上傳你自己的套件\\ 參照
\url{https://wiki.debian.org/DebianMaintainer}
\hbr
\item \textbf{Debian Developer (DD):}\\ Debian project member; 能夠投票且上傳任何套件
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{發出協助需求前需確認事項}
\begin{itemize}
\item Debian \textbf{非常重視品質}
\hbr
\item 一般而言, \textbf{協助人員很忙又很難找}
\begin{itemize}
\item 請再三確認你的套件已經很完整, 再提出協助確認需求
\end{itemize}
\hbr
\item 需要確認之事項:
\begin{itemize}
\item 避免忘了加入構建相依性: 確認你的套件可以在乾淨的 \textsl{sid} \textsl{chroot} 中正常構建
\begin{itemize}
\item 建議使用\texttt{pbuilder}
\end{itemize}
\hbr
\item 在你的套件上執行 \texttt{lintian -EviIL +pedantic}
\begin{itemize}
\item 若出現Errors 則必須被修復, 其他問題也需一併修復
\end{itemize}
\hbr
\item 請在你的套件上進行大規模的測試驗證
\end{itemize}
\hbr
\item 若有疑問, 請提出問題以尋求協助
\end{itemize}
\end{frame}
\subsection{去哪邊尋求協助?}
\begin{frame}{去哪邊尋求協助?}
\hbr
可針對下列事項進行協助:
\begin{itemize}
\item 對於提出的問題, 給予建議或答案, 以及程式碼審查
\item 協助確認並且上傳你已經準備好的套件
\end{itemize}
\hbr
你可以從下列得到協助:
\begin{itemize}
\item \textbf{其他打包部門的成員}
\begin{itemize}
\item 部門列表: \url{https://wiki.debian.org/Teams}
\end{itemize}
\hbr
\item The \textbf{Debian Mentors group} (如果你的套件找不到相對應的部門)
\begin{itemize}
\item \url{https://wiki.debian.org/DebianMentorsFaq}
\item Mailing list: \url{debian-mentors@lists.debian.org}\\ {\small (有時可以學到不錯的東西)}
\item IRC: \texttt{\#debian-mentors} on \texttt{irc.debian.org}
\item \url{http://mentors.debian.net/}
\item 文件: \url{http://mentors.debian.net/intro-maintainers}
\end{itemize}
\hbr
\item \textbf{當地 mailing lists} (根據你的語言來尋求協助)
\begin{itemize}
\item \texttt{debian-devel-\{french,italian,portuguese,spanish\}@lists.d.o}
\item 完整清單: \url{https://lists.debian.org/devel.html}
\item 或者使用者清單: \url{https://lists.debian.org/users.html}
\end{itemize}
\end{itemize}
\end{frame}
\subsection{更多文件}
\begin{frame}{更多文件}
\begin{itemize}
\item Debian Developers' Corner\\ \url{https://www.debian.org/devel/}\\ {\small
有許多開發 Debian 相關的資源連結}
\hbr
\item Debian 維護者指南\\ \url{https://www.debian.org/doc/manuals/debmake-doc/}
\hbr
\item Debian Developer's Reference\\
\url{https://www.debian.org/doc/developers-reference/}\\ {\small 比較多關於
Debian 的常規, 但也含有一些很棒的實際範例 (part 6)}
\hbr
\item Debian Policy\\ \url{https://www.debian.org/doc/debian-policy/}\\
{\small \begin{itemize} \item \small 所有需求都必須在每個套件中被滿足 \item \small 對於 Perl,
Java, Python, \ldots 特定的規則\end{itemize}}
\hbr
\item Ubuntu 打包指南\\ \url{https://packaging.ubuntu.com/html/}
\end{itemize}
\end{frame}
\subsection{Debian 給維護者的dashboards}
\begin{frame}{Debian 給維護者的dashboards}
\begin{itemize}
\item \textbf{原始碼套件中心}: 套件追蹤系統 Package Tracking System (PTS)\\
\url{https://packages.qa.debian.org/dpkg}
\br
\item \textbf{維護者/ 小組中心}: 開發者套件概述 Developer's Packages Overview (DDPO)\\
\url{https://qa.debian.org/developer.php?login=pkg-ruby-extras-maintainers@lists.alioth.debian.org}
\br
\item \textbf{待作清單列表}: Debian Maintainer Dashboard (DMD)\\
\url{https://udd.debian.org/dmd.cgi}
\end{itemize}
\end{frame}
\begin{frame}{使用 Debian Bug 追蹤系統 (BTS)}
\begin{itemize}
\item 使用特有的方法來管控缺陷
\begin{itemize}
\item 使用 Web 的介面來查看缺陷
\item 使用 Email 的介面來處理缺陷
\end{itemize}
\hbr
\item 加入缺陷的資訊:
\begin{itemize}
\item 寫電子郵件到 \texttt{123456@bugs.debian.org} (若要包含submitter, 你需要加入
\texttt{123456-submitter@bugs.debian.org})
\end{itemize}
\hbr
\item 更改缺陷狀態:
\begin{itemize}
\item 送出指令到 \texttt{control@bugs.debian.org}
\item 指令列的介面: 在 \texttt{devscripts}中的指令 \texttt{bts}
\item 文件: \url{https://www.debian.org/Bugs/server-control}
\end{itemize}
\hbr
\item 回報缺陷: 使用 \texttt{reportbug}
\begin{itemize}
\item 通常使用本地郵件服務器: 可透過 \texttt{ssmtp} 或者 \texttt{nullmailer} 安裝
\item 或者使用 \texttt{reportbug -\@-template}, 然後手動送出至
\texttt{submit@bugs.debian.org}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{使用 Debian Bug 追蹤系統 (BTS): 範例}
\begin{itemize}
\item 針對缺陷送出電子郵件給 submitter:\\
\url{https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680822\#10}
\hbr
\item 標記並且修改嚴重程度:\\
\url{https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680227\#10}
\hbr
\item 重新指定, 修改嚴重程度, 修改主旨 \ldots: \\
\url{https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680822\#93}
\begin{itemize}
\item \texttt{notfound}, \texttt{found}, \texttt{notfixed}, \texttt{fixed} 是給
\textbf{版本追蹤}來使用\\ 參照
\url{https://wiki.debian.org/HowtoUseBTS\#Version\_tracking}
\end{itemize}
\hbr
\item 使用使用者標籤:
\url{https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=42;bug=642267}\\ 參照
\url{https://wiki.debian.org/bugs.debian.org/usertags}
\hbr
\item Debian Bug 追蹤系統 (BTS) 文件:
\begin{itemize}
\item \url{https://www.debian.org/Bugs/}
\item \url{https://wiki.debian.org/HowtoUseBTS}
\end{itemize}
\end{itemize}
\end{frame}
\subsection{More interested in Ubuntu?}
\begin{frame}{More interested in Ubuntu?}
\begin{itemize}
\item Ubuntu 主要管控和 Debian 的差異
\br
\item 不針對於特定套件,\\ 而是和 Debian team 協同合作
\br
\item 一般來說會建議新套件要先上傳到 Debian\\
\url{https://wiki.ubuntu.com/UbuntuDevelopment/NewPackages}
\br
\item 但有更好的方法:
\begin{itemize}
\item 參與 Debian team並且和 Ubuntu 建立溝通橋樑
\hbr
\item 協助減少差異並在Launchpad進行缺陷診斷
\hbr
\item 許多 Debian 工具能提供協助:
\begin{itemize}
\item Developer 的套件大綱中有 ubuntu 欄位
\item Ubuntu box on the 套件追蹤系統
\item 透過 PTS 收 launchpad bugmail
\end{itemize}
\end{itemize}
\end{itemize}
\end{frame}
\section{結論}
\subsection{結論}
\begin{frame}{結論}
\begin{itemize}
\item 現在你對 Debian 打包已經有一個完整的概觀
\br
\item 但你需要閱讀更多的文件
\br
\item 典範實務是經年累月而成的
\begin{itemize}
\item 如果不太確定, 使用 \textbf{dh} 套件小幫手, 以及 \textbf{3.0 (quilt)} 格式
\end{itemize}
\end{itemize}
\vfill
\centerline{\large 回饋: \textbf{packaging-tutorial@packages.debian.org}}
\end{frame}
\subsection{法律相關}
\begin{frame}{法律相關}
Copyright \copyright 2011--2019 Lucas Nussbaum -- lucas@debian.org
\br
{\small \textbf{This document is free software}: you can redistribute it
and/or modify it under either (at your option): \hbr \begin{itemize} \item
The terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.\\ \url{http://www.gnu.org/licenses/gpl.html} \br \item
The terms of the Creative Commons Attribution-ShareAlike 3.0 Unported
License.\\ \url{http://creativecommons.org/licenses/by-sa/3.0/}
\end{itemize} }
\end{frame}
\subsection{對此教學指南做出貢獻}
\begin{frame}{對此教學指南做出貢獻}
\begin{itemize}
\item 貢獻:
\begin{itemize}
\item{\small \texttt{apt-get source packaging-tutorial}}
\hbr
\item {\small \texttt{debcheckout packaging-tutorial}}
\hbr
\item {\small \texttt{git clone\\
https://salsa.debian.org/debian/packaging-tutorial.git}}
\hbr
\item {\small \url{https://salsa.debian.org/debian/packaging-tutorial}}
\hbr
\item {\small 回報缺陷: \url{bugs.debian.org/src:packaging-tutorial}}
\end{itemize}
\br
\item 提供回饋:
\begin{itemize}
\item \href{mailto:packaging-tutorial@packages.debian.org}{\textbf{\texttt{mailto:packaging-tutorial@packages.debian.org}}}
\begin{itemize}
\item{\small 有哪些必須加入此教學指南?}
\item {\small 有哪些部份可以再優化?}
\end{itemize}
\hbr
\item{\small \texttt{reportbug packaging-tutorial}}
\end{itemize}
\end{itemize}
\end{frame}
\section{深入淺出實際演練}
\subsection{實際演練 2: 打包 GNUjump}
\begin{frame}{實際演練 2: 打包 GNUjump}
\begin{enumerate}
\item 從 \url{http://ftp.gnu.org/gnu/gnujump/gnujump-1.0.8.tar.gz} 下載 GNUjump 1.0.8
\br
\item 建立一個 Debian 套件
\begin{itemize}
\item 安裝 build-dependencies 以進行構建套件之先行必要動作
\item 修正問題
\item 產生一個基本可運作的套件
\item 完成填入 \texttt{debian/control} 以及其他檔案
\end{itemize}
\br
\item 享受吧
\end{enumerate}
\centerline{\includegraphics[width=5cm]{figs/gnujump.png}}
\end{frame}
\begin{frame}[fragile=singleslide]{實際演練 2: 打包 GNUjump (小訣竅)}
\begin{itemize}
\item 創建一個基本的套件: \texttt{dh\_make}
\item 一開始先創建一個 \textsl{1.0} 原始碼套件會比 \textsl{3.0 (quilt)} (透過 修改
\texttt{debian/source/format})簡單
\item 先搜尋構建所需要的相依檔案,找到檔案後,使用\texttt{apt-file}來找到套件
\item 如果你遇到錯誤:
\begin{lstlisting}[basicstyle=\ttfamily\tiny]
/usr/bin/ld: SDL_rotozoom.o: undefined reference to symbol 'ceil@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:376: recipe for target 'gnujump' failed
\end{lstlisting}
代表你需要加入\texttt{-lm} 到linker指令列:\\ 編輯 \texttt{src/Makefile.am}並且替換
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = $(all_libraries)
\end{lstlisting}
成下列
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = -Wl,--as-needed
gnujump_LDADD = $(all_libraries) -lm
\end{lstlisting}
接著執行 \texttt{autoreconf -i}
\end{itemize}
\end{frame}
\subsection{實際演練 3: 打包 Java library}
\begin{frame}{實際演練 3: 打包 Java library}
\begin{enumerate}
\item 先看一下如何打包 Java 相關文件:\\
\begin{itemize}
\item \url{https://wiki.debian.org/Java}
\hbr
\item \url{https://wiki.debian.org/Java/Packaging}
\hbr
\item \url{https://www.debian.org/doc/packaging-manuals/java-policy/}
\hbr
\item \texttt{/usr/share/doc/javahelper/tutorial.txt.gz}
\end{itemize}
\br
\item 從 \url{http://moepii.sourceforge.net/} 下載 IRClib
\br
\item 開始打包
\end{enumerate}
\end{frame}
\subsection{實際演練 4: 打包 Ruby gem}
\begin{frame}{實際演練 4: 打包 Ruby gem}
\begin{enumerate}
\item 先看一下如何打包 Ruby 相關文件:\\
\begin{itemize}
\item \url{https://wiki.debian.org/Ruby}
\hbr
\item \url{https://wiki.debian.org/Teams/Ruby}
\hbr
\item \url{https://wiki.debian.org/Teams/Ruby/Packaging}
\hbr
\item \texttt{gem2deb(1)}, \texttt{dh\_ruby(1)} (\texttt{gem2deb} 套件)
\end{itemize}
\hbr
\item 從 \texttt{peach} gem:\\ \texttt{gem2deb peach} 建立基本的 Debian 原始碼套件
\hbr
\item 適時的優化, 讓它成為一個合適的 Debian 套件
\end{enumerate}
\end{frame}
\subsection{實際演練 5: 打包 Perl 模組}
\begin{frame}[fragile=singleslide]{實際演練 5: 打包 Perl 模組}
\begin{enumerate}
\item 先看一下如何打包 Perl 相關文件:\\
\begin{itemize}
\item \url{https://perl-team.pages.debian.net}
\hbr
\item \url{https://wiki.debian.org/Teams/DebianPerlGroup}
\hbr
\item \texttt{dh-make-perl(1)}, \texttt{dpt(1)} (in the \texttt{pkg-perl-tools}
package)
\end{itemize}
\hbr
\item 從 \texttt{Acme} CPAN 發行版:\\ \verb|dh-make-perl --cpan Acme| 建立基本的 Debian
原始碼套件
\hbr
\item 適時的優化, 讓它成為一個合適的 Debian 套件
\end{enumerate}
\end{frame}
\section{深入淺出實際演練}
\begin{frame}
\begin{center}
\LARGE 深入淺出\\[0.5em] 實際演練
\end{center}
\end{frame}
\subsection{實際演練 1: 修改 grep 套件}
\begin{frame}{實際演練 1: 修改 grep 套件}
\begin{enumerate}
\item 前往 \url{http://ftp.debian.org/debian/pool/main/g/grep/} 並且下載版本 2.12-2 的套件
\item 注意 \texttt{debian/}中的檔案.
\begin{itemize}
\item 原始碼套件產生多少二進制套件?
\item 這個套件使用哪一種打包小幫手?
\end{itemize}
\hbr
\item 構建套件
\hbr
\item 先修改套件. 並在changelog中添加一個條目並且遞增版本號碼.
\hbr
\item 接著將 perl-regexp 功能移除 (位於 \texttt{./configure} 中的選項)
\hbr
\item 重新構建套件
\hbr
\item 使用 debdiff 來比較原始和新套件中差異
\hbr
\item 安裝新構建的套件
\end{enumerate}
\end{frame}
\begin{frame}{把原始碼抓下來}
\begin{enumerate}
\item 前往 \url{http://ftp.debian.org/debian/pool/main/g/grep/} 並且下載版本 2.12-2 的套件
\end{enumerate}
\begin{itemize}
\item 使用 dget 下載 \texttt{.dsc} 檔案:\\ {\small \texttt{dget
https://cdn.debian.net/debian/pool/main/g/grep/grep\_2.12-2.dsc}}
\hbr
\item 如果你在Debian發行版上有\texttt{deb-src}有\texttt{grep}版本2.12-2(可查看\url{https://tracker.debian.org/grep}),你可以使用\texttt{apt-get
source grep=2.12-2}\\或者\texttt{apt-get source grep/release} (例
\texttt{grep/stable}\\又或者你可直接使用\texttt{apt-get source grep}
\hbr
\item \texttt{grep} 原始碼套件主要有 3 個檔案所組成:
\begin{itemize}
\item \texttt{grep\_2.12-2.dsc}
\item \texttt{grep\_2.12-2.debian.tar.bz2}
\item \texttt{grep\_2.12-2.orig.tar.bz2}
\end{itemize}
這些代表 "3.0 (quilt)"格式.
\hbr
\item 若有需求, 解壓縮這些原始碼\\ \texttt{dpkg-source -x grep\_2.12-2.dsc}
\end{itemize}
\end{frame}
\begin{frame}{瞧瞧並且構建套件包}
\begin{enumerate}
\setcounter{enumi}{1}
\item 注意 \texttt{debian/}中的檔案
\begin{itemize}
\item 原始碼套件產生多少二進制套件?
\item 這個套件使用哪一種打包小幫手?
\end{itemize}
\end{enumerate}
\hbr
\begin{itemize}
\item 根據 \texttt{debian/control}的設定, 此套件只會產生一個二進制套件, 取名為\texttt{grep}.
\hbr
\item 根據\texttt{debian/rules}內容所述, 此套件是採用 \textsl{classic} debhelper 來進行打包, 而不是使用
\textsl{CDBS} 或者 \textsl{dh}. 可以看到它在 \texttt{debian/rules}呼叫許多\texttt{dh\_*}
指令.
\end{itemize}
\hbr
\begin{enumerate}
\setcounter{enumi}{2}
\item 構建套件
\end{enumerate}
\hbr
\begin{itemize}
\item 使用 \texttt{apt-get build-dep grep} 來取得構建相依性
\item 然後使用 \texttt{debuild} 或者 \texttt{dpkg-buildpackage -us -uc} (大約需要一分鐘)
\end{itemize}
\end{frame}
\begin{frame}{編輯修改歷程}
\begin{enumerate}
\setcounter{enumi}{3}
\item 先修改套件. 並在changelog中添加一個條目並且遞增版本號碼.
\end{enumerate}
\hbr
\begin{itemize}
\item \texttt{debian/changelog} 是一個文字檔. 你可以手動編輯或者創建一條歷程記錄.
\hbr
\item 或者你可以使用\texttt{dch -i}, 使用編輯器創建一條歷程記錄
\hbr
\item 名字以及電子郵件的相關設定可透過\texttt{DEBFULLNAME} and \texttt{DEBEMAIL}環境變數來進行配置
\hbr
\item 接著重新構建套件: 產生一個新版本套件
\hbr
\item 套件版本規則被定義在Debian policy 章節 5.6.12\\
\url{https://www.debian.org/doc/debian-policy/ch-controlfields}
\end{itemize}
\end{frame}
\begin{frame}{移除 Perl 中的正規表示法支援然後重新構建}
\begin{enumerate}
\setcounter{enumi}{4}
\item 接著將 perl-regexp 功能移除 (位於 \texttt{./configure} 中的選項)
\item 重新構建套件
\end{enumerate}
\hbr
\begin{itemize}
\item 確認 \texttt{./configure -{}-help}: 移除 Perl
正規表示法的選項為\texttt{-{}-disable-perl-regexp}
\hbr
\item 編輯\texttt{debian/rules} 然後找到\texttt{./configure}這一行
\hbr
\item 添加 \texttt{-{}-disable-perl-regexp}
\hbr
\item 使用\texttt{debuild} 或者 \texttt{dpkg-buildpackage -us -uc}重新構建
\end{itemize}
\end{frame}
\begin{frame}{比對以及測試套件}
\begin{enumerate}
\setcounter{enumi}{6}
\item 使用 debdiff 來比較原始和新套件中差異
\item 安裝新構建的套件
\end{enumerate}
\hbr
\begin{itemize}
\item 比對二進制套件: \texttt{debdiff ../*changes}
\hbr
\item 比對原始碼套件: \texttt{debdiff ../*dsc}
\hbr
\item 安裝新構建成的套件: \texttt{debi}\\ Or \texttt{dpkg -i ../grep\_<TAB>}
\hbr
\item \texttt{grep -P foo} 已失效!
\end{itemize}
\br
重新安裝前一版的套件:
\begin{itemize}
\item \texttt{apt-get install -{}-reinstall grep=2.6.3-3} \textit{(= previous
version)}
\end{itemize}
\end{frame}
\subsection{實際演練 2: 打包 GNUjump}
\begin{frame}{實際演練 2: 打包 GNUjump}
\begin{enumerate}
\item 從 \url{http://ftp.gnu.org/gnu/gnujump/gnujump-1.0.8.tar.gz} 下載 GNUjump 1.0.8
\br
\item 建立一個 Debian 套件
\begin{itemize}
\item 安裝 build-dependencies 以進行構建套件之先行必要動作
\item 產生一個基本可運作的套件
\item 完成填入 \texttt{debian/control} 以及其他檔案
\end{itemize}
\br
\item 享受吧
\end{enumerate}
\centerline{\includegraphics[width=5cm]{figs/gnujump.png}}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots}
\begin{itemize}
\item \texttt{wget http://ftp.gnu.org/gnu/gnujump/gnujump-1.0.8.tar.gz}
\hbr
\item \texttt{mv gnujump-1.0.8.tar.gz gnujump\_1.0.8.orig.tar.gz}
\hbr
\item \texttt{tar xf gnujump\_1.0.8.orig.tar.gz}
\hbr
\item \texttt{cd gnujump-1.0.8/}
\hbr
\item \texttt{dh\_make -f ../gnujump-1.0.8.tar.gz}
\begin{itemize}
\item \small 套件種類: 單一二進制 (for now)
\end{itemize}
\end{itemize}
\begin{lstlisting}[basicstyle=\ttfamily\small]
gnujump-1.0.8$ ls debian/
changelog gnujump.default.ex preinst.ex
compat gnujump.doc-base.EX prerm.ex
control init.d.ex README.Debian
copyright manpage.1.ex README.source
docs manpage.sgml.ex rules
emacsen-install.ex manpage.xml.ex source
emacsen-remove.ex menu.ex watch.ex
emacsen-startup.ex postinst.ex
gnujump.cron.d.ex postrm.ex
\end{lstlisting}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (2)}
\begin{itemize}
\item 注意 \texttt{debian/changelog}, \texttt{debian/rules},
\texttt{debian/control}\\ (由 \textbf{dh\_make}自動生成)
\hbr
\item 在\texttt{debian/control}:\\ \texttt{Build-Depends: debhelper (>= 7.0.50~),
autotools-dev}\\ 列出\textsl{build-dependencies} = packages 來滿足構建套件的需求
\hbr
\item 可透過\texttt{debuild} (感謝 \textbf{dh})來構建套件
\begin{itemize}
\item And add build-dependencies, until it builds
\item 提示: 使用 \texttt{apt-cache search} 以及 \texttt{apt-file}來尋找套件
\item 範例:
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
checking for sdl-config... no
checking for SDL - version >= 1.2.0... no
[...]
configure: error: *** SDL version 1.2.0 not found!
\end{lstlisting}
$\rightarrow$ 將 \textbf{libsdl1.2-dev} 加入 Build-Depends並且安裝.
\hbr
\item 建議方法: 使用 \textbf{pbuilder} 來構建一個乾淨的環境
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (3)}
\begin{itemize}
\item 構建所需安裝的套件有\texttt{libsdl1.2-dev, libsdl-image1.2-dev, libsdl-mixer1.2-dev}
\item 接著, 你可能會遇到其他錯誤:
\end{itemize}
\begin{lstlisting}[basicstyle=\ttfamily\tiny]
/usr/bin/ld: SDL_rotozoom.o: undefined reference to symbol 'ceil@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:376: recipe for target 'gnujump' failed
\end{lstlisting}
\begin{itemize}
\item 這個問題主要是因為bitrot: gnujump需要照下列linker修改來調整.
\item 如果你使用原始碼格式版本為\textbf{1.0},你可以直接修改上游原始碼.
\begin{itemize}
\item 編輯\texttt{src/Makefile.am}並替換
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = $(all_libraries)
\end{lstlisting}
成下列
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = -Wl,--as-needed
gnujump_LDADD = $(all_libraries) -lm
\end{lstlisting}
\item 接著執行 \texttt{autoreconf -i}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (4)}
\begin{itemize}
\item 如果你使用原始碼格式的版本為 \textbf{3.0 (quilt)}, 請使用 \texttt{quilt} 來準備補丁. (可參照
\url{https://wiki.debian.org/UsingQuilt})
\begin{itemize}
\item \texttt{export QUILT\_PATCHES=debian/patches}
\item \texttt{mkdir debian/patches}\\ \texttt{quilt new linker-fixes.patch}\\
\texttt{quilt add src/Makefile.am}\\
\hbr
\item 編輯\texttt{src/Makefile.am}並替換
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = $(all_libraries)
\end{lstlisting}
成下列
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
gnujump_LDFLAGS = -Wl,--as-needed
gnujump_LDADD = $(all_libraries) -lm
\end{lstlisting}
\hbr
\item \texttt{quilt refresh}
\hbr
\item 由於 \texttt{src/Makefile.am} 已被修改,
所以在構建時必須要呼叫autoreconf. 另外也可以使用\texttt{dh}來進行自動化, 可修改\texttt{dh} 在
\texttt{debian/rules} 的指令.從: \texttt{dh \$\@ -{}-with autotools-dev}\\ 到:
\texttt{dh \$\@ -{}-with autotools-dev -{}-with autoreconf}
\hbr
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (5)}
\begin{itemize}
\item 此套件理應完成正常構建.
\hbr
\item 使用 \texttt{debc} 來列出套件的內容,並且使用 \texttt{debi}來進行安裝以及測試.
\hbr
\item 使用 \texttt{lintian}來測試套件
\begin{itemize}
\item 雖不是強制性的要求, 但推薦使用 \textsl{lintian-clean}來上傳套件到Debian
\hbr
\item 可透過 \texttt{lintian -EviIL +pedantic}列出更多問題
\hbr
\item 小提示:
\begin{itemize}
\item 移除在\texttt{debian/}中不必要的檔案
\hbr
\item 填好 \texttt{debian/control}
\hbr
\item 透過覆蓋 \texttt{dh\_auto\_configure} 安裝執行檔到 \texttt{/usr/games}
\hbr
\item 使用 \textsl{hardening} 編譯 flags 來增加安全性.\\ 參照
\url{https://wiki.debian.org/Hardening}
\end{itemize}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{循序漸進\ldots (6)}
\begin{itemize}
\item 將你的套件和 Debian 上的套件進行差異比對:
\begin{itemize}
\item 它將檔案分開放到第二個套件中, 讓所有平台架構都可以一起共用($\rightarrow$ 可讓 Debian 檔案庫節省不必要的空間)
\hbr
\item 它安裝 .desktop 檔案(給 GNOME/KDE 選單) 並且整合到Debian 選單中
\hbr
\item 透過補丁來修補一些次要的問題
\end{itemize}
\end{itemize}
\end{frame}
\subsection{實際演練 3: 打包 Java library}
\begin{frame}{實際演練 3: 打包 Java library}
\begin{enumerate}
\item 先看一下如何打包 Java 相關文件:\\
\begin{itemize}
\item \url{https://wiki.debian.org/Java}
\hbr
\item \url{https://wiki.debian.org/Java/Packaging}
\hbr
\item \url{https://www.debian.org/doc/packaging-manuals/java-policy/}
\hbr
\item \texttt{/usr/share/doc/javahelper/tutorial.txt.gz}
\end{itemize}
\br
\item 從 \url{http://moepii.sourceforge.net/} 下載 IRClib
\br
\item 開始打包
\end{enumerate}
\end{frame}
\begin{frame}{循序漸進\ldots}
\begin{itemize}
\item \texttt{apt-get install javahelper}
\hbr
\item 創建一個基本的原始碼套件: \texttt{jh\_makepkg}
\begin{itemize}
\item 函式庫
\item 無
\item Default Free compiler/runtime
\end{itemize}
\hbr
\item 修正 \texttt{debian/*}
\hbr
\item \texttt{dpkg-buildpackage -us -uc} or \texttt{debuild}
\hbr
\item \texttt{lintian}, \texttt{debc}, 等等.
\hbr
\item 將你的套件和\texttt{libirclib-java}原始碼套件進行差異比對
\end{itemize}
\end{frame}
\subsection{實際演練 4: 打包 Ruby gem}
\begin{frame}{實際演練 4: 打包 Ruby gem}
\begin{enumerate}
\item 先看一下如何打包 Ruby 相關文件:\\
\begin{itemize}
\item \url{https://wiki.debian.org/Ruby}
\hbr
\item \url{https://wiki.debian.org/Teams/Ruby}
\hbr
\item \url{https://wiki.debian.org/Teams/Ruby/Packaging}
\hbr
\item \texttt{gem2deb(1)}, \texttt{dh\_ruby(1)} (\texttt{gem2deb} 套件)
\end{itemize}
\hbr
\item 從 \texttt{peach} gem:\\ \texttt{gem2deb peach} 建立基本的 Debian 原始碼套件
\hbr
\item 適時的優化, 讓它成為一個合適的 Debian 套件
\end{enumerate}
\end{frame}
\begin{frame}{循序漸進\ldots}
\texttt{gem2deb peach}:
\begin{itemize}
\item 從 rubygems.org 下載 gem 回來
\item 建立一個正確的 .orig.tar.gz 檔案,並且解壓縮
\item 根據描述 gem 套件相關資訊的檔案來初始化 Debian 原始碼套件
\begin{itemize}
\item 命名為 \texttt{ruby-\textsl{gemname}}
\end{itemize}
\item 嘗試構建 Debian 二進制套件 (也許會失敗)
\end{itemize}
\br
\texttt{dh\_ruby} ( 在\textsl{gem2deb}裡) 執行 Ruby 特定相關任務:
\begin{itemize}
\item 替每個 Ruby 版本皆構建 C 擴充功能
\item 將檔案複製到每個目的端目錄
\item 更新每一個執行腳本中的shebang符號(\#!)
\item 執行定義在 \texttt{debian/ruby-tests.rb}, \texttt{debian/ruby-tests.rake}中的測試,
或者其他種類的驗證 \texttt{debian/ruby-test-files.yaml}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (2)}
優化產生的套件:
\begin{itemize}
\item 執行 \texttt{debclean} 來清除原始碼樹工具. 請看 \texttt{debian/}.
\hbr
\item \texttt{changelog} 以及 \texttt{compat}需要被修正
\hbr
\item 編輯 \texttt{debian/control}: 優化 \texttt{Description}
\hbr
\item 根據上游檔案來寫對應的 \texttt{copyright}
\hbr
\item 構建套件
\hbr
\item 將你的套件和 Debian 檔案庫中的 \texttt{ruby-peach} 套件比對
\end{itemize}
\end{frame}
\subsection{實際演練 5: 打包 Perl 模組}
\begin{frame}[fragile=singleslide]{實際演練 5: 打包 Perl 模組}
\begin{enumerate}
\item 先看一下如何打包 Perl 相關文件:\\
\begin{itemize}
\item \url{https://perl-team.pages.debian.net}
\hbr
\item \url{https://wiki.debian.org/Teams/DebianPerlGroup}
\hbr
\item \texttt{dh-make-perl(1)}, \texttt{dpt(1)} (in the \texttt{pkg-perl-tools}
package)
\end{itemize}
\hbr
\item 從 \texttt{Acme} CPAN 發行版:\\ \verb|dh-make-perl --cpan Acme| 建立基本的 Debian
原始碼套件
\hbr
\item 適時的優化, 讓它成為一個合適的 Debian 套件
\end{enumerate}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots}
\verb|dh-make-perl --cpan Acme|:
\begin{itemize}
\item 從 CPAN 下載壓縮檔案
\item 創建適合的 .orig.tar.gz 檔案, 並且解壓縮
\item 根據描述發行版相關資訊的檔案初始化 Debian 原始碼套件
\begin{itemize}
\item 取名為\texttt{lib\textsl{distname}-perl}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]{循序漸進\ldots (2)}
優化產生的套件:
\begin{itemize}
\item \texttt{debian/changelog}, \texttt{debian/compat},
\texttt{debian/libacme-perl.docs}, 以及\texttt{debian/watch} 這些內容需正確無誤
\hbr
\item 編輯 \texttt{debian/control}: 優化\texttt{Description}, 並且移除底部的樣版
\hbr
\item 編輯\texttt{debian/copyright}: 將置頂的樣版移除, 加入著作權的年份到
\texttt{Files:\hspace{0.3em}*} 的章節中
\end{itemize}
\end{frame}
\section*{翻譯}
\begin{frame}{翻譯}
本教學指南由 SZ Lin (林上智) 翻譯成繁體中文
\hbr
若有任何翻譯上的建議, 請發信至
\href{mailto:debian-chinese-big5@lists.debian.org}{\texttt{<debian-chinese-big5@lists.debian.org>}}
\end{frame}
\end{document}
|