\u65b9\u6cd5 1\uff1a \u4e0d\u8981\u4e0a\u4f20\u4f60\u7684 snap \u5230\u5546\u5e97<\/strong><\/div>\n\u8fd9\u662f\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u4e86\u3002\u9996\u5148\u770b\u4e00\u4e0b\u8fd9\u4e2a\u6709\u5173\u6a21\u578b\u5b9a\u4e49\u7684\u4f8b\u5b50\u2014\u2014amd64-model.json\uff1a<\/p>\n
{\r\n\"type\": \"model\",\r\n\"series\": \"16\",\r\n\"model\": \"custom-amd64\",\r\n\"architecture\": \"amd64\",\r\n\"gadget\": \"pc\",\r\n\"kernel\": \"pc-kernel\",\r\n\"authority-id\": \"4tSgWHfAL1vm9l8mSiutBDKnnSQBv0c8\",\r\n\"brand-id\": \"4tSgWHfAL1vm9l8mSiutBDKnnSQBv0c8\",\r\n\"timestamp\": \"2017-06-23T21:03:24+00:00\",\r\n\"required-snaps\": [\"kyrofa-test-snap\"]\r\n}\r\n<\/pre>\n\u8ba9\u6211\u4eec\u5c06\u5b83\u8f6c\u6362\u6210\u6a21\u578b\u65ad\u8a00\uff1a<\/p>\n
$ cat amd64-model.json | snap sign -k my-key-name > amd64.model\r\nYou need a passphrase to unlock the secret key for\r\nuser: \"my-key-name\"\r\n4096-bit RSA key, ID 0B79B865, created 2016-01-01\r\n...<\/pre>\n\u83b7\u5f97\u6a21\u578b\u65ad\u8a00\uff1aamd64.model \u540e\uff0c\u5982\u679c\u4f60\u73b0\u5728\u5c31\u628a\u5b83\u4ea4\u7ed9 ubuntu-image \u4f7f\u7528\uff0c\u4f60\u5c06\u4f1a\u78b0\u9489\u5b50\uff1a<\/p>\n
$ sudo ubuntu-image -c stable amd64.model\r\nFetching core\r\nFetching pc-kernel\r\nFetching pc\r\nFetching kyrofa-test-snap\r\nerror: cannot find snap \"kyrofa-test-snap\": snap not found\r\nCOMMAND FAILED: snap prepare-image --channel=stable amd64.model \/tmp\/tmp6p453gk9\/unpack<\/pre>\n\u5b9e\u9645\u4e0a\u5546\u5e97\u4e2d\u5e76\u6ca1\u6709\u540d\u4e3a kyrofa-test-snap \u7684 snap\u3002\u8fd9\u91cc\u9700\u8981\u91cd\u70b9\u8bf4\u660e\u7684\u662f\uff1a\u6a21\u578b\u5b9a\u4e49\uff08\u4ee5\u53ca\u8f6c\u6362\u540e\u7684\u65ad\u8a00\uff09\u53ea\u5305\u542b\u4e86\u4e00\u7cfb\u5217\u7684 snap \u7684\u540d\u5b57\u3002\u5982\u679c\u4f60\u5728\u672c\u5730\u6709\u4e2a\u90a3\u4e2a\u540d\u5b57\u7684 snap\uff0c\u5373\u4f7f\u5b83\u6ca1\u6709\u5b58\u5728\u4e8e\u5546\u5e97\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 --extra-snaps \u9009\u9879\u544a\u8bc9 ubuntu-image \u5728\u65ad\u8a00\u4e2d\u5339\u914d\u8fd9\u4e2a\u540d\u5b57\u6765\u4f7f\u7528\u5b83\uff1a<\/p>\n
$ sudo ubuntu-image -c stable \\\r\n--extra-snaps \/path\/to\/kyrofa-test-snap_0.1_amd64.snap \\\r\namd64.model\r\nFetching core\r\nFetching pc-kernel\r\nFetching pc\r\nCopying \"\/path\/to\/kyrofa-test-snap_0.1_amd64.snap\" (kyrofa-test-snap)\r\nkyrofa-test-snap already prepared, skipping\r\nWARNING: \"kyrofa-test-snap\" were installed from local snaps\r\ndisconnected from a store and cannot be refreshed subsequently!\r\nPartition size\/offset need to be a multiple of sector size (512).\r\nThe size\/offset will be rounded up to the nearest sector.<\/pre>\n\u73b0\u5728\uff0c\u5728 snap \u5e76\u6ca1\u6709\u4e0a\u4f20\u5230\u5546\u5e97\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u5df2\u7ecf\u83b7\u5f97\u4e00\u4e2a\u9884\u88c5\u4e86\u79c1\u6709 snap \u7684 Ubuntu Core \u955c\u50cf\uff08\u540d\u4e3a pc.img\uff09\u3002\u4f46\u662f\u8fd9\u6837\u505a\u6709\u4e00\u4e2a\u5f88\u5927\u7684\u95ee\u9898\uff0cubuntu-image \u4f1a\u63d0\u793a\u4e00\u4e2a\u8b66\u544a\uff1a\u4e0d\u901a\u8fc7\u8fde\u63a5\u5546\u5e97\u9884\u88c5 snap \u610f\u5473\u7740\u4f60\u6ca1\u6709\u529e\u6cd5\u5728\u70e7\u5f55\u4e86\u8fd9\u4e9b\u955c\u50cf\u7684\u8bbe\u5907\u4e0a\u66f4\u65b0\u5b83\u3002\u4f60\u53ea\u80fd\u901a\u8fc7\u5236\u4f5c\u65b0\u7684\u955c\u50cf\u5e76\u91cd\u65b0\u70e7\u5f55\u5230\u8bbe\u5907\u7684\u65b9\u5f0f\u6765\u66f4\u65b0\u5b83\u3002<\/p>\n
\u65b9\u6cd5 2\uff1a \u4f7f\u7528\u54c1\u724c\u5546\u5e97<\/strong><\/div>\n\u5f53\u4f60\u6ce8\u518c\u4e86\u4e00\u4e2a\u5546\u5e97\u8d26\u53f7\u5e76\u8bbf\u95ee dashboard.snapcraft.io \u65f6\uff0c\u4f60\u5176\u5b9e\u662f\u5728\u6807\u51c6\u7684 Ubuntu \u5546\u5e97\u4e2d\u67e5\u770b\u4f60\u7684 snap\u3002\u5982\u679c\u4f60\u662f\u5728\u7cfb\u7edf\u4e2d\u65b0\u5b89\u88c5\u7684 snapd\uff0c\u9ed8\u8ba4\u4f1a\u4ece\u8fd9\u4e2a\u5546\u5e97\u4e0b\u8f7d\u3002\u867d\u7136\u4f60\u53ef\u4ee5\u5728 Ubuntu \u5546\u5e97\u4e2d\u53d1\u5e03\u79c1\u6709\u7684 snap\uff0c\u4f46\u662f\u4f60\u4e0d\u80fd\u5c06\u5b83\u4eec\u9884\u88c5\u5230\u955c\u50cf\u4e2d\uff0c\u56e0\u4e3a\u53ea\u6709\u4f60\uff08\u4ee5\u53ca\u4f60\u6dfb\u52a0\u7684\u5408\u4f5c\u8005\uff09\u624d\u6709\u6743\u9650\u53bb\u4f7f\u7528\u5b83\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5236\u4f5c\u955c\u50cf\u7684\u552f\u4e00\u65b9\u5f0f\u5c31\u662f\u516c\u5f00\u53d1\u5e03\u4f60\u7684 snap\uff0c\u7136\u800c\u8fd9\u5e76\u4e0d\u7b26\u5408\u8fd9\u7bc7\u5e16\u5b50\u7684\u76ee\u7684\u3002<\/p>\n
\u5bf9\u4e8e\u8fd9\u79cd\u7528\u4f8b\uff0c\u6211\u4eec\u6709\u6240\u8c13\u7684 \u54c1\u724c\u5546\u5e97\u3002\u54c1\u724c\u5546\u5e97\u4ecd\u7136\u6258\u7ba1\u5728 Ubuntu \u5546\u5e97\u91cc\uff0c\u4f46\u662f\u5b83\u4eec\u662f\u9488\u5bf9\u4e8e\u67d0\u4e00\u7279\u5b9a\u516c\u53f8\u6216\u8bbe\u5907\u7684\u4e00\u4e2a\u5b9a\u5236\u7684\u3001\u4e13\u95e8\u7684\u7248\u672c\u3002\u54c1\u724c\u5546\u5e97\u53ef\u4ee5\u7ee7\u627f\u6216\u8005\u4e0d\u7ee7\u627f\u6807\u51c6\u7684 Ubuntu \u5546\u5e97\uff0c\u54c1\u724c\u5546\u5e97\u4e5f\u53ef\u4ee5\u9009\u62e9\u5f00\u653e\u7ed9\u6240\u6709\u7684\u5f00\u53d1\u8005\u6216\u8005\u5c06\u5176\u9650\u5236\u5728\u4e00\u4e2a\u7279\u5b9a\u7684\u7ec4\u5185\uff08\u4fdd\u6301\u79c1\u6709\u6b63\u662f\u6211\u4eec\u60f3\u8981\u7684\uff09\u3002<\/p>\n
\u8bf7\u6ce8\u610f\uff0c\u8fd9\u662f\u4e00\u4e2a\u4ed8\u8d39\u529f\u80fd\u3002\u4f60\u9700\u8981 \u7533\u8bf7\u4e00\u4e2a\u54c1\u724c\u5546\u5e97\u3002\u8bf7\u6c42\u901a\u8fc7\u540e\uff0c\u4f60\u5c06\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u7528\u6237\u540d\u4e0b\u7684 \u201cstores you can access\u201d \u770b\u5230\u4f60\u7684\u65b0\u5546\u5e97\u3002
\n
\n\u5728\u90a3\u91cc\u4f60\u53ef\u4ee5\u770b\u5230\u591a\u4e2a\u6709\u6743\u4f7f\u7528\u7684\u5546\u5e97\u3002\u6700\u5c11\u7684\u60c5\u51b5\u4e0b\u4e5f\u4f1a\u6709\u4e24\u4e2a\uff1a\u6807\u51c6\u7684 Ubuntu \u5546\u5e97\u4ee5\u53ca\u4f60\u7684\u65b0\u7684\u54c1\u724c\u5546\u5e97\u3002\u9009\u62e9\u54c1\u724c\u5546\u5e97\uff08\u7ea2\u6846\uff09\uff0c\u8fdb\u53bb\u540e\u8bb0\u5f55\u4e0b\u4f60\u7684\u5546\u5e97 ID\uff08\u84dd\u6846\uff09\uff1a\u7b49\u4e0b\u4f60\u5c06\u4f1a\u7528\u5230\u5b83\u3002
\n
\n\u5728\u54c1\u724c\u5546\u5e97\u91cc\u6ce8\u518c\u540d\u5b57\u6216\u8005\u4e0a\u4f20 snap \u548c\u6807\u51c6\u7684\u5546\u5e97\u4f7f\u7528\u7684\u65b9\u6cd5\u662f\u4e00\u6837\u7684\uff0c\u53ea\u662f\u5b83\u4eec\u73b0\u5728\u662f\u4e0a\u4f20\u5230\u4f60\u7684\u54c1\u724c\u5546\u5e97\u800c\u4e0d\u662f\u6807\u51c6\u7684\u90a3\u4e2a\u3002\u5982\u679c\u4f60\u5c06\u54c1\u724c\u5546\u5e97\u653e\u5728 unlisted \u91cc\u9762\uff0c\u90a3\u4e48\u8fd9\u4e9b snap \u5bf9\u5916\u90e8\u7528\u6237\u662f\u4e0d\u53ef\u89c1\u3002\u4f46\u662f\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\u7b2c\u4e00\u6b21\u4e0a\u4f20 snap \u7684\u65f6\u5019\u9700\u8981\u901a\u8fc7 web \u754c\u9762\u6765\u64cd\u4f5c\u3002\u5728\u90a3\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u7ee7\u7eed\u50cf\u5f80\u5e38\u4e00\u6837\u4f7f\u7528 Snapcraft \u6765\u64cd\u4f5c\u3002<\/p>\n
\u90a3\u4e48\u8fd9\u4e9b\u662f\u5982\u4f55\u6539\u53d8\u7684\u5462\uff1f\u6211\u7684 \u201ckyrofal-store\u201d \u4ece Ubuntu \u5546\u5e97\u7ee7\u627f\u4e86 snap\uff0c\u5e76\u4e14\u8fd8\u5305\u542b\u4e00\u4e2a\u53d1\u5e03\u5728\u7a33\u5b9a\u901a\u9053\u4e2d\u7684 \u201ckyrofa-bran-test-snap\u201d \u3002\u8fd9\u4e2a snap \u5728 Ubuntu \u5546\u5e97\u91cc\u662f\u4f7f\u7528\u4e0d\u4e86\u7684\uff0c\u5982\u679c\u4f60\u53bb\u641c\u7d22\u5b83\uff0c\u4f60\u662f\u627e\u4e0d\u5230\u7684\uff1a<\/p>\n
$ snap find kyrofa-branded\r\nThe search \"kyrofa-branded\" returned 0 snaps<\/pre>\n\u4f46\u662f\u4f7f\u7528\u6211\u4eec\u524d\u9762\u8bb0\u5f55\u7684\u5546\u5e97 ID\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u4ece\u54c1\u724c\u5546\u5e97\u800c\u4e0d\u662f Ubuntu \u5546\u5e97\u4e0b\u8f7d snap \u7684\u6a21\u578b\u65ad\u8a00\u3002\u6211\u4eec\u53ea\u9700\u8981\u5c06 \u201cstore\u201d \u952e\u6dfb\u52a0\u5230 JSON \u6587\u4ef6\u4e2d\uff0c\u5c31\u50cf\u8fd9\u6837\uff1a<\/p>\n
{\r\n\"type\": \"model\",\r\n\"series\": \"16\",\r\n\"model\": \"custom-amd64\",\r\n\"architecture\": \"amd64\",\r\n\"gadget\": \"pc\",\r\n\"kernel\": \"pc-kernel\",\r\n\"authority-id\": \"4tSgWHfAL1vm9l8mSiutBDKnnSQBv0c8\",\r\n\"brand-id\": \"4tSgWHfAL1vm9l8mSiutBDKnnSQBv0c8\",\r\n\"timestamp\": \"2017-06-23T21:03:24+00:00\",\r\n\"required-snaps\": [\"kyrofa-branded-test-snap\"],\r\n\"store\": \"kyek\"\r\n}<\/pre>\n\u4f7f\u7528\u65b9\u6cd5 1 \u4e2d\u7684\u65b9\u5f0f\u5bf9\u5b83\u7b7e\u540d\uff0c\u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u50cf\u8fd9\u6837\u5f88\u7b80\u5355\u7684\u5236\u4f5c\u4e00\u4e2a\u9884\u88c5\u6709\u6211\u4eec\u54c1\u724c\u5546\u5e97\u79c1\u6709 snap \u7684 Ubuntu Core \u955c\u50cf\uff1a<\/p>\n
$ sudo ubuntu-image -c stable amd64.model\r\nFetching core\r\nFetching pc-kernel\r\nFetching pc\r\nFetching kyrofa-branded-test-snap\r\nPartition size\/offset need to be a multiple of sector size (512).\r\nThe size\/offset will be rounded up to the nearest sector.<\/pre>\n\u73b0\u5728\uff0c\u548c\u65b9\u6cd5 1 \u7684\u6700\u540e\u4e00\u6837\uff0c\u4f60\u83b7\u5f97\u4e86\u4e00\u4e2a\u4e3a\u5de5\u5382\u51c6\u5907\u7684 pc.img\u3002\u5e76\u4e14\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u5236\u4f5c\u7684\u955c\u50cf\u4e2d\u7684\u6240\u6709 snap \u90fd\u4ece\u5546\u5e97\u4e0b\u8f7d\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u5c06\u80fd\u50cf\u5e73\u5e38\u4e00\u6837\u81ea\u52a8\u66f4\u65b0\u3002<\/p>\n