mirror of
				https://gitlab.archlinux.org/pacman/pacman.git
				synced 2025-11-04 01:14:41 +01:00 
			
		
		
		
	Compare commits
	
		
			791 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					5caf143faa | ||
| 
						 | 
					e9639ad172 | ||
| 
						 | 
					8d3ee29809 | ||
| 
						 | 
					afc77a808d | ||
| 
						 | 
					c85d155f3a | ||
| 
						 | 
					950443a438 | ||
| 
						 | 
					d5c0f39144 | ||
| 
						 | 
					a6291858cc | ||
| 
						 | 
					3f00a03db4 | ||
| 
						 | 
					d413178354 | ||
| 
						 | 
					a31e8bdff6 | ||
| 
						 | 
					38f0a7d462 | ||
| 
						 | 
					f797749c4e | ||
| 
						 | 
					bf3618a7c1 | ||
| 
						 | 
					6e2c15099a | ||
| 
						 | 
					fb522face1 | ||
| 
						 | 
					cd6ca88c49 | ||
| 
						 | 
					3eee3d67af | ||
| 
						 | 
					47a7ea8c86 | ||
| 
						 | 
					66fe80f39b | ||
| 
						 | 
					a554e1a460 | ||
| 
						 | 
					aa550a85f1 | ||
| 
						 | 
					a97f792d3c | ||
| 
						 | 
					9cd344fb0d | ||
| 
						 | 
					b2ea5f6860 | ||
| 
						 | 
					e42e9ab873 | ||
| 
						 | 
					0ba9b262ab | ||
| 
						 | 
					342924f796 | ||
| 
						 | 
					fa620685fa | ||
| 
						 | 
					8c33d7f1ef | ||
| 
						 | 
					f3f257405b | ||
| 
						 | 
					d5a06e964c | ||
| 
						 | 
					9ec049f518 | ||
| 
						 | 
					0d99b54ba2 | ||
| 
						 | 
					163c36bdcd | ||
| 
						 | 
					62f828014f | ||
| 
						 | 
					d35a7fb6f3 | ||
| 
						 | 
					6c870953c5 | ||
| 
						 | 
					63f04177c3 | ||
| 
						 | 
					1e21aa589d | ||
| 
						 | 
					0cb963df03 | ||
| 
						 | 
					c5652361fb | ||
| 
						 | 
					1366da57fa | ||
| 
						 | 
					6a85e4a9ca | ||
| 
						 | 
					b878157c78 | ||
| 
						 | 
					f9be4eed42 | ||
| 
						 | 
					312e9252f4 | ||
| 
						 | 
					41ef7eff75 | ||
| 
						 | 
					0e5c22e7a1 | ||
| 
						 | 
					0d4ecae625 | ||
| 
						 | 
					1b78e2bb1a | ||
| 
						 | 
					8fd62a39b5 | ||
| 
						 | 
					704ab17a6a | ||
| 
						 | 
					8db7e0c98d | ||
| 
						 | 
					e43c271650 | ||
| 
						 | 
					c9b7f9b0d0 | ||
| 
						 | 
					0ff57350fb | ||
| 
						 | 
					43a2f63194 | ||
| 
						 | 
					2259dff7f3 | ||
| 
						 | 
					93fa63ee8a | ||
| 
						 | 
					fcdaa46b65 | ||
| 
						 | 
					06d761a020 | ||
| 
						 | 
					ce9fd69eba | ||
| 
						 | 
					9876d97839 | ||
| 
						 | 
					51276f1ac5 | ||
| 
						 | 
					08a1244f4e | ||
| 
						 | 
					d90641a894 | ||
| 
						 | 
					6e0c47d22f | ||
| 
						 | 
					f8ed8620d0 | ||
| 
						 | 
					5a67eee78c | ||
| 
						 | 
					79d60f0f42 | ||
| 
						 | 
					81f945e2a5 | ||
| 
						 | 
					9d99914a18 | ||
| 
						 | 
					2c91b991ee | ||
| 
						 | 
					65650f2cdb | ||
| 
						 | 
					e292b1b5a2 | ||
| 
						 | 
					32f3b4304c | ||
| 
						 | 
					7dd1a5a58d | ||
| 
						 | 
					326345b378 | ||
| 
						 | 
					46c10c5bf3 | ||
| 
						 | 
					ce06e6f9b9 | ||
| 
						 | 
					5dada13a1a | ||
| 
						 | 
					e8130b8f2c | ||
| 
						 | 
					6582f68c9d | ||
| 
						 | 
					c8c7a51374 | ||
| 
						 | 
					ea42d03ea1 | ||
| 
						 | 
					ce5ee8a065 | ||
| 
						 | 
					b4459f1e04 | ||
| 
						 | 
					ef5feb15a7 | ||
| 
						 | 
					098cfe516d | ||
| 
						 | 
					8b03b1a877 | ||
| 
						 | 
					6831a5f4b1 | ||
| 
						 | 
					a03f5f55cd | ||
| 
						 | 
					017184fab5 | ||
| 
						 | 
					1b39653e96 | ||
| 
						 | 
					a98bb96b43 | ||
| 
						 | 
					e6b8d5189f | ||
| 
						 | 
					8e2648bf02 | ||
| 
						 | 
					3d142fe8ef | ||
| 
						 | 
					63baba13ec | ||
| 
						 | 
					972528c021 | ||
| 
						 | 
					34749e177d | ||
| 
						 | 
					19754b34a3 | ||
| 
						 | 
					083ac51816 | ||
| 
						 | 
					9995510dc8 | ||
| 
						 | 
					4a1d93b92c | ||
| 
						 | 
					0bbc406ee8 | ||
| 
						 | 
					8803ae3b4d | ||
| 
						 | 
					bc747fbfbf | ||
| 
						 | 
					d5a5a6b512 | ||
| 
						 | 
					578dfcd977 | ||
| 
						 | 
					158a249a77 | ||
| 
						 | 
					c1a84c03b2 | ||
| 
						 | 
					0a5b79e133 | ||
| 
						 | 
					540cae816a | ||
| 
						 | 
					26a79cb29d | ||
| 
						 | 
					8fe8233dfa | ||
| 
						 | 
					87ffc648b7 | ||
| 
						 | 
					1d0a69c655 | ||
| 
						 | 
					3fa2830829 | ||
| 
						 | 
					05b0d7e799 | ||
| 
						 | 
					42b492b2fd | ||
| 
						 | 
					bafee395a6 | ||
| 
						 | 
					572b1a5de7 | ||
| 
						 | 
					390b08f18b | ||
| 
						 | 
					9aead554bc | ||
| 
						 | 
					d2ce93bc54 | ||
| 
						 | 
					17d4ec5ed8 | ||
| 
						 | 
					711b6d3911 | ||
| 
						 | 
					3068b52f9a | ||
| 
						 | 
					829aeb2c2c | ||
| 
						 | 
					5f5469c774 | ||
| 
						 | 
					0d89c10f4b | ||
| 
						 | 
					4ccf16dff5 | ||
| 
						 | 
					31b9b264c1 | ||
| 
						 | 
					198154962b | ||
| 
						 | 
					05745089ac | ||
| 
						 | 
					4ec6848f91 | ||
| 
						 | 
					45b6d36cf7 | ||
| 
						 | 
					c0835ff08e | ||
| 
						 | 
					defa561558 | ||
| 
						 | 
					fc0ec7644c | ||
| 
						 | 
					2d832adf08 | ||
| 
						 | 
					2f137fdd39 | ||
| 
						 | 
					1631255357 | ||
| 
						 | 
					ec339969d9 | ||
| 
						 | 
					7956441350 | ||
| 
						 | 
					5c5cdb0eb9 | ||
| 
						 | 
					f170a94c13 | ||
| 
						 | 
					274c3890b0 | ||
| 
						 | 
					529cf928ab | ||
| 
						 | 
					6617182229 | ||
| 
						 | 
					7edd262a06 | ||
| 
						 | 
					05d83c46fd | ||
| 
						 | 
					33b3b6d9b8 | ||
| 
						 | 
					3aece8f0ee | ||
| 
						 | 
					e1e4bbb79d | ||
| 
						 | 
					2a57c2068c | ||
| 
						 | 
					266b3dd706 | ||
| 
						 | 
					27067b1372 | ||
| 
						 | 
					f21e1f54aa | ||
| 
						 | 
					cb43bd8dfb | ||
| 
						 | 
					8624eddb31 | ||
| 
						 | 
					24a78fe731 | ||
| 
						 | 
					66a9b53141 | ||
| 
						 | 
					8308c7b320 | ||
| 
						 | 
					457642231e | ||
| 
						 | 
					6bbf6e8fa1 | ||
| 
						 | 
					250aaefb27 | ||
| 
						 | 
					a64a713fc2 | ||
| 
						 | 
					89ecf8cabe | ||
| 
						 | 
					e3d8197d67 | ||
| 
						 | 
					801f7d1033 | ||
| 
						 | 
					ad280e1b56 | ||
| 
						 | 
					b27886ab59 | ||
| 
						 | 
					132e1ac10c | ||
| 
						 | 
					c628d649f6 | ||
| 
						 | 
					4a8c2852a8 | ||
| 
						 | 
					993700bc6b | ||
| 
						 | 
					bb4d2b72c1 | ||
| 
						 | 
					60b192e383 | ||
| 
						 | 
					9c160cf3f3 | ||
| 
						 | 
					7a83cd003a | ||
| 
						 | 
					49c5f515e9 | ||
| 
						 | 
					09295f7e40 | ||
| 
						 | 
					86eefc1a3a | ||
| 
						 | 
					b5709b8171 | ||
| 
						 | 
					e13a3bf599 | ||
| 
						 | 
					46e9afdd74 | ||
| 
						 | 
					925d44bde6 | ||
| 
						 | 
					b6320de4be | ||
| 
						 | 
					27d9c25ee2 | ||
| 
						 | 
					965e1de217 | ||
| 
						 | 
					fe0586e240 | ||
| 
						 | 
					b455bbc91d | ||
| 
						 | 
					342f079f7e | ||
| 
						 | 
					04821ea9ca | ||
| 
						 | 
					241d6b884a | ||
| 
						 | 
					d5a6ce8ca1 | ||
| 
						 | 
					5aaf5bcf83 | ||
| 
						 | 
					23f93118d0 | ||
| 
						 | 
					163ba4016e | ||
| 
						 | 
					495460d717 | ||
| 
						 | 
					6a804d55dd | ||
| 
						 | 
					dd3762edc4 | ||
| 
						 | 
					2616cb5fdc | ||
| 
						 | 
					038b1815d0 | ||
| 
						 | 
					60d2588192 | ||
| 
						 | 
					1dd3405813 | ||
| 
						 | 
					5186f702d3 | ||
| 
						 | 
					7d27b2b0f4 | ||
| 
						 | 
					ddd2b9e6f6 | ||
| 
						 | 
					01e093d0ae | ||
| 
						 | 
					327c272bb4 | ||
| 
						 | 
					cfd9f1cc69 | ||
| 
						 | 
					18ddf90ff4 | ||
| 
						 | 
					097d5a478b | ||
| 
						 | 
					0445c68d9b | ||
| 
						 | 
					da3a0333de | ||
| 
						 | 
					ad3a26c615 | ||
| 
						 | 
					f5d904d97f | ||
| 
						 | 
					422a4021e4 | ||
| 
						 | 
					a9ad5a75f2 | ||
| 
						 | 
					1dc3de3f69 | ||
| 
						 | 
					95f566d98a | ||
| 
						 | 
					53d610e0a5 | ||
| 
						 | 
					0c74ffd6b6 | ||
| 
						 | 
					964640fbfc | ||
| 
						 | 
					c8417f3386 | ||
| 
						 | 
					5a5e712c74 | ||
| 
						 | 
					8e736e1c9a | ||
| 
						 | 
					62f1c590fc | ||
| 
						 | 
					7a24f909fc | ||
| 
						 | 
					d0e5cd2c7f | ||
| 
						 | 
					9a24f1ffc5 | ||
| 
						 | 
					63a2874fe4 | ||
| 
						 | 
					eb9e74ecc7 | ||
| 
						 | 
					0c2edbdd49 | ||
| 
						 | 
					4a427dbc1b | ||
| 
						 | 
					5a247ccbd4 | ||
| 
						 | 
					927fdc0079 | ||
| 
						 | 
					1c2cfc5bad | ||
| 
						 | 
					9cd7ff807d | ||
| 
						 | 
					948f135a73 | ||
| 
						 | 
					88e7ea421e | ||
| 
						 | 
					28d404f16a | ||
| 
						 | 
					80bc89c147 | ||
| 
						 | 
					2fad78974d | ||
| 
						 | 
					c1abfeae1e | ||
| 
						 | 
					6860e2f703 | ||
| 
						 | 
					254329f6fb | ||
| 
						 | 
					dbbe3e7cb4 | ||
| 
						 | 
					13667fd4b1 | ||
| 
						 | 
					7e8d9dfda2 | ||
| 
						 | 
					a5e81f5599 | ||
| 
						 | 
					bd4ff4a377 | ||
| 
						 | 
					a53fd79632 | ||
| 
						 | 
					6be96e7612 | ||
| 
						 | 
					6c22ef2c82 | ||
| 
						 | 
					7199fb3b1a | ||
| 
						 | 
					a459156a4e | ||
| 
						 | 
					d9e8197e60 | ||
| 
						 | 
					8054a254cb | ||
| 
						 | 
					1c0c292728 | ||
| 
						 | 
					e1fdcfb145 | ||
| 
						 | 
					c4c5b8ba1d | ||
| 
						 | 
					6b1deedf15 | ||
| 
						 | 
					3536975bbf | ||
| 
						 | 
					3531533c2f | ||
| 
						 | 
					86233476b0 | ||
| 
						 | 
					0285c678ab | ||
| 
						 | 
					3232c975c6 | ||
| 
						 | 
					93148d0879 | ||
| 
						 | 
					fbf96203ab | ||
| 
						 | 
					fc35b16fd4 | ||
| 
						 | 
					b1d614a01d | ||
| 
						 | 
					b25dda737b | ||
| 
						 | 
					fe8bd95092 | ||
| 
						 | 
					ded25aeb98 | ||
| 
						 | 
					40d6894910 | ||
| 
						 | 
					768c8ba100 | ||
| 
						 | 
					977489d9ab | ||
| 
						 | 
					1d0ab50c05 | ||
| 
						 | 
					b57ada336b | ||
| 
						 | 
					2abe1f1646 | ||
| 
						 | 
					3b02f80dcb | ||
| 
						 | 
					ea452d0277 | ||
| 
						 | 
					8b9cb8e03d | ||
| 
						 | 
					306c274239 | ||
| 
						 | 
					7a4f76c2af | ||
| 
						 | 
					2d347132ba | ||
| 
						 | 
					800799ea63 | ||
| 
						 | 
					03ea8ca6a9 | ||
| 
						 | 
					c926c39b04 | ||
| 
						 | 
					34b52c9a60 | ||
| 
						 | 
					8f5ee72974 | ||
| 
						 | 
					7262f4bed4 | ||
| 
						 | 
					8550680924 | ||
| 
						 | 
					aa50df630c | ||
| 
						 | 
					369c5aa7dd | ||
| 
						 | 
					c4ab50584f | ||
| 
						 | 
					f7558856b1 | ||
| 
						 | 
					37de9df7c0 | ||
| 
						 | 
					87f9377b32 | ||
| 
						 | 
					e32d129967 | ||
| 
						 | 
					ea35ce5d2e | ||
| 
						 | 
					de7a5cf346 | ||
| 
						 | 
					03f2e2360a | ||
| 
						 | 
					140c76d328 | ||
| 
						 | 
					9648887481 | ||
| 
						 | 
					bad00696f3 | ||
| 
						 | 
					89319b5bfd | ||
| 
						 | 
					19b8298ce8 | ||
| 
						 | 
					0fe562011c | ||
| 
						 | 
					632912261a | ||
| 
						 | 
					c52bb7030c | ||
| 
						 | 
					527ae7092d | ||
| 
						 | 
					a50d1bc9ab | ||
| 
						 | 
					024bc44a25 | ||
| 
						 | 
					0c95b294e9 | ||
| 
						 | 
					8853a6f282 | ||
| 
						 | 
					c9b31ad622 | ||
| 
						 | 
					a818766c6e | ||
| 
						 | 
					7e4aa9e524 | ||
| 
						 | 
					d51902c978 | ||
| 
						 | 
					062204daa1 | ||
| 
						 | 
					c887ccf905 | ||
| 
						 | 
					e0cd7b0293 | ||
| 
						 | 
					4b129d4843 | ||
| 
						 | 
					b1e75d7dd6 | ||
| 
						 | 
					6c8def6ae0 | ||
| 
						 | 
					7fd56118d0 | ||
| 
						 | 
					b3e82ec59e | ||
| 
						 | 
					2042b79bcc | ||
| 
						 | 
					888020de90 | ||
| 
						 | 
					cca9849fc2 | ||
| 
						 | 
					aa6fe1160b | ||
| 
						 | 
					682c9af846 | ||
| 
						 | 
					91d119af1c | ||
| 
						 | 
					57e06394dd | ||
| 
						 | 
					1a04e2e11a | ||
| 
						 | 
					a922d18056 | ||
| 
						 | 
					e806414407 | ||
| 
						 | 
					d338b3981d | ||
| 
						 | 
					ec5e6d9029 | ||
| 
						 | 
					d46bb6b27b | ||
| 
						 | 
					72d3713cc7 | ||
| 
						 | 
					70d8c2150e | ||
| 
						 | 
					41dae68952 | ||
| 
						 | 
					fa2eadcec7 | ||
| 
						 | 
					eb87155391 | ||
| 
						 | 
					6f47dfc920 | ||
| 
						 | 
					e3772f7654 | ||
| 
						 | 
					49dbebcc36 | ||
| 
						 | 
					7193ce1ecd | ||
| 
						 | 
					647b9ea6d9 | ||
| 
						 | 
					eb25a18571 | ||
| 
						 | 
					065b7f863a | ||
| 
						 | 
					b782388f16 | ||
| 
						 | 
					52550a2a0a | ||
| 
						 | 
					d2669b4781 | ||
| 
						 | 
					e94876089a | ||
| 
						 | 
					f619bc61f5 | ||
| 
						 | 
					cc6fb2e8a7 | ||
| 
						 | 
					3fb934b59a | ||
| 
						 | 
					a6bd14285d | ||
| 
						 | 
					958b41fa5f | ||
| 
						 | 
					ddbd36103d | ||
| 
						 | 
					35ac4e7ef3 | ||
| 
						 | 
					c5e7eeece7 | ||
| 
						 | 
					8fe383860e | ||
| 
						 | 
					7520c0facb | ||
| 
						 | 
					e41ca0f2f6 | ||
| 
						 | 
					392fffe241 | ||
| 
						 | 
					e0daaea38c | ||
| 
						 | 
					5c1ba2d5fd | ||
| 
						 | 
					d7c3164fd5 | ||
| 
						 | 
					ea3439f928 | ||
| 
						 | 
					44e9fdd0e8 | ||
| 
						 | 
					717fdb8ee0 | ||
| 
						 | 
					d6f31dc788 | ||
| 
						 | 
					0c62b36c19 | ||
| 
						 | 
					47711947dd | ||
| 
						 | 
					b1bb2eaa50 | ||
| 
						 | 
					a98fce0896 | ||
| 
						 | 
					ab8431c929 | ||
| 
						 | 
					b58489d29a | ||
| 
						 | 
					e183522e31 | ||
| 
						 | 
					82c999a8bf | ||
| 
						 | 
					377cc23a09 | ||
| 
						 | 
					12866ba791 | ||
| 
						 | 
					5951e9ce84 | ||
| 
						 | 
					e253968b4d | ||
| 
						 | 
					81dd6ddf0c | ||
| 
						 | 
					d310b6f85c | ||
| 
						 | 
					3a24e44206 | ||
| 
						 | 
					19c2347507 | ||
| 
						 | 
					da0dcc29cf | ||
| 
						 | 
					c6e47cb435 | ||
| 
						 | 
					9f751bf492 | ||
| 
						 | 
					f556fe8b4a | ||
| 
						 | 
					74274b5dc3 | ||
| 
						 | 
					7245bc8e8e | ||
| 
						 | 
					6a5370b634 | ||
| 
						 | 
					1d32934769 | ||
| 
						 | 
					9ce4f80db4 | ||
| 
						 | 
					ac990b96e7 | ||
| 
						 | 
					a64a8d6cea | ||
| 
						 | 
					9a76a458b8 | ||
| 
						 | 
					81bc390dc1 | ||
| 
						 | 
					18e0a97209 | ||
| 
						 | 
					7eb6dc2a9c | ||
| 
						 | 
					8abef73ba9 | ||
| 
						 | 
					c4ea4e017f | ||
| 
						 | 
					e533478e02 | ||
| 
						 | 
					363894e27b | ||
| 
						 | 
					9f6a67fee7 | ||
| 
						 | 
					fc9002188b | ||
| 
						 | 
					9d3e59e311 | ||
| 
						 | 
					c2fdc38b78 | ||
| 
						 | 
					ceb2362209 | ||
| 
						 | 
					5de465d63e | ||
| 
						 | 
					233e5f610c | ||
| 
						 | 
					26abe8f600 | ||
| 
						 | 
					2671581123 | ||
| 
						 | 
					951d23e3ec | ||
| 
						 | 
					9e2078b179 | ||
| 
						 | 
					3f202c7808 | ||
| 
						 | 
					1bf05e706b | ||
| 
						 | 
					9d9c12e4e2 | ||
| 
						 | 
					92e20b508d | ||
| 
						 | 
					7fd0d03795 | ||
| 
						 | 
					d214c2347a | ||
| 
						 | 
					5a9f5c60da | ||
| 
						 | 
					4d31709787 | ||
| 
						 | 
					678bdfb0d0 | ||
| 
						 | 
					2e6cb69bf6 | ||
| 
						 | 
					8c7202ca19 | ||
| 
						 | 
					9dd42dc0da | ||
| 
						 | 
					8a9c666a8c | ||
| 
						 | 
					6d2fb6fd81 | ||
| 
						 | 
					52a9a5240a | ||
| 
						 | 
					82b7122542 | ||
| 
						 | 
					e0afd81d18 | ||
| 
						 | 
					dbc58d9386 | ||
| 
						 | 
					20ff0cd40f | ||
| 
						 | 
					1583a2079c | ||
| 
						 | 
					953415c86a | ||
| 
						 | 
					242411a1b4 | ||
| 
						 | 
					22050f18f4 | ||
| 
						 | 
					d38a1c02db | ||
| 
						 | 
					6d10de881e | ||
| 
						 | 
					ea4aa6f184 | ||
| 
						 | 
					03acea832a | ||
| 
						 | 
					1b494ab771 | ||
| 
						 | 
					71fcb69028 | ||
| 
						 | 
					b2a2a98297 | ||
| 
						 | 
					ca4f8687f7 | ||
| 
						 | 
					ac6ebcfe93 | ||
| 
						 | 
					59dc631c9a | ||
| 
						 | 
					2d0a00b409 | ||
| 
						 | 
					00ab01e634 | ||
| 
						 | 
					e07a2ab45e | ||
| 
						 | 
					62dbf7ec43 | ||
| 
						 | 
					f61f075b1c | ||
| 
						 | 
					3f9cf8471f | ||
| 
						 | 
					d85c71865e | ||
| 
						 | 
					8679cd68d8 | ||
| 
						 | 
					1eb6a9cbfe | ||
| 
						 | 
					5f71570ec4 | ||
| 
						 | 
					133d174e60 | ||
| 
						 | 
					839953f111 | ||
| 
						 | 
					70d425c1d3 | ||
| 
						 | 
					0fc5aea027 | ||
| 
						 | 
					b9fc709c55 | ||
| 
						 | 
					d7b728591a | ||
| 
						 | 
					6a8e50a69e | ||
| 
						 | 
					ded66fbb62 | ||
| 
						 | 
					8fb1948cd0 | ||
| 
						 | 
					c27a946769 | ||
| 
						 | 
					d158dde30c | ||
| 
						 | 
					31091963ed | ||
| 
						 | 
					468270ce4f | ||
| 
						 | 
					8fe6791928 | ||
| 
						 | 
					dca10b062f | ||
| 
						 | 
					3a82885348 | ||
| 
						 | 
					ca090e10d2 | ||
| 
						 | 
					b729ed0109 | ||
| 
						 | 
					a8a1b093eb | ||
| 
						 | 
					ec91133e38 | ||
| 
						 | 
					30ca48df4c | ||
| 
						 | 
					4b95967bd0 | ||
| 
						 | 
					5f77402577 | ||
| 
						 | 
					793eff3704 | ||
| 
						 | 
					7fcb445f35 | ||
| 
						 | 
					cb5b66367d | ||
| 
						 | 
					b2226ed11b | ||
| 
						 | 
					059c572ca5 | ||
| 
						 | 
					c5d951846d | ||
| 
						 | 
					bcfc2155a0 | ||
| 
						 | 
					f053141c87 | ||
| 
						 | 
					569876f930 | ||
| 
						 | 
					ecd6eddf13 | ||
| 
						 | 
					87c4fb51a4 | ||
| 
						 | 
					62e8812fb9 | ||
| 
						 | 
					3be02aa27c | ||
| 
						 | 
					42d408e0c2 | ||
| 
						 | 
					cb5ae428b6 | ||
| 
						 | 
					b5043dd6c3 | ||
| 
						 | 
					923214497f | ||
| 
						 | 
					1917c845f7 | ||
| 
						 | 
					d11192c73a | ||
| 
						 | 
					bb71d254e2 | ||
| 
						 | 
					0fd477238f | ||
| 
						 | 
					0666b13669 | ||
| 
						 | 
					80a811ec96 | ||
| 
						 | 
					6310bb5fbe | ||
| 
						 | 
					4ca6590af5 | ||
| 
						 | 
					3f1ea8b62f | ||
| 
						 | 
					0145604728 | ||
| 
						 | 
					b5b9860a2e | ||
| 
						 | 
					b752561a52 | ||
| 
						 | 
					3c5d5a19b3 | ||
| 
						 | 
					297916e6a2 | ||
| 
						 | 
					a8f03d07c7 | ||
| 
						 | 
					114d121001 | ||
| 
						 | 
					391769ff89 | ||
| 
						 | 
					969dcddbdf | ||
| 
						 | 
					72ba4fb83f | ||
| 
						 | 
					d7f4e8fbcc | ||
| 
						 | 
					ed353d91b7 | ||
| 
						 | 
					1eeab12228 | ||
| 
						 | 
					7f258619c6 | ||
| 
						 | 
					be0e044404 | ||
| 
						 | 
					c571bd7afb | ||
| 
						 | 
					e66edf817b | ||
| 
						 | 
					38c0ec868b | ||
| 
						 | 
					8da489eac5 | ||
| 
						 | 
					0972b7acfd | ||
| 
						 | 
					e6f72c61a0 | ||
| 
						 | 
					f988aa6b32 | ||
| 
						 | 
					573bd80f14 | ||
| 
						 | 
					44de3183ff | ||
| 
						 | 
					03465ad6b6 | ||
| 
						 | 
					d521f30f07 | ||
| 
						 | 
					9e1a20022d | ||
| 
						 | 
					56f821b72a | ||
| 
						 | 
					930e93b892 | ||
| 
						 | 
					89f4dd88d7 | ||
| 
						 | 
					83e42dccce | ||
| 
						 | 
					f41037358a | ||
| 
						 | 
					952ee5e6cb | ||
| 
						 | 
					47d0df6c10 | ||
| 
						 | 
					5bda38196f | ||
| 
						 | 
					ff58e5cb2d | ||
| 
						 | 
					8de0631edb | ||
| 
						 | 
					1a8c3e52d7 | ||
| 
						 | 
					f34864cc9e | ||
| 
						 | 
					4773c6b66e | ||
| 
						 | 
					5c404268d9 | ||
| 
						 | 
					bc311a24ce | ||
| 
						 | 
					8d26df5ee5 | ||
| 
						 | 
					708a227578 | ||
| 
						 | 
					82abe079ab | ||
| 
						 | 
					09a93b2e0e | ||
| 
						 | 
					e85e77e6f9 | ||
| 
						 | 
					00f29cbc14 | ||
| 
						 | 
					6a636b2b6e | ||
| 
						 | 
					1fe6cabc4d | ||
| 
						 | 
					4ffa0401d2 | ||
| 
						 | 
					cb64fbeac4 | ||
| 
						 | 
					ea7fc8962a | ||
| 
						 | 
					fbfcd86650 | ||
| 
						 | 
					986e99a613 | ||
| 
						 | 
					4b384b7f0b | ||
| 
						 | 
					d1151b5ab9 | ||
| 
						 | 
					687f7b6ba8 | ||
| 
						 | 
					3849c3aec1 | ||
| 
						 | 
					326c6a8eed | ||
| 
						 | 
					5bbe342932 | ||
| 
						 | 
					f8892b9d08 | ||
| 
						 | 
					31d95b8679 | ||
| 
						 | 
					78adb71f20 | ||
| 
						 | 
					fe659153d5 | ||
| 
						 | 
					4899b5bd86 | ||
| 
						 | 
					ca41427141 | ||
| 
						 | 
					242006933d | ||
| 
						 | 
					85712814cd | ||
| 
						 | 
					9a1ff474f1 | ||
| 
						 | 
					edd81f3e8b | ||
| 
						 | 
					6c78f0d560 | ||
| 
						 | 
					13a1d5883c | ||
| 
						 | 
					c7321a7b80 | ||
| 
						 | 
					115c0381c2 | ||
| 
						 | 
					48d63048f1 | ||
| 
						 | 
					991be28672 | ||
| 
						 | 
					e530993392 | ||
| 
						 | 
					7a3f59cd66 | ||
| 
						 | 
					8741551dc9 | ||
| 
						 | 
					3ba5391839 | ||
| 
						 | 
					20a16f55b3 | ||
| 
						 | 
					b4f5a63e7f | ||
| 
						 | 
					e7bc1e3c9a | ||
| 
						 | 
					f8ae60bc28 | ||
| 
						 | 
					294f0fdf4d | ||
| 
						 | 
					31432edcbe | ||
| 
						 | 
					9b1ab3d767 | ||
| 
						 | 
					ea32924c62 | ||
| 
						 | 
					5945241469 | ||
| 
						 | 
					f55be48977 | ||
| 
						 | 
					b7c06d6d67 | ||
| 
						 | 
					b488f229d2 | ||
| 
						 | 
					f12effc6ff | ||
| 
						 | 
					d8e1c450a3 | ||
| 
						 | 
					52afce0a10 | ||
| 
						 | 
					216db87f99 | ||
| 
						 | 
					0fdf0b19ce | ||
| 
						 | 
					17e71fc908 | ||
| 
						 | 
					090ea28942 | ||
| 
						 | 
					e01fdc3dba | ||
| 
						 | 
					e8db984ce5 | ||
| 
						 | 
					47313acee4 | ||
| 
						 | 
					fcbae69fe8 | ||
| 
						 | 
					4f54bde439 | ||
| 
						 | 
					9aa4d9a7b9 | ||
| 
						 | 
					2a73f4e994 | ||
| 
						 | 
					9d1e8084df | ||
| 
						 | 
					7b2f600d71 | ||
| 
						 | 
					5c2928aa25 | ||
| 
						 | 
					9e9835f464 | ||
| 
						 | 
					7ff1b945f6 | ||
| 
						 | 
					41db62b77a | ||
| 
						 | 
					225ee71cae | ||
| 
						 | 
					be038f9cb2 | ||
| 
						 | 
					ac239c54d0 | ||
| 
						 | 
					e50c4a8837 | ||
| 
						 | 
					825b4ff35a | ||
| 
						 | 
					a03c35125e | ||
| 
						 | 
					44f146f232 | ||
| 
						 | 
					edd4276bbf | ||
| 
						 | 
					df47136bcf | ||
| 
						 | 
					de56874cc9 | ||
| 
						 | 
					1eb40c8328 | ||
| 
						 | 
					562109c0e8 | ||
| 
						 | 
					b3612e9cc1 | ||
| 
						 | 
					1b50223f82 | ||
| 
						 | 
					c77cec2ffc | ||
| 
						 | 
					c231c9af97 | ||
| 
						 | 
					24ca6ce1f9 | ||
| 
						 | 
					430b0df779 | ||
| 
						 | 
					d9af1a0cf2 | ||
| 
						 | 
					4e60b9646d | ||
| 
						 | 
					b426488e2b | ||
| 
						 | 
					7b1a86b893 | ||
| 
						 | 
					be229d129e | ||
| 
						 | 
					e8a2c25456 | ||
| 
						 | 
					6e8ca48cbb | ||
| 
						 | 
					b6209b4ba4 | ||
| 
						 | 
					4f02b98338 | ||
| 
						 | 
					73d0d743bd | ||
| 
						 | 
					2b38f4eab7 | ||
| 
						 | 
					36413aa856 | ||
| 
						 | 
					102e6209c7 | ||
| 
						 | 
					24c166f42a | ||
| 
						 | 
					7f51ba99ae | ||
| 
						 | 
					6f9ab22fd8 | ||
| 
						 | 
					2d794cc031 | ||
| 
						 | 
					b7ecff160e | ||
| 
						 | 
					d59324c8ff | ||
| 
						 | 
					a857b9c8e0 | ||
| 
						 | 
					c6e1d4ddde | ||
| 
						 | 
					a1437cbf1b | ||
| 
						 | 
					def9e45aff | ||
| 
						 | 
					6513b0ba59 | ||
| 
						 | 
					f1d9b0a74a | ||
| 
						 | 
					0b9cd9448c | ||
| 
						 | 
					6507fd6bf0 | ||
| 
						 | 
					177beb91c9 | ||
| 
						 | 
					29e94dc065 | ||
| 
						 | 
					eb5cb8ec02 | ||
| 
						 | 
					496f7b4f64 | ||
| 
						 | 
					566f5210ce | ||
| 
						 | 
					2ce4f85f1e | ||
| 
						 | 
					819c28bf8c | ||
| 
						 | 
					627cf6bca8 | ||
| 
						 | 
					39cb865e71 | ||
| 
						 | 
					7113ea4e08 | ||
| 
						 | 
					b264fb9e9d | ||
| 
						 | 
					1b46137426 | ||
| 
						 | 
					a77e638c77 | ||
| 
						 | 
					cd75ae46ab | ||
| 
						 | 
					c34b69b5c7 | ||
| 
						 | 
					38143770a9 | ||
| 
						 | 
					5b749eeee9 | ||
| 
						 | 
					aac639351f | ||
| 
						 | 
					a7cb150931 | ||
| 
						 | 
					e28f321a48 | ||
| 
						 | 
					bec0b0c823 | ||
| 
						 | 
					6b29374a60 | ||
| 
						 | 
					92216c5864 | ||
| 
						 | 
					d95c04945f | ||
| 
						 | 
					7b2f68cc21 | ||
| 
						 | 
					d6ccd44390 | ||
| 
						 | 
					6c1426842a | ||
| 
						 | 
					ee96900605 | ||
| 
						 | 
					71164b76c4 | ||
| 
						 | 
					4c5e7af32f | ||
| 
						 | 
					2a4df070c3 | ||
| 
						 | 
					370c873be5 | ||
| 
						 | 
					8c8f043717 | ||
| 
						 | 
					67290441b8 | ||
| 
						 | 
					3d4656c020 | ||
| 
						 | 
					b75fac5be3 | ||
| 
						 | 
					5f0df42303 | ||
| 
						 | 
					1a1f5540a4 | ||
| 
						 | 
					074cf4cb95 | ||
| 
						 | 
					62fa0c7d8d | ||
| 
						 | 
					781af8f91b | ||
| 
						 | 
					dacda1f6b3 | ||
| 
						 | 
					b5225165c0 | ||
| 
						 | 
					86cb6e1f0f | ||
| 
						 | 
					0e4946d559 | ||
| 
						 | 
					a3a75e0a41 | ||
| 
						 | 
					1038e66964 | ||
| 
						 | 
					48188fbeee | ||
| 
						 | 
					6a1d3948a6 | ||
| 
						 | 
					17e0be9e6a | ||
| 
						 | 
					d85d0ddcfe | ||
| 
						 | 
					61ce2ca1bb | ||
| 
						 | 
					1d98c6347c | ||
| 
						 | 
					5490cd6eb2 | ||
| 
						 | 
					a521cea96f | ||
| 
						 | 
					15aa57d51b | ||
| 
						 | 
					d7f8838294 | ||
| 
						 | 
					f5820c8bd6 | ||
| 
						 | 
					86b5b7aa42 | ||
| 
						 | 
					77af613efc | ||
| 
						 | 
					96b3ba3470 | ||
| 
						 | 
					2141b7112d | ||
| 
						 | 
					2f96067fe7 | ||
| 
						 | 
					5ba8b83b8b | ||
| 
						 | 
					cb898be887 | ||
| 
						 | 
					80868b0da6 | ||
| 
						 | 
					6a9ed33055 | ||
| 
						 | 
					2752932d19 | ||
| 
						 | 
					919b604c29 | ||
| 
						 | 
					dee8144ce5 | ||
| 
						 | 
					f1ec3b9b10 | ||
| 
						 | 
					a3f9399295 | ||
| 
						 | 
					1de5070bb3 | ||
| 
						 | 
					10241a6d76 | ||
| 
						 | 
					902305f163 | ||
| 
						 | 
					64d54f6741 | ||
| 
						 | 
					1a994bf180 | ||
| 
						 | 
					90477f156c | ||
| 
						 | 
					8b3717ef0d | ||
| 
						 | 
					6df558177f | ||
| 
						 | 
					ed3cd75736 | ||
| 
						 | 
					ba7a056d58 | ||
| 
						 | 
					a4ce3edf95 | ||
| 
						 | 
					d5f0395dc1 | ||
| 
						 | 
					a708e7d28e | ||
| 
						 | 
					90ddcbe71d | ||
| 
						 | 
					33bb7dbd35 | ||
| 
						 | 
					32327dc8c9 | ||
| 
						 | 
					89edea326b | ||
| 
						 | 
					d72487cc00 | ||
| 
						 | 
					0b155677cf | ||
| 
						 | 
					6f2faf16ba | ||
| 
						 | 
					e47eb9a777 | ||
| 
						 | 
					b633985e60 | ||
| 
						 | 
					758d3403cd | ||
| 
						 | 
					6e29f02e94 | ||
| 
						 | 
					ae25167bcd | ||
| 
						 | 
					bf84dc4cf1 | ||
| 
						 | 
					a33424f879 | ||
| 
						 | 
					dbd54c0cb9 | ||
| 
						 | 
					0d2600c575 | ||
| 
						 | 
					8605284e0d | ||
| 
						 | 
					9934052b54 | ||
| 
						 | 
					53e525c4f3 | ||
| 
						 | 
					ff87046354 | ||
| 
						 | 
					35e6136f4b | ||
| 
						 | 
					6be492d2f7 | ||
| 
						 | 
					1b7d2b0cfa | ||
| 
						 | 
					a27bdcfe51 | ||
| 
						 | 
					89fe19f3e1 | ||
| 
						 | 
					980b3faea5 | ||
| 
						 | 
					027a8a3260 | ||
| 
						 | 
					5f3629bea0 | ||
| 
						 | 
					759f435fb9 | 
							
								
								
									
										4
									
								
								.mailmap
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								.mailmap
									
									
									
									
									
								
							@@ -3,6 +3,8 @@ Allan McRae <allan@archlinux.org> <mcrae_allan@hotmail.com>
 | 
			
		||||
Allan McRae <allan@archlinux.org> <mcrae_allan at hotmail.com>
 | 
			
		||||
Allan McRae <allan@archlinux.org> <allan.mcrae@qimr.edu.au>
 | 
			
		||||
Andres P <aepd87@gmail.com> <stderr@mail.com>
 | 
			
		||||
Andrew Gregory <andrew.gregory.8@gmail.com>
 | 
			
		||||
Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>
 | 
			
		||||
Bryan Ischo <bryan@ischo.com> <bji-keyword-pacman.3644cb@www.ischo.com>
 | 
			
		||||
Christos Nouskas <nous@archlinux.us> <nouskas@gmail.com>
 | 
			
		||||
Daenyth Blank <daenyth+arch@gmail.com> <Daenyth+Arch@gmail.com>
 | 
			
		||||
@@ -10,6 +12,7 @@ Daenyth Blank <Daenyth+arch@gmail.com> <Daenyth+git@gmail.com>
 | 
			
		||||
Dave Reisner <dreisner@archlinux.org> <d@falconindy.com>
 | 
			
		||||
甘露(Gan Lu) <rhythm.gan@gmail.com>
 | 
			
		||||
Giovanni Scafora <giovanni@archlinux.org> <linuxmania@gmail.com>
 | 
			
		||||
Jan Steffens <jan.steffens@gmail.com>
 | 
			
		||||
Jaroslaw Swierczynski <swiergot@gmail.com> <swiergot@juvepoland.com>
 | 
			
		||||
Jonathan Conder <j@skurvy.no-ip.org> <jonno.conder@gmail.com>
 | 
			
		||||
Juan Pablo González Tognarelli <lord_jotape@yahoo.com.ar>
 | 
			
		||||
@@ -25,6 +28,7 @@ Roman Kyrylych <roman@archlinux.org> <roman.kyrylych@gmail.com>
 | 
			
		||||
Sebastian Nowicki <sebnow@gmail.com> <xilonmu@gmail.com>
 | 
			
		||||
Vojtěch Gondžala <vojtech.gondzala@gmail.com> <vogo@seznam.cz>
 | 
			
		||||
Vojtěch Gondžala <vojtech.gondzala@gmail.com> Vojtech Gondzala <vojtech.gondzala@gmail.com>
 | 
			
		||||
William Giokas <1007380@gmail.com>
 | 
			
		||||
Xavier Chantry <shiningxc@gmail.com>
 | 
			
		||||
Xavier Chantry <shiningxc@gmail.com> <chantry.xavier@gmail.com>
 | 
			
		||||
Xavier Chantry <shiningxc@gmail.com> <xav@chantry.homelinux.org>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
[main]
 | 
			
		||||
host = https://www.transifex.net
 | 
			
		||||
host = https://www.transifex.com
 | 
			
		||||
 | 
			
		||||
[archlinux-pacman.libalpm-pot]
 | 
			
		||||
file_filter = lib/libalpm/po/<lang>.po
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										59
									
								
								HACKING
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								HACKING
									
									
									
									
									
								
							@@ -90,6 +90,61 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
 | 
			
		||||
       NOT
 | 
			
		||||
    if(!strcmp(a, b))
 | 
			
		||||
 | 
			
		||||
8.  Use spaces around almost all arithmetic, comparison and assignment
 | 
			
		||||
    operators and after all ',;:' separators.
 | 
			
		||||
 | 
			
		||||
	foobar[2 * size + 1] = function(a, 6);
 | 
			
		||||
	   NOT
 | 
			
		||||
	foobar[2*size+1]=function(a,6);
 | 
			
		||||
 | 
			
		||||
	for(a = 0; a < n && n > 0; a++, n--) {}
 | 
			
		||||
	   NOT
 | 
			
		||||
	for(a=0;a<n&&n>0;a++,n--) {}
 | 
			
		||||
 | 
			
		||||
9.  Declare all variables at the start of the block.
 | 
			
		||||
[source,C]
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
 | 
			
		||||
{
 | 
			
		||||
  char *newurl, *vdata = NULL;
 | 
			
		||||
 | 
			
		||||
  newurl = url;
 | 
			
		||||
  if(!newurl) {
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ...
 | 
			
		||||
 | 
			
		||||
  if(vdata) {
 | 
			
		||||
    ...
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
 | 
			
		||||
    NOT
 | 
			
		||||
 | 
			
		||||
[source,C]
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
 | 
			
		||||
{
 | 
			
		||||
  char *newurl = url;
 | 
			
		||||
 | 
			
		||||
  if(!newurl) {
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  char *vdata = NULL;
 | 
			
		||||
 | 
			
		||||
  if(vdata) {
 | 
			
		||||
    ...
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Other Concerns
 | 
			
		||||
--------------
 | 
			
		||||
@@ -103,8 +158,6 @@ general pattern, including blank lines:
 | 
			
		||||
 | 
			
		||||
[source,C]
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <standardheader.h>
 | 
			
		||||
#include <another.h>
 | 
			
		||||
#include <...>
 | 
			
		||||
@@ -133,6 +186,8 @@ For pacman:
 | 
			
		||||
#include "anythingelse.h"
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
 | 
			
		||||
Never directly include config.h. This will always be added via Makefiles.
 | 
			
		||||
 | 
			
		||||
GDB and Valgrind Usage
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								Makefile.am
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								Makefile.am
									
									
									
									
									
								
							@@ -1,9 +1,12 @@
 | 
			
		||||
SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util contrib
 | 
			
		||||
SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util test/scripts
 | 
			
		||||
if WANT_DOC
 | 
			
		||||
SUBDIRS += doc
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
DIST_SUBDIRS = $(SUBDIRS) contrib src/common
 | 
			
		||||
 | 
			
		||||
ACLOCAL_AMFLAGS = -I m4 --install
 | 
			
		||||
AM_MAKEFLAGS = --no-print-directory
 | 
			
		||||
 | 
			
		||||
# Make sure we test and build manpages when doing distcheck
 | 
			
		||||
DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version
 | 
			
		||||
@@ -21,15 +24,29 @@ dist_pkgdata_DATA = \
 | 
			
		||||
	proto/ChangeLog.proto
 | 
			
		||||
 | 
			
		||||
# run the pactest test suite and vercmp tests
 | 
			
		||||
check-local: test/pacman test/util src/pacman src/util
 | 
			
		||||
check-local: test-pacman test-pacsort test-vercmp test-parseopts
 | 
			
		||||
 | 
			
		||||
test-pacman: test/pacman src/pacman
 | 
			
		||||
	LC_ALL=C $(PYTHON) $(top_srcdir)/test/pacman/pactest.py --debug=1 \
 | 
			
		||||
		--test $(top_srcdir)/test/pacman/tests/*.py \
 | 
			
		||||
		--scriptlet-shell $(SCRIPTLET_SHELL) \
 | 
			
		||||
		--ldconfig $(LDCONFIG) \
 | 
			
		||||
		-p $(top_builddir)/src/pacman/pacman
 | 
			
		||||
	$(SH) $(top_srcdir)/test/util/pacsorttest.sh \
 | 
			
		||||
 | 
			
		||||
test-pacsort: test/util src/util
 | 
			
		||||
	$(BASH_SHELL) $(top_srcdir)/test/util/pacsorttest.sh \
 | 
			
		||||
		$(top_builddir)/src/util/pacsort
 | 
			
		||||
	$(SH) $(top_srcdir)/test/util/vercmptest.sh \
 | 
			
		||||
 | 
			
		||||
test-vercmp: test/util src/util
 | 
			
		||||
	$(BASH_SHELL) $(top_srcdir)/test/util/vercmptest.sh \
 | 
			
		||||
		$(top_builddir)/src/util/vercmp
 | 
			
		||||
 | 
			
		||||
test-parseopts: test/scripts scripts
 | 
			
		||||
	$(BASH_SHELL) $(top_srcdir)/test/scripts/parseopts_test.sh \
 | 
			
		||||
		$(top_srcdir)/scripts/library/parseopts.sh
 | 
			
		||||
	$(BASH_SHELL) $(top_srcdir)/test/scripts/human_to_size_test.sh \
 | 
			
		||||
		$(top_srcdir)/scripts/library/human_to_size.sh
 | 
			
		||||
 | 
			
		||||
# create the pacman DB and cache directories upon install
 | 
			
		||||
install-data-local:
 | 
			
		||||
	for dir in "$(DESTDIR)$(localstatedir)/lib/pacman" "$(DESTDIR)$(localstatedir)/cache/pacman/pkg"; do \
 | 
			
		||||
@@ -41,4 +58,6 @@ update-po:
 | 
			
		||||
	$(MAKE) -C scripts/po update-po
 | 
			
		||||
	$(MAKE) -C src/pacman/po update-po
 | 
			
		||||
 | 
			
		||||
.PHONY: test-pacman test-pacsort test-vercmp test-parseopts update-po
 | 
			
		||||
 | 
			
		||||
# vim:set ts=2 sw=2 noet:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										123
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										123
									
								
								NEWS
									
									
									
									
									
								
							@@ -1,5 +1,128 @@
 | 
			
		||||
VERSION         DESCRIPTION
 | 
			
		||||
-----------------------------------------------------------------------------
 | 
			
		||||
4.1.0         - check file properties when using -Qkk (FS#11091)
 | 
			
		||||
              - add color to pacman output - new configuration option "Color"
 | 
			
		||||
              - add informational messages for optdepends installation
 | 
			
		||||
                status (FS#13035, FS#27116)
 | 
			
		||||
              - add number suffix to pacsave files instead of overwriting
 | 
			
		||||
                (FS#24192)
 | 
			
		||||
              - improve needed key importing for Upgrade (FS#26520)
 | 
			
		||||
              - add options to specify require signature level for
 | 
			
		||||
                Upgrade operations (FS#26729)
 | 
			
		||||
              - directory ownership can be queried
 | 
			
		||||
              - allow wildcards in NoUpgrade, NoExtract, IgnorePkg,
 | 
			
		||||
                IgnoreGroup and HoldPkg (FS#20360, FS#18988)
 | 
			
		||||
              - remove -f short option for --force
 | 
			
		||||
              - SyncFirst option has been removed (FS#26445)
 | 
			
		||||
              - offer to delete downloaded packages failing signature check
 | 
			
		||||
                (FS#28014)
 | 
			
		||||
              - configure shell for running install scriptlets (FS#20557)
 | 
			
		||||
              - make path to ldconfig configurable
 | 
			
		||||
              - display repo in VerbosePkgLists output (FS#26334)
 | 
			
		||||
              - do not check file conflicts or diskspace with --dbonly
 | 
			
		||||
                (FS#25667)
 | 
			
		||||
              - UseDelta takes a ratio for the largest delta to use
 | 
			
		||||
              - track how installed packages were validated (FS#28040)
 | 
			
		||||
              - add pkg-config file for libalpm
 | 
			
		||||
              - avoid false ownership matches for files in / (FS#30388)
 | 
			
		||||
              - only load filesystem space information when needed
 | 
			
		||||
              - allow leading "local/" in query options
 | 
			
		||||
              - allow cleaning only some cachedirs
 | 
			
		||||
              - do not remove source package and package databases from
 | 
			
		||||
                cache (FS#25166)
 | 
			
		||||
              - improve conflict checking with directory symlinks (FS#30681)
 | 
			
		||||
              - remove Cygwin support
 | 
			
		||||
              - add program prefix to pacman log entries
 | 
			
		||||
              - add --native filter to pacman -Q
 | 
			
		||||
              - makepkg:
 | 
			
		||||
                - require bash>=4.0
 | 
			
		||||
                - support for VCS URLs (git, bzr, svn and hg) (FS#7816,
 | 
			
		||||
                  FS#8890, FS#13727, FS#15895, FS#16384, FS#16872, FS#19459,
 | 
			
		||||
                  FS#19476, FS#20841, FS#21098, FS#28605)
 | 
			
		||||
                - split debugging symbols into separate package (FS#10975)
 | 
			
		||||
                - use SKIP in checksums to skip integrity check (FS#19735)
 | 
			
		||||
                - add prepare() function to PKGBUILD (FS#30582)
 | 
			
		||||
                - add pkgver() function to auto-update pkgver/pkgrel
 | 
			
		||||
                - pkgrel must be in decimal format
 | 
			
		||||
                - PKGBUILDs without package() functions are deprecated
 | 
			
		||||
                - support specifying CPPFLAGS in makepkg.conf
 | 
			
		||||
                - support PACKAGER environmental variable
 | 
			
		||||
                - allow source renaming to work on signature files
 | 
			
		||||
                - configurable compression options (FS#27430)
 | 
			
		||||
                - allow multiple packages to be build when using
 | 
			
		||||
                  BUILDDIR (FS#28417)
 | 
			
		||||
                - add makedepends/checkdepends information to .PKGINFO
 | 
			
		||||
                - url can be overridden in split packages
 | 
			
		||||
                - allow wildcards in PURGE_TARGETS
 | 
			
		||||
                - pass --asdep and --needed flags to pacman when installing
 | 
			
		||||
                - use last match in BUILDENV/OPTIONS arrays (FS#26701)
 | 
			
		||||
                - fix "arch" handling in split packages (FS#27204)
 | 
			
		||||
                - add LOGDEST configuration option
 | 
			
		||||
                - install makedepends with --repackage
 | 
			
		||||
              - repo-add:
 | 
			
		||||
                - honor TMPDIR environmental variable
 | 
			
		||||
                - add makedepends/checkdepends information to database
 | 
			
		||||
              - pacman-key:
 | 
			
		||||
                - fix importing keys with quotes in file name (FS#28445)
 | 
			
		||||
                - allow verification of multiple sig files
 | 
			
		||||
                - add zsh completion (FS#29062)
 | 
			
		||||
              - pkgdelta: add ratio and package size limits
 | 
			
		||||
              - pactree: improve output
 | 
			
		||||
              - contrib:
 | 
			
		||||
                - updpkgsums: update checksums in a PKGBUILD
 | 
			
		||||
                - checkupdates: new - safely check for package updates
 | 
			
		||||
                - pacsort: add --files option to support parsing filenames
 | 
			
		||||
                - pacdiff: improve usability
 | 
			
		||||
                - add zsh completion
 | 
			
		||||
4.0.3         - frontend database cleanup enhancements (FS#28714)
 | 
			
		||||
              - frontend package cleanup enhancements (FS#25166)
 | 
			
		||||
              - back out changes related to SyncFirst in 4.0.0
 | 
			
		||||
                - remove recursive/needed automatic flags on SyncFirst
 | 
			
		||||
                - remove poorly implemented `-S --recursive` option
 | 
			
		||||
              - improve error messages on database locking failures
 | 
			
		||||
              - use full delta size as max download size (FS#28345)
 | 
			
		||||
              - improved handling and fix crash after failed downloads
 | 
			
		||||
              - fix key lookup when using gpg 2.X as GPG program
 | 
			
		||||
              - match only full path components in diskspace checking
 | 
			
		||||
              - skip diskspace checks when using --dbonly
 | 
			
		||||
              - scripts: unset CDPATH bash variable in all scripts
 | 
			
		||||
              - makepkg:
 | 
			
		||||
                - fix syntax error in remove_deps (FS#28448)
 | 
			
		||||
                - small fixes related to multiple libdeps, parsing issues
 | 
			
		||||
                - exit via default handler in trap_exit (FS#28491)
 | 
			
		||||
                - attempt to work around BTRFS file/block size reporting issues
 | 
			
		||||
              - pacman-key:
 | 
			
		||||
                - remove signature verification in --populate
 | 
			
		||||
                - make -e option work as advertised without arguments
 | 
			
		||||
                - exit with correct return codes when verifying signature
 | 
			
		||||
              - pacsysclean: fix description, fix option parsing (FS#28434)
 | 
			
		||||
              - pkgdelta: use bsdtar -q option for better performance
 | 
			
		||||
              - translations: various updates and corrections
 | 
			
		||||
4.0.2         - allow comments after a repository header in pacman.conf
 | 
			
		||||
              - search for and import PGP subkeys if necessary (FS#27612)
 | 
			
		||||
              - fix rare segfault on removal operations (FS#27805, FS#28195)
 | 
			
		||||
              - skip all unknown files when cleaning package cache
 | 
			
		||||
              - restore looking for files in cache before downloading via -U
 | 
			
		||||
              - ensure '[removal]' is displayed in trans confirmation (FS#27981)
 | 
			
		||||
              - implement disk space checking code for Illumos
 | 
			
		||||
              - use TCP keepalive in download to prevent dropped connections
 | 
			
		||||
              - round and show -0.00 values as 0.00 (FS#27924)
 | 
			
		||||
              - makepkg:
 | 
			
		||||
                - ensure all source files are included in --source (FS#26580)
 | 
			
		||||
                - fix locale sort/comm related issues (FS#26580)
 | 
			
		||||
                - abort on missing download agent
 | 
			
		||||
                - restrict flags passed to pacman (FS#28012)
 | 
			
		||||
                - work around certain zipman glob/existence issues
 | 
			
		||||
                - fix non-writable SRCPKGDEST error message (FS#28197)
 | 
			
		||||
                - fix printf interpreting gettext string as arg (FS#28069)
 | 
			
		||||
                - don't abort on non-zero hg return codes (FS#28248)
 | 
			
		||||
                - disable extglob when sourcing BUILDSCRIPT (FS#27780)
 | 
			
		||||
              - pacman-key: improve return codes of operations (FS#26730)
 | 
			
		||||
              - repo-add: enforce maximum signature file size (FS#27453)
 | 
			
		||||
              - contrib/paclist: support --help (FS#27258)
 | 
			
		||||
              - contrib/pacsysclean: new script
 | 
			
		||||
              - contrib/*_completion: fix completion for uncompressed packages
 | 
			
		||||
              - translations: extensive updates and corrections
 | 
			
		||||
4.0.1         - ensure VerbosePkgList table display supports multibyte chars
 | 
			
		||||
              - always use stderr for warning/error messages (FS#26555)
 | 
			
		||||
              - add guidance message for users when public keyring not found
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										82
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								README
									
									
									
									
									
								
							@@ -53,8 +53,16 @@ library is initialized.
 | 
			
		||||
* dlcb: The callback function for download progress of each package.
 | 
			
		||||
* fetchcb: Callback for custom download function.
 | 
			
		||||
* totaldlcb: The callback function for overall download progress.
 | 
			
		||||
* root: The root directory for pacman to install to (Default: /)
 | 
			
		||||
* dbpath: The toplevel database directory (Default: /var/lib/pacman)
 | 
			
		||||
* eventcb: Callback for transaction messages.
 | 
			
		||||
* questioncb: Callback for selecting amongst choices.
 | 
			
		||||
* progresscb: Callback to handle display of transaction progress.
 | 
			
		||||
* gpgdir: Directory where GnuPG files are stored.
 | 
			
		||||
* arch: Allowed package architecture.
 | 
			
		||||
* deltaratio: Download deltas if possible; a ratio value.
 | 
			
		||||
* checkspace: Check disk space before installing.
 | 
			
		||||
* default_siglevel: Default signature verification level.
 | 
			
		||||
* local_file_siglevel: Signature verification level for local file upgrades.
 | 
			
		||||
* remote_file_siglevel: Signature verification level for remote file upgrades.
 | 
			
		||||
* logfile: The base path to pacman's log file (Default: /var/log/pacman.log)
 | 
			
		||||
* usesyslog: Log to syslog instead of `logfile` for file-base logging.
 | 
			
		||||
 | 
			
		||||
@@ -71,14 +79,10 @@ alpm_option_{get,set}_noupgrades -> alpm_option_{add,remove}_noupgrade.
 | 
			
		||||
 | 
			
		||||
The following options are read-only, having ONLY alpm_option_get_* functions:
 | 
			
		||||
 | 
			
		||||
* lockfile: The file used for locking the database
 | 
			
		||||
  (Default: <dbpath>/db.lck)
 | 
			
		||||
* localdb: A alpm_db_t structure for the local (installed) database
 | 
			
		||||
* syncdbs: A list of alpm_db_t structures to which pacman can sync from.
 | 
			
		||||
* root: The root directory for pacman to install to
 | 
			
		||||
* dbpath: The toplevel database directory
 | 
			
		||||
* lockfile: The file used for locking the database (Default: <dbpath>/db.lck)
 | 
			
		||||
 | 
			
		||||
The following options are write-only, having ONLY alpm_option_set_* functions:
 | 
			
		||||
 | 
			
		||||
* usedelta: Download delta files instead of complete packages if possible.
 | 
			
		||||
 | 
			
		||||
[Transactions]
 | 
			
		||||
 | 
			
		||||
@@ -366,6 +370,7 @@ API CHANGES BETWEEN 3.4 AND 3.5
 | 
			
		||||
   PM_TRANS_EVT_DISKSPACE_DONE, PM_TRANS_CONV_SELECT_PROVIDER,
 | 
			
		||||
   PM_TRANS_PROGRESS_DISKSPACE_START, PM_TRANS_PROGRESS_INTEGRITY_START
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
API CHANGES BETWEEN 3.5 AND 4.0
 | 
			
		||||
===============================
 | 
			
		||||
 | 
			
		||||
@@ -389,7 +394,7 @@ API CHANGES BETWEEN 3.5 AND 4.0
 | 
			
		||||
- PM_ prefixes for enum values are now ALPM_
 | 
			
		||||
- pm prefixes for structs and enums are now alpm_
 | 
			
		||||
- alpm_initialize now has parameters: char *root, char *dbpath,
 | 
			
		||||
    _alpm_errno_t *err and returns an alpm_handle_t struct.
 | 
			
		||||
    alpm_errno_t *err and returns an alpm_handle_t struct.
 | 
			
		||||
- alpm_release now takes an alpm_handle_t *.
 | 
			
		||||
- alpm_db_register_sync() now requires a extra parameter of a alpm_siglevel_t.
 | 
			
		||||
- alpm_pkg_load() now requires an extra parameter of an alpm_siglevel_t
 | 
			
		||||
@@ -445,3 +450,60 @@ API CHANGES BETWEEN 3.5 AND 4.0
 | 
			
		||||
    ALPM_ERR_DB_INVALID, ALPM_ERR_DB_INVALID_SIG, ALPM_ERR_GPGME,
 | 
			
		||||
    ALPM_ERR_PKG_INVALID_CHECKSUM, ALPM_ERR_PKG_INVALID_SIG, ALPM_ERR_SIG_INVALID,
 | 
			
		||||
    ALPM_ERR_SIG_MISSING
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
API CHANGES BETWEEN 4.0 AND 4.1
 | 
			
		||||
===============================
 | 
			
		||||
 | 
			
		||||
[REMOVED]
 | 
			
		||||
- alpm_list_getdata()
 | 
			
		||||
 | 
			
		||||
[CHANGED]
 | 
			
		||||
- alpm_pkgfrom_t members are now prefixed with ALPM_
 | 
			
		||||
- alpm_siglevel_t - added members ALPM_SIG_PACKAGE_SET, ALPM_SIG_PACKAGE_TRUST_SET
 | 
			
		||||
- alpm_depend_t - additional desc member
 | 
			
		||||
- alpm_filelist_t - additional resolved_path member
 | 
			
		||||
- alpm_pgpkey_t - added members length, revoked, pubkey_algo
 | 
			
		||||
- alpm_logaction - added caller identifier argument
 | 
			
		||||
- function renaming:
 | 
			
		||||
  - alpm_option_get_localdb -> alpm_get_localdb
 | 
			
		||||
  - alpm_option_get_syncdbs -> alpm_get_syncdbs
 | 
			
		||||
  - alpm_db_register_sync -> alpm_register_syncdb
 | 
			
		||||
  - alpm_db_unregister_all -> alpm_unregister_all_syncdbs
 | 
			
		||||
  - alpm_db_readgroup -> alpm_db_get_group
 | 
			
		||||
  - alpm_db_set_pkgreason -> alpm_pkg_set_reason (handle parameter removed)
 | 
			
		||||
- alpm_time_t typedef used for all times
 | 
			
		||||
  - members of alpm_pgpkey_t
 | 
			
		||||
  - return types of alpm_pkg_get_builddate and alpm_pkg_get_installdate
 | 
			
		||||
- delta options now use required ratio rather than on/off
 | 
			
		||||
  - alpm_option_get_usedelta -> alpm_option_get_deltaratio
 | 
			
		||||
  - alpm_option_set_usedelta -> alpm_option_set_deltaratio
 | 
			
		||||
 | 
			
		||||
[ADDED]
 | 
			
		||||
- tracking of how a package was validated:
 | 
			
		||||
  - alpm_pkgvalidation_t
 | 
			
		||||
  - alpm_pkg_get_validation()
 | 
			
		||||
- adjustable signature verification levels for upgrade operations:
 | 
			
		||||
  - alpm_option_get_local_file_siglevel()
 | 
			
		||||
  - alpm_option_set_local_file_siglevel()
 | 
			
		||||
  - alpm_option_get_remote_file_siglevel()
 | 
			
		||||
  - alpm_option_set_remote_file_siglevel()
 | 
			
		||||
- sync database usage functions:
 | 
			
		||||
  - alpm_db_usage_t
 | 
			
		||||
  - alpm_db_set_usage()
 | 
			
		||||
  - alpm_db_get_usage()
 | 
			
		||||
- wrapper functions for reading mtree files
 | 
			
		||||
  - alpm_pkg_mtree_open()
 | 
			
		||||
  - alpm_pkg_mtree_next()
 | 
			
		||||
  - alpm_pkg_mtree_close()
 | 
			
		||||
- utility functions
 | 
			
		||||
  - alpm_pkg_find()
 | 
			
		||||
  - alpm_pkg_compute_optionalfor()
 | 
			
		||||
  - alpm_filelist_contains()
 | 
			
		||||
- types
 | 
			
		||||
  - alpm_time_t
 | 
			
		||||
  - alpm_errno_t
 | 
			
		||||
- flags
 | 
			
		||||
   ALPM_EVENT_OPTDEP_REQUIRED, ALPM_EVENT_DATABASE_MISSING,
 | 
			
		||||
   ALPM_EVENT_KEYRING_START, ALPM_EVENT_KEYRING_DONE, ALPM_EVENT_KEY_DOWNLOAD_START,
 | 
			
		||||
   ALPM_EVENT_KEY_DOWNLOAD_DONE, ALPM_PROGRESS_KEYRING_START
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								autoclean.sh
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								autoclean.sh
									
									
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
#!/bin/sh -xu
 | 
			
		||||
 | 
			
		||||
[ -f Makefile ] && make distclean
 | 
			
		||||
 | 
			
		||||
rm -rf autom4te.cache
 | 
			
		||||
rm -f {Makefile.in,Makefile}
 | 
			
		||||
rm -f {config.h.in,config.h}
 | 
			
		||||
rm -f config.h.in config.h
 | 
			
		||||
rm -f config.status
 | 
			
		||||
rm -f configure
 | 
			
		||||
rm -f stamp*
 | 
			
		||||
@@ -11,22 +11,12 @@ rm -f aclocal.m4
 | 
			
		||||
rm -f compile
 | 
			
		||||
rm -f libtool
 | 
			
		||||
 | 
			
		||||
rm -f lib/libalpm/{Makefile.in,Makefile}
 | 
			
		||||
rm -f src/util/{Makefile.in,Makefile}
 | 
			
		||||
rm -f src/pacman/{Makefile.in,Makefile}
 | 
			
		||||
rm -f scripts/{Makefile.in,Makefile}
 | 
			
		||||
rm -f etc/{Makefile.in,Makefile}
 | 
			
		||||
rm -f etc/pacman.d/{Makefile.in,Makefile}
 | 
			
		||||
rm -f etc/abs/{Makefile.in,Makefile}
 | 
			
		||||
rm -f test/{pacman,util}{,/tests}/{Makefile.in,Makefile}
 | 
			
		||||
rm -f contrib/{Makefile.in,Makefile}
 | 
			
		||||
rm -f doc/{Makefile.in,Makefile}
 | 
			
		||||
 | 
			
		||||
rm -f test/pacman/*.pyc
 | 
			
		||||
rm -f doc/html/*.html
 | 
			
		||||
rm -f doc/man3/*.3
 | 
			
		||||
 | 
			
		||||
rm -f {lib/libalpm,scripts,src/pacman}/po/{Makefile.in,Makefile}
 | 
			
		||||
rm -f {lib/libalpm,scripts,src/pacman}/po/POTFILES
 | 
			
		||||
rm -f {lib/libalpm,scripts,src/pacman}/po/stamp-po
 | 
			
		||||
rm -f {lib/libalpm,scripts,src/pacman}/po/*.gmo
 | 
			
		||||
find . \( -name 'Makefile' -o \
 | 
			
		||||
          -name 'Makefile.in' -o \
 | 
			
		||||
          -path '*/po/POTFILES' -o \
 | 
			
		||||
          -path '*/po/stamp-po' -o \
 | 
			
		||||
          -path '*/po/*.gmo' \) -exec rm -f {} +
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								config.guess → build-aux/config.guess
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										0
									
								
								config.guess → build-aux/config.guess
									
									
									
									
										vendored
									
									
								
							
							
								
								
									
										0
									
								
								config.sub → build-aux/config.sub
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										0
									
								
								config.sub → build-aux/config.sub
									
									
									
									
										vendored
									
									
								
							
							
								
								
									
										215
									
								
								build-aux/missing
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										215
									
								
								build-aux/missing
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,215 @@
 | 
			
		||||
#! /bin/sh
 | 
			
		||||
# Common wrapper for a few potentially missing GNU programs.
 | 
			
		||||
 | 
			
		||||
scriptversion=2012-06-26.16; # UTC
 | 
			
		||||
 | 
			
		||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 | 
			
		||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 | 
			
		||||
 | 
			
		||||
# This program is free software; you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU General Public License as published by
 | 
			
		||||
# the Free Software Foundation; either version 2, or (at your option)
 | 
			
		||||
# any later version.
 | 
			
		||||
 | 
			
		||||
# This program is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
# GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
# As a special exception to the GNU General Public License, if you
 | 
			
		||||
# distribute this file as part of a program that contains a
 | 
			
		||||
# configuration script generated by Autoconf, you may include it under
 | 
			
		||||
# the same distribution terms that you use for the rest of that program.
 | 
			
		||||
 | 
			
		||||
if test $# -eq 0; then
 | 
			
		||||
  echo 1>&2 "Try '$0 --help' for more information"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
case $1 in
 | 
			
		||||
 | 
			
		||||
  --is-lightweight)
 | 
			
		||||
    # Used by our autoconf macros to check whether the available missing
 | 
			
		||||
    # script is modern enough.
 | 
			
		||||
    exit 0
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
  --run)
 | 
			
		||||
    # Back-compat with the calling convention used by older automake.
 | 
			
		||||
    shift
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
  -h|--h|--he|--hel|--help)
 | 
			
		||||
    echo "\
 | 
			
		||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
 | 
			
		||||
 | 
			
		||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
 | 
			
		||||
to PROGRAM being missing or too old.
 | 
			
		||||
 | 
			
		||||
Options:
 | 
			
		||||
  -h, --help      display this help and exit
 | 
			
		||||
  -v, --version   output version information and exit
 | 
			
		||||
 | 
			
		||||
Supported PROGRAM values:
 | 
			
		||||
  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
 | 
			
		||||
  bison     yacc      flex         lex       help2man
 | 
			
		||||
 | 
			
		||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
 | 
			
		||||
'g' are ignored when checking the name.
 | 
			
		||||
 | 
			
		||||
Send bug reports to <bug-automake@gnu.org>."
 | 
			
		||||
    exit $?
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
 | 
			
		||||
    echo "missing $scriptversion (GNU Automake)"
 | 
			
		||||
    exit $?
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
  -*)
 | 
			
		||||
    echo 1>&2 "$0: unknown '$1' option"
 | 
			
		||||
    echo 1>&2 "Try '$0 --help' for more information"
 | 
			
		||||
    exit 1
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# Run the given program, remember its exit status.
 | 
			
		||||
"$@"; st=$?
 | 
			
		||||
 | 
			
		||||
# If it succeeded, we are done.
 | 
			
		||||
test $st -eq 0 && exit 0
 | 
			
		||||
 | 
			
		||||
# Also exit now if we it failed (or wasn't found), and '--version' was
 | 
			
		||||
# passed; such an option is passed most likely to detect whether the
 | 
			
		||||
# program is present and works.
 | 
			
		||||
case $2 in --version|--help) exit $st;; esac
 | 
			
		||||
 | 
			
		||||
# Exit code 63 means version mismatch.  This often happens when the user
 | 
			
		||||
# tries to use an ancient version of a tool on a file that requires a
 | 
			
		||||
# minimum version.
 | 
			
		||||
if test $st -eq 63; then
 | 
			
		||||
  msg="probably too old"
 | 
			
		||||
elif test $st -eq 127; then
 | 
			
		||||
  # Program was missing.
 | 
			
		||||
  msg="missing on your system"
 | 
			
		||||
else
 | 
			
		||||
  # Program was found and executed, but failed.  Give up.
 | 
			
		||||
  exit $st
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
perl_URL=http://www.perl.org/
 | 
			
		||||
flex_URL=http://flex.sourceforge.net/
 | 
			
		||||
gnu_software_URL=http://www.gnu.org/software
 | 
			
		||||
 | 
			
		||||
program_details ()
 | 
			
		||||
{
 | 
			
		||||
  case $1 in
 | 
			
		||||
    aclocal|automake)
 | 
			
		||||
      echo "The '$1' program is part of the GNU Automake package:"
 | 
			
		||||
      echo "<$gnu_software_URL/automake>"
 | 
			
		||||
      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
 | 
			
		||||
      echo "<$gnu_software_URL/autoconf>"
 | 
			
		||||
      echo "<$gnu_software_URL/m4/>"
 | 
			
		||||
      echo "<$perl_URL>"
 | 
			
		||||
      ;;
 | 
			
		||||
    autoconf|autom4te|autoheader)
 | 
			
		||||
      echo "The '$1' program is part of the GNU Autoconf package:"
 | 
			
		||||
      echo "<$gnu_software_URL/autoconf/>"
 | 
			
		||||
      echo "It also requires GNU m4 and Perl in order to run:"
 | 
			
		||||
      echo "<$gnu_software_URL/m4/>"
 | 
			
		||||
      echo "<$perl_URL>"
 | 
			
		||||
      ;;
 | 
			
		||||
  esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
give_advice ()
 | 
			
		||||
{
 | 
			
		||||
  # Normalize program name to check for.
 | 
			
		||||
  normalized_program=`echo "$1" | sed '
 | 
			
		||||
    s/^gnu-//; t
 | 
			
		||||
    s/^gnu//; t
 | 
			
		||||
    s/^g//; t'`
 | 
			
		||||
 | 
			
		||||
  printf '%s\n' "'$1' is $msg."
 | 
			
		||||
 | 
			
		||||
  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
 | 
			
		||||
  case $normalized_program in
 | 
			
		||||
    autoconf*)
 | 
			
		||||
      echo "You should only need it if you modified 'configure.ac',"
 | 
			
		||||
      echo "or m4 files included by it."
 | 
			
		||||
      program_details 'autoconf'
 | 
			
		||||
      ;;
 | 
			
		||||
    autoheader*)
 | 
			
		||||
      echo "You should only need it if you modified 'acconfig.h' or"
 | 
			
		||||
      echo "$configure_deps."
 | 
			
		||||
      program_details 'autoheader'
 | 
			
		||||
      ;;
 | 
			
		||||
    automake*)
 | 
			
		||||
      echo "You should only need it if you modified 'Makefile.am' or"
 | 
			
		||||
      echo "$configure_deps."
 | 
			
		||||
      program_details 'automake'
 | 
			
		||||
      ;;
 | 
			
		||||
    aclocal*)
 | 
			
		||||
      echo "You should only need it if you modified 'acinclude.m4' or"
 | 
			
		||||
      echo "$configure_deps."
 | 
			
		||||
      program_details 'aclocal'
 | 
			
		||||
      ;;
 | 
			
		||||
   autom4te*)
 | 
			
		||||
      echo "You might have modified some maintainer files that require"
 | 
			
		||||
      echo "the 'automa4te' program to be rebuilt."
 | 
			
		||||
      program_details 'autom4te'
 | 
			
		||||
      ;;
 | 
			
		||||
    bison*|yacc*)
 | 
			
		||||
      echo "You should only need it if you modified a '.y' file."
 | 
			
		||||
      echo "You may want to install the GNU Bison package:"
 | 
			
		||||
      echo "<$gnu_software_URL/bison/>"
 | 
			
		||||
      ;;
 | 
			
		||||
    lex*|flex*)
 | 
			
		||||
      echo "You should only need it if you modified a '.l' file."
 | 
			
		||||
      echo "You may want to install the Fast Lexical Analyzer package:"
 | 
			
		||||
      echo "<$flex_URL>"
 | 
			
		||||
      ;;
 | 
			
		||||
    help2man*)
 | 
			
		||||
      echo "You should only need it if you modified a dependency" \
 | 
			
		||||
           "of a man page."
 | 
			
		||||
      echo "You may want to install the GNU Help2man package:"
 | 
			
		||||
      echo "<$gnu_software_URL/help2man/>"
 | 
			
		||||
    ;;
 | 
			
		||||
    makeinfo*)
 | 
			
		||||
      echo "You should only need it if you modified a '.texi' file, or"
 | 
			
		||||
      echo "any other file indirectly affecting the aspect of the manual."
 | 
			
		||||
      echo "You might want to install the Texinfo package:"
 | 
			
		||||
      echo "<$gnu_software_URL/texinfo/>"
 | 
			
		||||
      echo "The spurious makeinfo call might also be the consequence of"
 | 
			
		||||
      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
 | 
			
		||||
      echo "want to install GNU make:"
 | 
			
		||||
      echo "<$gnu_software_URL/make/>"
 | 
			
		||||
      ;;
 | 
			
		||||
    *)
 | 
			
		||||
      echo "You might have modified some files without having the proper"
 | 
			
		||||
      echo "tools for further handling them.  Check the 'README' file, it"
 | 
			
		||||
      echo "often tells you about the needed prerequisites for installing"
 | 
			
		||||
      echo "this package.  You may also peek at any GNU archive site, in"
 | 
			
		||||
      echo "case some other package contains this missing '$1' program."
 | 
			
		||||
      ;;
 | 
			
		||||
  esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
 | 
			
		||||
                       -e '2,$s/^/         /' >&2
 | 
			
		||||
 | 
			
		||||
# Propagate the correct exit status (expected to be 127 for a program
 | 
			
		||||
# not found, 63 for a program that failed due to version mismatch).
 | 
			
		||||
exit $st
 | 
			
		||||
 | 
			
		||||
# Local variables:
 | 
			
		||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
 | 
			
		||||
# time-stamp-start: "scriptversion="
 | 
			
		||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
 | 
			
		||||
# time-stamp-time-zone: "UTC"
 | 
			
		||||
# time-stamp-end: "; # UTC"
 | 
			
		||||
# End:
 | 
			
		||||
							
								
								
									
										265
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										265
									
								
								configure.ac
									
									
									
									
									
								
							@@ -41,13 +41,13 @@ AC_PREREQ(2.62)
 | 
			
		||||
#   Bugfix releases:
 | 
			
		||||
#     pacman_version_micro += 1
 | 
			
		||||
 | 
			
		||||
m4_define([lib_current], [7])
 | 
			
		||||
m4_define([lib_revision], [1])
 | 
			
		||||
m4_define([lib_current], [8])
 | 
			
		||||
m4_define([lib_revision], [0])
 | 
			
		||||
m4_define([lib_age], [0])
 | 
			
		||||
 | 
			
		||||
m4_define([pacman_version_major], [4])
 | 
			
		||||
m4_define([pacman_version_minor], [0])
 | 
			
		||||
m4_define([pacman_version_micro], [1])
 | 
			
		||||
m4_define([pacman_version_minor], [1])
 | 
			
		||||
m4_define([pacman_version_micro], [0])
 | 
			
		||||
m4_define([pacman_version],
 | 
			
		||||
          [pacman_version_major.pacman_version_minor.pacman_version_micro])
 | 
			
		||||
 | 
			
		||||
@@ -55,13 +55,22 @@ m4_define([pacman_version],
 | 
			
		||||
AC_INIT([pacman], [pacman_version], [pacman-dev@archlinux.org])
 | 
			
		||||
AC_CONFIG_SRCDIR([config.h.in])
 | 
			
		||||
AC_CONFIG_HEADERS([config.h])
 | 
			
		||||
AC_CONFIG_MACRO_DIR([m4])
 | 
			
		||||
AC_CONFIG_AUX_DIR([build-aux])
 | 
			
		||||
 | 
			
		||||
AC_CANONICAL_HOST
 | 
			
		||||
AM_INIT_AUTOMAKE
 | 
			
		||||
AM_INIT_AUTOMAKE([1.11])
 | 
			
		||||
AM_SILENT_RULES([yes])
 | 
			
		||||
 | 
			
		||||
LT_INIT
 | 
			
		||||
LIB_VERSION=`expr lib_current - lib_age`.lib_age.lib_revision
 | 
			
		||||
LIB_VERSION_INFO="lib_current:lib_revision:lib_age"
 | 
			
		||||
 | 
			
		||||
# Respect empty CFLAGS during compiler tests
 | 
			
		||||
if test "x$CFLAGS" = "x"; then
 | 
			
		||||
  CFLAGS=""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Set subsitution values for version stuff in Makefiles and anywhere else,
 | 
			
		||||
# and put LIB_VERSION in config.h
 | 
			
		||||
AC_SUBST(LIB_VERSION)
 | 
			
		||||
@@ -88,6 +97,23 @@ AC_ARG_WITH(buildscript,
 | 
			
		||||
	AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]),
 | 
			
		||||
	[BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD])
 | 
			
		||||
 | 
			
		||||
# Help line for debug package suffix
 | 
			
		||||
AC_ARG_WITH(debug-suffix,
 | 
			
		||||
	AS_HELP_STRING([--with-debug-suffix=name], [set the suffix for split debugging symbol packages used by makepkg]),
 | 
			
		||||
	[DEBUGSUFFIX=$withval], [DEBUGSUFFIX=debug])
 | 
			
		||||
 | 
			
		||||
# Help line for changing shell used to run install scriptlets
 | 
			
		||||
AC_ARG_WITH(scriptlet-shell,
 | 
			
		||||
	AS_HELP_STRING([--with-scriptlet-shell=shell],
 | 
			
		||||
		[set the full path to the shell used to run install scriptlets]),
 | 
			
		||||
	[SCRIPTLET_SHELL=$withval], [SCRIPTLET_SHELL=/bin/sh])
 | 
			
		||||
 | 
			
		||||
# Help line for ldconfig path
 | 
			
		||||
AC_ARG_WITH(ldconfig,
 | 
			
		||||
	AS_HELP_STRING([--with-ldconfig=path],
 | 
			
		||||
		[set the full path to ldconfig]),
 | 
			
		||||
	[LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig])
 | 
			
		||||
 | 
			
		||||
# Help line for using OpenSSL
 | 
			
		||||
AC_ARG_WITH(openssl,
 | 
			
		||||
	AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]),
 | 
			
		||||
@@ -98,8 +124,10 @@ AC_ARG_WITH(gpgme,
 | 
			
		||||
	AS_HELP_STRING([--with-gpgme], [use GPGME for PGP signature verification]),
 | 
			
		||||
	[], [with_gpgme=check])
 | 
			
		||||
 | 
			
		||||
# Check for useable libcurl
 | 
			
		||||
LIBCURL_CHECK_CONFIG([yes], [7.19.4], [with_libcurl=yes], [with_libcurl=no])
 | 
			
		||||
# Help line for using libcurl
 | 
			
		||||
AC_ARG_WITH(curl,
 | 
			
		||||
	AS_HELP_STRING([--with-libcurl], [use libcurl for the internal downloader]),
 | 
			
		||||
	[], [with_curl=check])
 | 
			
		||||
 | 
			
		||||
# Help line for documentation
 | 
			
		||||
AC_ARG_ENABLE(doc,
 | 
			
		||||
@@ -116,23 +144,43 @@ AC_ARG_ENABLE(debug,
 | 
			
		||||
	AS_HELP_STRING([--enable-debug], [enable debugging support]),
 | 
			
		||||
	[debug=$enableval], [debug=no])
 | 
			
		||||
 | 
			
		||||
# Help line for compiler warning flags
 | 
			
		||||
AC_ARG_ENABLE(warningflags,
 | 
			
		||||
	AS_HELP_STRING([--enable-warningflags], [enable extra compiler warning flags]),
 | 
			
		||||
	[warningflags=$enableval], [warningflags=no])
 | 
			
		||||
 | 
			
		||||
# Help line for using git version in pacman version string
 | 
			
		||||
AC_ARG_ENABLE(git-version,
 | 
			
		||||
	AS_HELP_STRING([--enable-git-version],
 | 
			
		||||
		[enable use of git version in version string if available]),
 | 
			
		||||
	[wantgitver=$enableval], [wantgitver=no])
 | 
			
		||||
 | 
			
		||||
# Enable large file support if available (must be enabled before
 | 
			
		||||
# testing compilation against gpgme).
 | 
			
		||||
AC_SYS_LARGEFILE
 | 
			
		||||
 | 
			
		||||
# Checks for programs.
 | 
			
		||||
AC_PROG_AWK
 | 
			
		||||
AC_PROG_CC_C99
 | 
			
		||||
AC_PROG_CXX
 | 
			
		||||
AC_PROG_INSTALL
 | 
			
		||||
AC_PROG_LN_S
 | 
			
		||||
AC_PROG_MAKE_SET
 | 
			
		||||
AC_PROG_LIBTOOL
 | 
			
		||||
AC_PROG_RANLIB
 | 
			
		||||
AC_CHECK_PROGS([PYTHON], [python2.7 python2.6 python2.5 python2 python], [false])
 | 
			
		||||
AC_PATH_PROGS([BASH_SHELL], [bash bash4 bash3], [false])
 | 
			
		||||
AC_PATH_PROGS([BASH_SHELL], [bash bash4], [false])
 | 
			
		||||
 | 
			
		||||
AS_IF([test "x$BASH_SHELL" = "xfalse"],
 | 
			
		||||
	AC_MSG_WARN([*** bash >= 4.1.0 is required for pacman scripts]),
 | 
			
		||||
	[bash_version_major=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[0]]}"'`
 | 
			
		||||
	bash_version_minor=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[1]]}"'`
 | 
			
		||||
	ok=yes
 | 
			
		||||
	if test "$bash_version_major" -lt 4; then
 | 
			
		||||
		ok=no
 | 
			
		||||
	fi
 | 
			
		||||
	if test "$bash_version_major" -eq 4 && test "$bash_version_minor" -lt 1; then
 | 
			
		||||
		ok=no
 | 
			
		||||
	fi
 | 
			
		||||
	if test "$ok" = "no"; then
 | 
			
		||||
		AC_MSG_ERROR([*** bash >= 4.1.0 is required for pacman scripts])
 | 
			
		||||
	fi
 | 
			
		||||
	unset bash_version_major bash_version_minor ok])
 | 
			
		||||
 | 
			
		||||
# find installed gettext
 | 
			
		||||
AM_GNU_GETTEXT([external], [need-ngettext])
 | 
			
		||||
@@ -142,38 +190,79 @@ AC_CHECK_LIB([m], [fabs], ,
 | 
			
		||||
	AC_MSG_ERROR([libm is needed to compile pacman!]))
 | 
			
		||||
 | 
			
		||||
# Check for libarchive
 | 
			
		||||
AC_CHECK_LIB([archive], [archive_read_data], ,
 | 
			
		||||
	AC_MSG_ERROR([libarchive is needed to compile pacman!]))
 | 
			
		||||
PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], ,
 | 
			
		||||
	AC_MSG_ERROR([*** libarchive >= 2.8.0 is needed to compile pacman!]))
 | 
			
		||||
 | 
			
		||||
# Check for OpenSSL
 | 
			
		||||
AC_MSG_CHECKING(whether to link with libssl)
 | 
			
		||||
AS_IF([test "x$with_openssl" != "xno"],
 | 
			
		||||
	[AC_MSG_RESULT(yes)
 | 
			
		||||
	AC_CHECK_LIB([ssl], [MD5_Final], ,
 | 
			
		||||
	[if test "x$with_openssl" != "xcheck"; then
 | 
			
		||||
		AC_MSG_FAILURE([--with-openssl was given, but -lssl was not found])
 | 
			
		||||
	fi],
 | 
			
		||||
	[-lcrypto])
 | 
			
		||||
	with_openssl=$ac_cv_lib_ssl_MD5_Final],
 | 
			
		||||
	AC_MSG_RESULT(no))
 | 
			
		||||
AM_CONDITIONAL([HAVE_LIBSSL], [test "x$with_openssl" = "xyes"])
 | 
			
		||||
have_openssl=no
 | 
			
		||||
if test "x$with_openssl" != "xno"; then
 | 
			
		||||
	PKG_CHECK_MODULES(LIBSSL, [libcrypto],
 | 
			
		||||
		[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no)
 | 
			
		||||
	if test "x$have_openssl" = xno -a "x$with_openssl" = xyes; then
 | 
			
		||||
		AC_MSG_ERROR([*** openssl support requested but libraries not found])
 | 
			
		||||
	fi
 | 
			
		||||
fi
 | 
			
		||||
AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
 | 
			
		||||
 | 
			
		||||
# Check for libcurl
 | 
			
		||||
have_libcurl=no
 | 
			
		||||
if test "x$with_libcurl" != "xno"; then
 | 
			
		||||
	PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.19.4],
 | 
			
		||||
		[AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no)
 | 
			
		||||
	if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then
 | 
			
		||||
		AC_MSG_ERROR([*** libcurl >= 7.19.4 is required for internal downloader support])
 | 
			
		||||
	fi
 | 
			
		||||
fi
 | 
			
		||||
AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"])
 | 
			
		||||
 | 
			
		||||
# Check for gpgme
 | 
			
		||||
AC_MSG_CHECKING(whether to link with libgpgme)
 | 
			
		||||
AS_IF([test "x$with_gpgme" != "xno"],
 | 
			
		||||
	[AC_MSG_RESULT(yes)
 | 
			
		||||
	AC_CHECK_LIB([gpgme], [gpgme_check_version], ,
 | 
			
		||||
	[if test "x$with_gpgme" != "xcheck"; then
 | 
			
		||||
		AC_MSG_FAILURE([--with-ggpme was given, but -lgpgme was not found])
 | 
			
		||||
	fi],
 | 
			
		||||
	[-lgpgme])
 | 
			
		||||
	with_gpgme=$ac_cv_lib_gpgme_gpgme_check_version],
 | 
			
		||||
	AC_MSG_RESULT(no))
 | 
			
		||||
AM_CONDITIONAL([HAVE_LIBGPGME], [test "x$with_gpgme" = "xyes"])
 | 
			
		||||
	[AC_MSG_RESULT([yes])],
 | 
			
		||||
	[AC_MSG_RESULT([no])])
 | 
			
		||||
 | 
			
		||||
have_gpgme=no
 | 
			
		||||
AS_IF([test "x$with_gpgme" != "xno"],
 | 
			
		||||
	[AM_PATH_GPGME([1.3.0],
 | 
			
		||||
		[LIBS_save="$LIBS"
 | 
			
		||||
		CPPFLAGS_save="$CPPFLAGS"
 | 
			
		||||
		CFLAGS_save="$CFLAGS"
 | 
			
		||||
 | 
			
		||||
		LIBS="$LIBS $GPGME_LIBS"
 | 
			
		||||
		CPPFLAGS="$CPPFLAGS $GPGME_CPPFLAGS"
 | 
			
		||||
		CFLAGS="$CFLAGS $GPGME_CFLAGS"
 | 
			
		||||
 | 
			
		||||
		AC_MSG_CHECKING([for sane gpgme])
 | 
			
		||||
		AC_LINK_IFELSE(
 | 
			
		||||
			[AC_LANG_PROGRAM(
 | 
			
		||||
				[[#include <gpgme.h>]],
 | 
			
		||||
				[[return gpgme_check_version("1.3.0");]])],
 | 
			
		||||
			[AC_MSG_RESULT([yes])
 | 
			
		||||
			have_gpgme=yes
 | 
			
		||||
			AC_DEFINE([HAVE_LIBGPGME], [1], [Define if gpgme should be used to provide GPG signature support.])],
 | 
			
		||||
			[AC_MSG_RESULT([no])
 | 
			
		||||
			have_gpgme=no
 | 
			
		||||
			unset GPGME_LIBS
 | 
			
		||||
			unset GPGME_CFLAGS]
 | 
			
		||||
			AS_IF([test "x$with_gpgme" = "xyes"],
 | 
			
		||||
				[AC_MSG_FAILURE([*** gpgme >= 1.3.0 is needed for GPG signature support])])
 | 
			
		||||
			)
 | 
			
		||||
 | 
			
		||||
		LIBS="$LIBS_save"
 | 
			
		||||
		CPPFLAGS="$CPPFLAGS_save"
 | 
			
		||||
		CFLAGS="$CFLAGS_save"
 | 
			
		||||
		unset CPPFLAGS_save
 | 
			
		||||
		unset CFLAGS_save],)])
 | 
			
		||||
 | 
			
		||||
AS_IF([test "x$have_gpgme" = xno -a "x$with_gpgme" = xyes],
 | 
			
		||||
	[AC_MSG_FAILURE([--with-gpgme was given, but gpgme was not found])])
 | 
			
		||||
AM_CONDITIONAL([HAVE_LIBGPGME], [test "x$have_gpgme" = "xyes"])
 | 
			
		||||
 | 
			
		||||
# Checks for header files.
 | 
			
		||||
AC_CHECK_HEADERS([fcntl.h float.h glob.h libintl.h limits.h locale.h \
 | 
			
		||||
                  mntent.h stddef.h string.h sys/ioctl.h sys/mount.h \
 | 
			
		||||
AC_CHECK_HEADERS([fcntl.h float.h glob.h langinfo.h libintl.h limits.h \
 | 
			
		||||
                  locale.h mntent.h netinet/in.h netinet/tcp.h \
 | 
			
		||||
                  stddef.h string.h sys/ioctl.h \
 | 
			
		||||
                  sys/mnttab.h sys/mount.h \
 | 
			
		||||
                  sys/param.h sys/statvfs.h sys/time.h sys/types.h \
 | 
			
		||||
                  sys/ucred.h syslog.h termios.h wchar.h])
 | 
			
		||||
 | 
			
		||||
@@ -197,10 +286,11 @@ AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
 | 
			
		||||
AC_FUNC_MALLOC
 | 
			
		||||
AC_FUNC_MKTIME
 | 
			
		||||
AC_FUNC_STRCOLL
 | 
			
		||||
AC_CHECK_FUNCS([dup2 getcwd geteuid getmntinfo gettimeofday memmove memset \
 | 
			
		||||
AC_CHECK_FUNCS([dup2 getcwd getmntinfo gettimeofday memmove memset \
 | 
			
		||||
                mkdir realpath regcomp rmdir setenv setlocale strcasecmp \
 | 
			
		||||
                strchr strcspn strdup strerror strndup strrchr strsep strstr \
 | 
			
		||||
                strtol swprintf tcflush wcwidth uname])
 | 
			
		||||
AC_CHECK_MEMBERS([struct stat.st_blksize],,,[[#include <sys/stat.h>]])
 | 
			
		||||
 | 
			
		||||
# For the diskspace code
 | 
			
		||||
FS_STATS_TYPE
 | 
			
		||||
@@ -208,44 +298,44 @@ AC_CHECK_MEMBERS([struct statvfs.f_flag],,,[[#include <sys/statvfs.h>]])
 | 
			
		||||
AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h>
 | 
			
		||||
                  #include <sys/mount.h>]])
 | 
			
		||||
 | 
			
		||||
# Enable large file support if available
 | 
			
		||||
AC_SYS_LARGEFILE
 | 
			
		||||
 | 
			
		||||
# Check if we can use symbol visibility support in GCC
 | 
			
		||||
GCC_VISIBILITY_CC
 | 
			
		||||
# Check if we have -fgnu89-inline flag
 | 
			
		||||
GCC_GNU89_INLINE_CC
 | 
			
		||||
 | 
			
		||||
# Host-dependant definitions
 | 
			
		||||
SIZECMD="stat -L -c %s"
 | 
			
		||||
SEDINPLACE="sed -i"
 | 
			
		||||
INODECMD="stat -c '%i %n'"
 | 
			
		||||
SIZECMD="stat -c %s"
 | 
			
		||||
SEDINPLACE="sed --follow-symlinks -i"
 | 
			
		||||
DUFLAGS="-sk --apparent-size"
 | 
			
		||||
STRIP_BINARIES="--strip-all"
 | 
			
		||||
STRIP_SHARED="--strip-unneeded"
 | 
			
		||||
STRIP_STATIC="--strip-debug"
 | 
			
		||||
case "${host_os}" in
 | 
			
		||||
	*bsd*)
 | 
			
		||||
		SIZECMD="stat -L -f %z"
 | 
			
		||||
		INODECMD="stat -f '%i %n'"
 | 
			
		||||
		SIZECMD="stat -f %z"
 | 
			
		||||
		SEDINPLACE="sed -i \"\""
 | 
			
		||||
		;;
 | 
			
		||||
	cygwin*)
 | 
			
		||||
		host_os_cygwin=yes
 | 
			
		||||
		CFLAGS="$CFLAGS -DCYGWIN"
 | 
			
		||||
		DUFLAGS="-sk"
 | 
			
		||||
		;;
 | 
			
		||||
	darwin*)
 | 
			
		||||
		host_os_darwin=yes
 | 
			
		||||
		SIZECMD="/usr/bin/stat -L -f %z"
 | 
			
		||||
		INODECMD="/usr/bin/stat -f '%i %n'"
 | 
			
		||||
		SIZECMD="/usr/bin/stat -f %z"
 | 
			
		||||
		SEDINPLACE="/usr/bin/sed -i ''"
 | 
			
		||||
		DUFLAGS="-sk"
 | 
			
		||||
		STRIP_BINARIES=""
 | 
			
		||||
		STRIP_SHARED="-S"
 | 
			
		||||
		STRIP_STATIC="-S"
 | 
			
		||||
		;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes")
 | 
			
		||||
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
 | 
			
		||||
AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
 | 
			
		||||
AC_SUBST(INODECMD)
 | 
			
		||||
AC_SUBST(SIZECMD)
 | 
			
		||||
AC_SUBST(SEDINPLACE)
 | 
			
		||||
AC_SUBST(DUFLAGS)
 | 
			
		||||
AC_SUBST(STRIP_BINARIES)
 | 
			
		||||
AC_SUBST(STRIP_SHARED)
 | 
			
		||||
AC_SUBST(STRIP_STATIC)
 | 
			
		||||
@@ -295,16 +385,49 @@ AC_MSG_CHECKING(for debug mode request)
 | 
			
		||||
if test "x$debug" = "xyes" ; then
 | 
			
		||||
	AC_MSG_RESULT(yes)
 | 
			
		||||
	AC_DEFINE([PACMAN_DEBUG], , [Enable debug code])
 | 
			
		||||
	# Check for mcheck
 | 
			
		||||
	AC_CHECK_HEADERS([mcheck.h])
 | 
			
		||||
	# Check for -fstack-protector availability
 | 
			
		||||
	GCC_STACK_PROTECT_LIB
 | 
			
		||||
	GCC_STACK_PROTECT_CC
 | 
			
		||||
	GCC_FORTIFY_SOURCE_CC
 | 
			
		||||
	CFLAGS="$CFLAGS -g -Wall -Werror"
 | 
			
		||||
	WARNING_CFLAGS="-g -Wall -Werror"
 | 
			
		||||
else
 | 
			
		||||
	AC_MSG_RESULT(no)
 | 
			
		||||
	WARNING_CFLAGS="-Wall"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Enable or disable compiler warning flags
 | 
			
		||||
AC_MSG_CHECKING(for excessive compiler warning flags)
 | 
			
		||||
if test "x$warningflags" = "xyes" ; then
 | 
			
		||||
	AC_MSG_RESULT(yes)
 | 
			
		||||
	CFLAGS_ADD([-Wcast-align], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wclobbered], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wempty-body], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wfloat-equal], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wmissing-field-initializers], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wmissing-parameter-type], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wmissing-prototypes], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wold-style-declaration], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Woverride-init], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wpointer-arith], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wredundant-decls], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wshadow], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wsign-compare], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wstrict-aliasing], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wstrict-overflow=5], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wstrict-prototypes], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wtype-limits], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wuninitialized], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wunused-but-set-parameter], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wunused-parameter], [WARNING_CFLAGS])
 | 
			
		||||
	CFLAGS_ADD([-Wwrite-strings], [WARNING_CFLAGS])
 | 
			
		||||
else
 | 
			
		||||
	AC_MSG_RESULT(no)
 | 
			
		||||
	CFLAGS="$CFLAGS -Wall"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Enable or disable use of git version in pacman version string
 | 
			
		||||
@@ -312,13 +435,9 @@ AC_MSG_CHECKING(whether to use git version if available)
 | 
			
		||||
if test "x$wantgitver" = "xyes" ; then
 | 
			
		||||
	AC_CHECK_PROGS([GIT], [git])
 | 
			
		||||
	AC_CHECK_FILE([.git/], hasgitdir=yes)
 | 
			
		||||
	usegitver=$ac_cv_file__git_
 | 
			
		||||
	if test $GIT -a "x$hasgitdir" = "xyes"; then
 | 
			
		||||
		AC_MSG_RESULT([yes])
 | 
			
		||||
		usegitver=yes
 | 
			
		||||
		AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string])
 | 
			
		||||
	else
 | 
			
		||||
		AC_MSG_RESULT([no, git or .git dir missing])
 | 
			
		||||
		usegitver=no
 | 
			
		||||
	fi
 | 
			
		||||
else
 | 
			
		||||
	AC_MSG_RESULT([no, disabled by configure])
 | 
			
		||||
@@ -328,6 +447,7 @@ AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
 | 
			
		||||
 | 
			
		||||
# Set root directory
 | 
			
		||||
AC_SUBST(ROOTDIR)
 | 
			
		||||
AC_DEFINE_UNQUOTED([ROOTDIR], "$ROOTDIR", [The location of the root operating directory])
 | 
			
		||||
# Set package file extension
 | 
			
		||||
AC_SUBST(PKGEXT)
 | 
			
		||||
AC_DEFINE_UNQUOTED([PKGEXT], "$PKGEXT", [The file extension used by pacman packages])
 | 
			
		||||
@@ -337,11 +457,23 @@ AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman sourc
 | 
			
		||||
# Set makepkg build script name
 | 
			
		||||
AC_SUBST(BUILDSCRIPT)
 | 
			
		||||
AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg])
 | 
			
		||||
# Set makepkg split debugging symbol package suffix
 | 
			
		||||
AC_SUBST(DEBUGSUFFIX)
 | 
			
		||||
AC_DEFINE_UNQUOTED([DEBUGSUFFIX], "$DEBUGSUFFIX", [The suffix for debugging symbol packages used by makepkg])
 | 
			
		||||
# Set shell used by install scriptlets
 | 
			
		||||
AC_SUBST(SCRIPTLET_SHELL)
 | 
			
		||||
AC_DEFINE_UNQUOTED([SCRIPTLET_SHELL], "$SCRIPTLET_SHELL", [The full path of the shell used to run install scriptlets])
 | 
			
		||||
# Set ldconfig path
 | 
			
		||||
AC_SUBST(LDCONFIG)
 | 
			
		||||
AC_DEFINE_UNQUOTED([LDCONFIG], "$LDCONFIG", [The full path to ldconfig])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Configuration files
 | 
			
		||||
AC_CONFIG_FILES([
 | 
			
		||||
lib/libalpm/Makefile
 | 
			
		||||
lib/libalpm/po/Makefile.in
 | 
			
		||||
lib/libalpm/libalpm.pc
 | 
			
		||||
src/common/Makefile
 | 
			
		||||
src/pacman/Makefile
 | 
			
		||||
src/pacman/po/Makefile.in
 | 
			
		||||
src/util/Makefile
 | 
			
		||||
@@ -351,6 +483,7 @@ doc/Makefile
 | 
			
		||||
etc/Makefile
 | 
			
		||||
test/pacman/Makefile
 | 
			
		||||
test/pacman/tests/Makefile
 | 
			
		||||
test/scripts/Makefile
 | 
			
		||||
test/util/Makefile
 | 
			
		||||
contrib/Makefile
 | 
			
		||||
Makefile
 | 
			
		||||
@@ -371,13 +504,13 @@ ${PACKAGE_NAME}:
 | 
			
		||||
 | 
			
		||||
    compiler               : ${CC}
 | 
			
		||||
    preprocessor flags     : ${CPPFLAGS}
 | 
			
		||||
    compiler flags         : ${CFLAGS}
 | 
			
		||||
    defines                : ${DEFS}
 | 
			
		||||
    library flags          : ${LIBS}
 | 
			
		||||
    compiler flags         : ${WARNING_CFLAGS} ${CFLAGS}
 | 
			
		||||
    library flags          : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
 | 
			
		||||
    linker flags           : ${LDFLAGS}
 | 
			
		||||
 | 
			
		||||
    Architecture           : ${CARCH}
 | 
			
		||||
    Host Type              : ${CHOST}
 | 
			
		||||
    File inode command     : ${INODECMD}
 | 
			
		||||
    Filesize command       : ${SIZECMD}
 | 
			
		||||
    In-place sed command   : ${SEDINPLACE}
 | 
			
		||||
 | 
			
		||||
@@ -393,12 +526,14 @@ ${PACKAGE_NAME}:
 | 
			
		||||
    build script name      : ${BUILDSCRIPT}
 | 
			
		||||
 | 
			
		||||
  Compilation options:
 | 
			
		||||
    Use libcurl            : ${with_libcurl}
 | 
			
		||||
    Use GPGME              : ${with_gpgme}
 | 
			
		||||
    Use OpenSSL            : ${with_openssl}
 | 
			
		||||
    Use libcurl            : ${have_libcurl}
 | 
			
		||||
    Use GPGME              : ${have_gpgme}
 | 
			
		||||
    Use OpenSSL            : ${have_openssl}
 | 
			
		||||
    Run make in doc/ dir   : ${wantdoc} ${asciidoc}
 | 
			
		||||
    Doxygen support        : ${usedoxygen}
 | 
			
		||||
    debug support          : ${debug}
 | 
			
		||||
    extra warning flags    : ${warningflags}
 | 
			
		||||
    use git version        : ${wantgitver}
 | 
			
		||||
"
 | 
			
		||||
 | 
			
		||||
# vim:set ts=2 sw=2 noet:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								contrib/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								contrib/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -6,5 +6,7 @@ paclist
 | 
			
		||||
paclog-pkglist
 | 
			
		||||
pacscripts
 | 
			
		||||
pacsearch
 | 
			
		||||
wget-xdelta.sh
 | 
			
		||||
pacsysclean
 | 
			
		||||
rankmirrors
 | 
			
		||||
updpkgsums
 | 
			
		||||
zsh_completion
 | 
			
		||||
 
 | 
			
		||||
@@ -1,26 +1,46 @@
 | 
			
		||||
OURSCRIPTS = \
 | 
			
		||||
# enforce that all scripts have a --help and --version option
 | 
			
		||||
AUTOMAKE_OPTIONS = std-options
 | 
			
		||||
 | 
			
		||||
bin_SCRIPTS = \
 | 
			
		||||
  $(OURSCRIPTS)
 | 
			
		||||
 | 
			
		||||
BASHSCRIPTS = \
 | 
			
		||||
	bacman \
 | 
			
		||||
	checkupdates \
 | 
			
		||||
	paccache \
 | 
			
		||||
	pacdiff \
 | 
			
		||||
	paclist \
 | 
			
		||||
	paclog-pkglist \
 | 
			
		||||
	pacscripts \
 | 
			
		||||
	pacsysclean \
 | 
			
		||||
	rankmirrors \
 | 
			
		||||
	updpkgsums
 | 
			
		||||
 | 
			
		||||
OTHERSCRIPTS = \
 | 
			
		||||
	pacsearch
 | 
			
		||||
 | 
			
		||||
OURSCRIPTS = \
 | 
			
		||||
	$(BASHSCRIPTS) \
 | 
			
		||||
	$(OTHERSCRIPTS)
 | 
			
		||||
 | 
			
		||||
OURFILES = \
 | 
			
		||||
	bash_completion \
 | 
			
		||||
	zsh_completion
 | 
			
		||||
 | 
			
		||||
EXTRA_DIST = \
 | 
			
		||||
	PKGBUILD.vim \
 | 
			
		||||
	bacman.in \
 | 
			
		||||
	bacman.sh.in \
 | 
			
		||||
	bash_completion.in \
 | 
			
		||||
	paccache.in \
 | 
			
		||||
	paclog-pkglist.in \
 | 
			
		||||
	pacdiff.in \
 | 
			
		||||
	paclist.in \
 | 
			
		||||
	pacscripts.in \
 | 
			
		||||
	checkupdates.sh.in \
 | 
			
		||||
	paccache.sh.in \
 | 
			
		||||
	paclog-pkglist.sh.in \
 | 
			
		||||
	pacdiff.sh.in \
 | 
			
		||||
	paclist.sh.in \
 | 
			
		||||
	pacscripts.sh.in \
 | 
			
		||||
	pacsearch.in \
 | 
			
		||||
	pacsysclean.sh.in \
 | 
			
		||||
	rankmirrors.sh.in \
 | 
			
		||||
	updpkgsums.sh.in \
 | 
			
		||||
	vimprojects \
 | 
			
		||||
	zsh_completion.in \
 | 
			
		||||
	README
 | 
			
		||||
@@ -28,38 +48,63 @@ EXTRA_DIST = \
 | 
			
		||||
# Files that should be removed, but which Automake does not know.
 | 
			
		||||
MOSTLYCLEANFILES = $(OURSCRIPTS) $(OURFILES) *.tmp
 | 
			
		||||
 | 
			
		||||
if USE_GIT_VERSION
 | 
			
		||||
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
 | 
			
		||||
REAL_PACKAGE_VERSION = $(GIT_VERSION)
 | 
			
		||||
else
 | 
			
		||||
REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
edit = sed \
 | 
			
		||||
	-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
 | 
			
		||||
	-e 's|@localstatedir[@]|$(localstatedir)|g' \
 | 
			
		||||
	-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
 | 
			
		||||
	-e 's|@SIZECMD[@]|$(SIZECMD)|g' \
 | 
			
		||||
	-e 's|@SCRIPTNAME[@]|$@|g' \
 | 
			
		||||
	-e '1s|!/bin/bash|!$(BASH_SHELL)|g'
 | 
			
		||||
 | 
			
		||||
$(OURSCRIPTS): Makefile
 | 
			
		||||
	@echo '    ' GEN $@;
 | 
			
		||||
	@$(RM) $@ $@.tmp
 | 
			
		||||
	@$(edit) $(srcdir)/$@.in >$@.tmp
 | 
			
		||||
	@chmod +x $@.tmp
 | 
			
		||||
	@chmod a-w $@.tmp
 | 
			
		||||
	@mv $@.tmp $@
 | 
			
		||||
$(OTHERSCRIPTS): Makefile
 | 
			
		||||
	$(AM_V_at)$(RM) $@ $@.tmp
 | 
			
		||||
	$(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
 | 
			
		||||
	$(AM_V_at)chmod +x,a-w $@.tmp
 | 
			
		||||
	$(AM_V_at)mv $@.tmp $@
 | 
			
		||||
 | 
			
		||||
$(BASHSCRIPTS): Makefile
 | 
			
		||||
	$(AM_V_at)$(RM) $@
 | 
			
		||||
	$(AM_V_GEN)test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@
 | 
			
		||||
	$(AM_V_at)chmod +x,a-w $@
 | 
			
		||||
	@$(BASH_SHELL) -O extglob -n $@
 | 
			
		||||
 | 
			
		||||
$(OURFILES): Makefile
 | 
			
		||||
	@echo '    ' GEN $@;
 | 
			
		||||
	@$(RM) $@ $@.tmp
 | 
			
		||||
	@$(edit) $(srcdir)/$@.in >$@.tmp
 | 
			
		||||
	@chmod a-w $@.tmp
 | 
			
		||||
	@mv $@.tmp $@
 | 
			
		||||
	$(AM_V_at)$(RM) $@ $@.tmp
 | 
			
		||||
	$(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
 | 
			
		||||
	$(AM_V_at)chmod a-w $@.tmp
 | 
			
		||||
	$(AM_V_at)mv $@.tmp $@
 | 
			
		||||
 | 
			
		||||
all-am: $(OURSCRIPTS) $(OURFILES)
 | 
			
		||||
 | 
			
		||||
bacman: $(srcdir)/bacman.in
 | 
			
		||||
install-data-local:
 | 
			
		||||
	$(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
 | 
			
		||||
	$(INSTALL_DATA) bash_completion $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
 | 
			
		||||
	$(MKDIR_P) $(DESTDIR)$(datarootdir)/zsh/site-functions/
 | 
			
		||||
	$(INSTALL_DATA) zsh_completion $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
 | 
			
		||||
 | 
			
		||||
uninstall-local:
 | 
			
		||||
	$(RM) $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
 | 
			
		||||
	$(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
 | 
			
		||||
 | 
			
		||||
bacman: $(srcdir)/bacman.sh.in
 | 
			
		||||
bash_completion: $(srcdir)/bash_completion.in
 | 
			
		||||
paccache: $(srcdir)/paccache.in
 | 
			
		||||
pacdiff: $(srcdir)/pacdiff.in
 | 
			
		||||
paclist: $(srcdir)/paclist.in
 | 
			
		||||
paclog-pkglist: $(srcdir)/paclog-pkglist.in
 | 
			
		||||
pacscripts: $(srcdir)/pacscripts.in
 | 
			
		||||
checkupdates: $(srcdir)/checkupdates.sh.in
 | 
			
		||||
paccache: $(srcdir)/paccache.sh.in $(top_srcdir)/scripts/library/parseopts.sh $(top_srcdir)/scripts/library/size_to_human.sh
 | 
			
		||||
pacdiff: $(srcdir)/pacdiff.sh.in
 | 
			
		||||
paclist: $(srcdir)/paclist.sh.in
 | 
			
		||||
paclog-pkglist: $(srcdir)/paclog-pkglist.sh.in
 | 
			
		||||
pacscripts: $(srcdir)/pacscripts.sh.in
 | 
			
		||||
pacsearch: $(srcdir)/pacsearch.in
 | 
			
		||||
pactree: $(srcdir)/pactree.in
 | 
			
		||||
pacsysclean: $(srcdir)/pacsysclean.sh.in
 | 
			
		||||
rankmirrors: $(srcdir)/rankmirrors.sh.in
 | 
			
		||||
updpkgsums: $(srcdir)/updpkgsums.sh.in
 | 
			
		||||
zsh_completion: $(srcdir)/zsh_completion.in
 | 
			
		||||
 | 
			
		||||
# vim:set ts=2 sw=2 noet:
 | 
			
		||||
 
 | 
			
		||||
@@ -69,8 +69,8 @@ syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubl
 | 
			
		||||
" license
 | 
			
		||||
syn keyword pb_k_license license contained
 | 
			
		||||
" echo $(pacman -Ql licenses | grep '/usr/share/licenses/common/' | cut -d'/' -f6 | sort -u)
 | 
			
		||||
syn keyword pbLicense  APACHE CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PerlArtistic PHP PSF RALINK RUBY ZPL contained
 | 
			
		||||
" special cases from http://wiki.archlinux.org/index.php/Arch_Packaging_Standards
 | 
			
		||||
syn keyword pbLicense  AGPL AGPL3 Apache APACHE Artistic2.0 CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PerlArtistic PHP PSF RUBY W3C ZPL contained
 | 
			
		||||
" special cases from https://wiki.archlinux.org/index.php/Arch_Packaging_Standards
 | 
			
		||||
syn keyword pbLicenseSpecial  BSD MIT ZLIB Python contained
 | 
			
		||||
syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained
 | 
			
		||||
syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicenseSpecial,pbLicense
 | 
			
		||||
@@ -108,7 +108,7 @@ syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
 | 
			
		||||
syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote
 | 
			
		||||
 | 
			
		||||
" checkdepends
 | 
			
		||||
syn keyword pb_k_ckdepends ckdepends contained
 | 
			
		||||
syn keyword pb_k_ckdepends checkdepends contained
 | 
			
		||||
syn match pbValidCkdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
 | 
			
		||||
syn region pbCkdependsGroup start=/^checkdepends=(/ end=/)/ contains=pb_k_ckdepends,pbValidCkdepends,shDoubleQuote,shSingleQuote
 | 
			
		||||
 | 
			
		||||
@@ -176,12 +176,45 @@ hi def link pbSha1Quotes Keyword
 | 
			
		||||
hi def link pbSha1Hash Error
 | 
			
		||||
hi def link pbValidSha1sums  Number
 | 
			
		||||
 | 
			
		||||
" sha256sums
 | 
			
		||||
syn keyword pb_k_sha256sums sha256sums contained
 | 
			
		||||
syn match pbIllegalSha256sums /[^='"()\/ ]/ contained contains=pbValidSha256sums
 | 
			
		||||
syn match pbValidSha256sums /\x\{64\}/ contained
 | 
			
		||||
syn region pbSha256sumsGroup start=/^sha256sums/ end=/)/ contains=pb_k_sha256sums,pbSha256Quotes,pbSha256Hash,pbIllegalSha256sums keepend
 | 
			
		||||
syn match pbSha256Quotes /'.*'\|".*"/ contained contains=pbSha256Hash,pbIllegalSha256sums
 | 
			
		||||
syn match pbSha256Hash /\x\+/ contained contains=pbValidSha256sums
 | 
			
		||||
hi def link pbSha256Quotes Keyword
 | 
			
		||||
hi def link pbSha256Hash Error
 | 
			
		||||
hi def link pbValidSha256sums  Number
 | 
			
		||||
 | 
			
		||||
" sha384sums
 | 
			
		||||
syn keyword pb_k_sha384sums sha384sums contained
 | 
			
		||||
syn match pbIllegalSha384sums /[^='"()\/ ]/ contained contains=pbValidSha384sums
 | 
			
		||||
syn match pbValidSha384sums /\x\{96\}/ contained
 | 
			
		||||
syn region pbSha384sumsGroup start=/^sha384sums/ end=/)/ contains=pb_k_sha384sums,pbSha384Quotes,pbSha384Hash,pbIllegalSha384sums keepend
 | 
			
		||||
syn match pbSha384Quotes /'.*'\|".*"/ contained contains=pbSha384Hash,pbIllegalSha384sums
 | 
			
		||||
syn match pbSha384Hash /\x\+/ contained contains=pbValidSha384sums
 | 
			
		||||
hi def link pbSha384Quotes Keyword
 | 
			
		||||
hi def link pbSha384Hash Error
 | 
			
		||||
hi def link pbValidSha384sums  Number
 | 
			
		||||
 | 
			
		||||
" sha512sums
 | 
			
		||||
syn keyword pb_k_sha512sums sha512sums contained
 | 
			
		||||
syn match pbIllegalSha512sums /[^='"()\/ ]/ contained contains=pbValidSha512sums
 | 
			
		||||
syn match pbValidSha512sums /\x\{128\}/ contained
 | 
			
		||||
syn region pbSha512sumsGroup start=/^sha512sums/ end=/)/ contains=pb_k_sha512sums,pbSha512Quotes,pbSha512Hash,pbIllegalSha512sums keepend
 | 
			
		||||
syn match pbSha512Quotes /'.*'\|".*"/ contained contains=pbSha512Hash,pbIllegalSha512sums
 | 
			
		||||
syn match pbSha512Hash /\x\+/ contained contains=pbValidSha512sums
 | 
			
		||||
hi def link pbSha512Quotes Keyword
 | 
			
		||||
hi def link pbSha512Hash Error
 | 
			
		||||
hi def link pbValidSha512sums  Number
 | 
			
		||||
 | 
			
		||||
" options
 | 
			
		||||
syn keyword pb_k_options options contained
 | 
			
		||||
syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|ccache\|distcc\|makeflags\|buildflags\)/ contained
 | 
			
		||||
syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|fakeroot\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
 | 
			
		||||
syn match   pbOptionsNeg     /\!/ contained
 | 
			
		||||
syn match   pbOptionsDeprec  /no/ contained
 | 
			
		||||
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption,shDoubleQuote,shSingleQuote
 | 
			
		||||
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
 | 
			
		||||
syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions
 | 
			
		||||
 | 
			
		||||
" noextract
 | 
			
		||||
@@ -258,6 +291,15 @@ hi def link pbIllegalMd5sums Error
 | 
			
		||||
hi def link pb_k_sha1sums pbKeywords
 | 
			
		||||
hi def link pbIllegalSha1sums Error
 | 
			
		||||
 | 
			
		||||
hi def link pb_k_sha256sums pbKeywords
 | 
			
		||||
hi def link pbIllegalSha256sums Error
 | 
			
		||||
 | 
			
		||||
hi def link pb_k_sha384sums pbKeywords
 | 
			
		||||
hi def link pbIllegalSha384sums Error
 | 
			
		||||
 | 
			
		||||
hi def link pb_k_sha512sums pbKeywords
 | 
			
		||||
hi def link pbIllegalSha512sums Error
 | 
			
		||||
 | 
			
		||||
hi def link pb_k_options pbKeywords
 | 
			
		||||
hi def link pbOptionsDeprec Todo
 | 
			
		||||
hi def link pbIllegalOption Error
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,17 @@ PKGBUILD.vim - a vim/gvim syntax file for PKGBUILDs. Colors known variable
 | 
			
		||||
names, highlights common errors such as invalid characters in pkgname or
 | 
			
		||||
pkgver, etc.
 | 
			
		||||
 | 
			
		||||
bacman - regenerate a pacman package based on installed files and the pacman
 | 
			
		||||
database entries. Useful for reuse, or possible config file extension.
 | 
			
		||||
 | 
			
		||||
bash_completion - a bash completion script for pacman, install in
 | 
			
		||||
/etc/bash_completion.d/ for use (but rename to something descriptive!).
 | 
			
		||||
 | 
			
		||||
zsh_completion - a zsh completion script, install (with a rename) to
 | 
			
		||||
/usr/share/zsh/site-functions/.
 | 
			
		||||
checkupdates - print a list of pending updates without touching the system
 | 
			
		||||
sync databases (for safety on rolling release distributions).
 | 
			
		||||
 | 
			
		||||
paccache - a flexible package cache cleaning utility that allows greater
 | 
			
		||||
control over which packages are removed.
 | 
			
		||||
 | 
			
		||||
pacdiff - a simple pacnew/pacorig/pacsave updater for /etc/.
 | 
			
		||||
 | 
			
		||||
@@ -16,6 +22,8 @@ paclist - list all packages installed from a given repository. Useful for
 | 
			
		||||
seeing which packages you may have installed from the testing repository,
 | 
			
		||||
for instance.
 | 
			
		||||
 | 
			
		||||
paclog-pkglist - lists currently installs packages based pacman's log.
 | 
			
		||||
 | 
			
		||||
pacscripts - tries to print out the {pre,post}_{install,remove,upgrade}
 | 
			
		||||
scripts of a given package.
 | 
			
		||||
 | 
			
		||||
@@ -23,8 +31,13 @@ pacsearch - a colorized search combining both -Ss and -Qs output. Installed
 | 
			
		||||
packages are easily identified with a *** and local-only packages are also
 | 
			
		||||
listed.
 | 
			
		||||
 | 
			
		||||
bacman - regenerate a pacman package based on installed files and the pacman
 | 
			
		||||
database entries. Useful for reuse, or possible config file extension.
 | 
			
		||||
pacsysclean - lists installed packages sorted by size.
 | 
			
		||||
 | 
			
		||||
rankmirrors - ranks pacman mirrors by their connection and opening speed.
 | 
			
		||||
 | 
			
		||||
updpkgsums - performs an in place update of the checksums in a PKGBUILD.
 | 
			
		||||
 | 
			
		||||
vimprojects - a project file for the vim project plugin.
 | 
			
		||||
 | 
			
		||||
zsh_completion - a zsh completion script, install (with a rename) to
 | 
			
		||||
/usr/share/zsh/site-functions/.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										93
									
								
								contrib/bacman.in → contrib/bacman.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										93
									
								
								contrib/bacman.in → contrib/bacman.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -4,7 +4,8 @@
 | 
			
		||||
#   This script rebuilds an already installed package using metadata
 | 
			
		||||
#   stored into the pacman database and system files
 | 
			
		||||
#
 | 
			
		||||
#   (c) 2008 - locci <carlocci_at_gmail_dot_com>
 | 
			
		||||
#   Copyright (c) 2008 locci <carlocci_at_gmail_dot_com>
 | 
			
		||||
#   Copyright (c) 2008-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
#
 | 
			
		||||
#   This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#   it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -23,31 +24,43 @@
 | 
			
		||||
shopt -s extglob
 | 
			
		||||
shopt -s nullglob
 | 
			
		||||
 | 
			
		||||
readonly progname="bacman"
 | 
			
		||||
readonly progver="0.2.1"
 | 
			
		||||
declare -r myname='bacman'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
USE_COLOR='y'
 | 
			
		||||
 | 
			
		||||
m4_include(../scripts/library/output_format.sh)
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# User Friendliness
 | 
			
		||||
#
 | 
			
		||||
usage() {
 | 
			
		||||
	echo "This program recreates a package using pacman's db and system files"
 | 
			
		||||
	echo "Usage:   $progname <installed package name>"
 | 
			
		||||
	echo "Example: $progname kernel26"
 | 
			
		||||
	echo "Usage:   $myname [--nocolor] <installed package name>"
 | 
			
		||||
	echo "Example: $myname kernel26"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [[ $1 == "--nocolor" ]]; then
 | 
			
		||||
	USE_COLOR='n'
 | 
			
		||||
	shift
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
m4_include(../scripts/library/term_colors.sh)
 | 
			
		||||
 | 
			
		||||
if (( $# != 1 )); then
 | 
			
		||||
	usage
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ $1 == "--help" || $1 == "-h" ]]; then
 | 
			
		||||
if [[ $1 = -@(h|-help) ]]; then
 | 
			
		||||
	usage
 | 
			
		||||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ $1 == "--version" || $1 == "-v" ]]; then
 | 
			
		||||
	echo "$progname version $progver"
 | 
			
		||||
	echo "Copyright (C) 2008 locci"
 | 
			
		||||
elif [[ $1 = -@(V|-version) ]]; then
 | 
			
		||||
	version
 | 
			
		||||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@@ -56,14 +69,13 @@ fi
 | 
			
		||||
#
 | 
			
		||||
if (( EUID )); then
 | 
			
		||||
	if [[ -f /usr/bin/fakeroot ]]; then
 | 
			
		||||
		echo "Entering fakeroot environment"
 | 
			
		||||
		msg "Entering fakeroot environment"
 | 
			
		||||
		export INFAKEROOT="1"
 | 
			
		||||
		/usr/bin/fakeroot -u -- "$0" "$@"
 | 
			
		||||
		exit $?
 | 
			
		||||
	else
 | 
			
		||||
		echo "WARNING: installing fakeroot or running ${progname} as root is required to"
 | 
			
		||||
		echo "         preserve the ownership permissions of files in some packages"
 | 
			
		||||
		echo ""
 | 
			
		||||
		warning "installing fakeroot or running $myname as root is required to"
 | 
			
		||||
		plain   "         preserve the ownership permissions of files in some packages\n"
 | 
			
		||||
	fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +83,7 @@ fi
 | 
			
		||||
# Setting environmental variables
 | 
			
		||||
#
 | 
			
		||||
if [[ ! -r @sysconfdir@/pacman.conf ]]; then
 | 
			
		||||
	echo "ERROR: unable to read @sysconfdir@/pacman.conf"
 | 
			
		||||
	error "unable to read @sysconfdir@/pacman.conf"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@@ -79,7 +91,7 @@ eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
 | 
			
		||||
pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
 | 
			
		||||
 | 
			
		||||
if [[ ! -r @sysconfdir@/makepkg.conf ]]; then
 | 
			
		||||
	echo "ERROR: unable to read @sysconfdir@/makepkg.conf"
 | 
			
		||||
	error "unable to read @sysconfdir@/makepkg.conf"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +100,6 @@ if [[ -r ~/.makepkg.conf ]]; then
 | 
			
		||||
	source ~/.makepkg.conf
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
pkg_arch=${CARCH:-'unknown'}
 | 
			
		||||
pkg_dest="${PKGDEST:-$PWD}"
 | 
			
		||||
pkg_pkger=${PACKAGER:-'Unknown Packager'}
 | 
			
		||||
 | 
			
		||||
@@ -100,34 +111,34 @@ pkg_namver=("${pkg_dir[@]##*/}")
 | 
			
		||||
# Checks everything is in place
 | 
			
		||||
#
 | 
			
		||||
if [[ ! -d $pac_db ]]; then
 | 
			
		||||
	echo "ERROR: pacman database directory ${pac_db} not found"
 | 
			
		||||
	error "pacman database directory ${pac_db} not found"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if (( ${#pkg_dir[@]} != 1 )); then
 | 
			
		||||
	printf "ERROR: %d entries for package %s found in pacman database\n" \
 | 
			
		||||
	error "%d entries for package %s found in pacman database" \
 | 
			
		||||
		${#pkg_dir[@]} "${pkg_name}"
 | 
			
		||||
	printf "%s\n" "${pkg_dir[@]}"
 | 
			
		||||
	msg2 "%s" "${pkg_dir[@]}"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ ! -d $pkg_dir ]]; then
 | 
			
		||||
	printf "ERROR: package %s is found in pacman database,\n" "${pkg_name}"
 | 
			
		||||
	printf "       but \`%s' is not a directory\n" "${pkg_dir}"
 | 
			
		||||
	error "package %s is found in pacman database," "${pkg_name}"
 | 
			
		||||
	plain "       but \`%s' is not a directory" "${pkg_dir}"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# Begin
 | 
			
		||||
#
 | 
			
		||||
echo "Package: ${pkg_namver}"
 | 
			
		||||
msg "Package: ${pkg_namver}"
 | 
			
		||||
work_dir=$(mktemp -d --tmpdir bacman.XXXXXXXXXX)
 | 
			
		||||
cd "$work_dir" || exit 1
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# File copying
 | 
			
		||||
#
 | 
			
		||||
echo "Copying package files..."
 | 
			
		||||
msg2 "Copying package files..."
 | 
			
		||||
 | 
			
		||||
cat "$pkg_dir"/files |
 | 
			
		||||
while read i; do
 | 
			
		||||
@@ -148,17 +159,14 @@ while read i; do
 | 
			
		||||
 | 
			
		||||
				# Workaround to bsdtar not reporting a missing file as an error
 | 
			
		||||
				if ! [[ -e $work_dir/$i || -L $work_dir/$i ]]; then
 | 
			
		||||
					echo ""
 | 
			
		||||
					echo "ERROR: unable to add /$i to the package"
 | 
			
		||||
					echo "       If your user does not have permssion to read this file then"
 | 
			
		||||
					echo "       you will need to run $progname as root"
 | 
			
		||||
					error "unable to add /$i to the package"
 | 
			
		||||
					plain "       If your user does not have permssion to read this file then"
 | 
			
		||||
					plain "       you will need to run $myname as root"
 | 
			
		||||
					rm -rf "$work_dir"
 | 
			
		||||
					exit 1
 | 
			
		||||
				fi
 | 
			
		||||
			else
 | 
			
		||||
				echo ""
 | 
			
		||||
				echo "WARNING: package file /$i is missing"
 | 
			
		||||
				echo ""
 | 
			
		||||
				warning "package file /$i is missing"
 | 
			
		||||
			fi
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
@@ -176,15 +184,14 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}')
 | 
			
		||||
# .PKGINFO stuff
 | 
			
		||||
# TODO adopt makepkg's write_pkginfo() into this or scripts/library
 | 
			
		||||
#
 | 
			
		||||
echo Generating .PKGINFO metadata...
 | 
			
		||||
echo "# Generated by $progname $progver"    > .PKGINFO
 | 
			
		||||
msg2 "Generating .PKGINFO metadata..."
 | 
			
		||||
echo "# Generated by $myname $myver"    > .PKGINFO
 | 
			
		||||
if [[ $INFAKEROOT == "1" ]]; then
 | 
			
		||||
	echo "# Using $(fakeroot -v)"    >> .PKGINFO
 | 
			
		||||
fi
 | 
			
		||||
echo "# $(LC_ALL=C date)"            >> .PKGINFO
 | 
			
		||||
echo "#"                    >> .PKGINFO
 | 
			
		||||
 | 
			
		||||
cat "$pkg_dir"/{desc,files} |
 | 
			
		||||
while read i; do
 | 
			
		||||
	if [[ -z $i ]]; then
 | 
			
		||||
		continue;
 | 
			
		||||
@@ -214,6 +221,7 @@ while read i; do
 | 
			
		||||
			;;
 | 
			
		||||
		%ARCH%)
 | 
			
		||||
			echo "arch = $i"    >> .PKGINFO
 | 
			
		||||
			pkg_arch="$i"
 | 
			
		||||
			;;
 | 
			
		||||
		%BUILDDATE%)
 | 
			
		||||
			echo "builddate = $(date -u "+%s")"    >> .PKGINFO
 | 
			
		||||
@@ -249,7 +257,7 @@ while read i; do
 | 
			
		||||
			echo "backup = ${i%%$'\t'*}"   >> .PKGINFO
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
done < <(cat "$pkg_dir"/{desc,files})
 | 
			
		||||
 | 
			
		||||
comp_files=".PKGINFO"
 | 
			
		||||
 | 
			
		||||
@@ -271,7 +279,7 @@ chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
 | 
			
		||||
#
 | 
			
		||||
# Generate the package
 | 
			
		||||
#
 | 
			
		||||
echo "Generating the package..."
 | 
			
		||||
msg2 "Generating the package..."
 | 
			
		||||
 | 
			
		||||
pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
 | 
			
		||||
ret=0
 | 
			
		||||
@@ -285,22 +293,21 @@ case "$PKGEXT" in
 | 
			
		||||
	*tar.xz)  xz -c -z - ;;
 | 
			
		||||
	*tar.Z)   compress -c -f ;;
 | 
			
		||||
	*tar)     cat ;;
 | 
			
		||||
	*) echo "WARNING: '%s' is not a valid archive extension." \
 | 
			
		||||
	"$PKGEXT" >&2; cat ;;
 | 
			
		||||
	*) warning "'%s' is not a valid archive extension." \
 | 
			
		||||
	"$PKGEXT"; cat ;;
 | 
			
		||||
esac > "${pkg_file}"; ret=$?
 | 
			
		||||
 | 
			
		||||
if (( ret )); then
 | 
			
		||||
	echo "ERROR: unable to write package to $pkg_dest"
 | 
			
		||||
	echo "       Maybe the disk is full or you do not have write access"
 | 
			
		||||
	error "Unable to write package to $pkg_dest"
 | 
			
		||||
	plain "       Maybe the disk is full or you do not have write access"
 | 
			
		||||
	rm -rf "$work_dir"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
rm -rf "$work_dir"
 | 
			
		||||
 | 
			
		||||
echo Done
 | 
			
		||||
msg "Done."
 | 
			
		||||
 | 
			
		||||
exit 0
 | 
			
		||||
 | 
			
		||||
# vim: set ts=2 sw=2 noet:
 | 
			
		||||
 | 
			
		||||
@@ -27,17 +27,45 @@ _arch_incomp() {
 | 
			
		||||
  local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_keyids() {
 | 
			
		||||
  \pacman-key --list-keys 2>/dev/null | awk '
 | 
			
		||||
    $1 == "pub" {
 | 
			
		||||
      # key id
 | 
			
		||||
      split($2, a, "/"); print a[2]
 | 
			
		||||
    }
 | 
			
		||||
    $1 == "uid" {
 | 
			
		||||
      # email
 | 
			
		||||
      if (match($NF, /<[^>]+>/))
 | 
			
		||||
        print substr($NF, RSTART + 1, RLENGTH - 2)
 | 
			
		||||
    }'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_key() {
 | 
			
		||||
  local cur opts prev
 | 
			
		||||
  local o cur opts prev wantfiles
 | 
			
		||||
  COMPREPLY=()
 | 
			
		||||
  _get_comp_words_by_ref cur prev
 | 
			
		||||
  if [[ $cur = -* &&
 | 
			
		||||
      $prev != -@(a|-add|c|-config|g|-gpgdir|h|-help|import?(-trustdb)) ]]; then
 | 
			
		||||
    opts=('add delete export finger help list-keys recv-keys updatedb verify version
 | 
			
		||||
           config edit-key gpgdir import import-trustdb init keyserver list-sigs
 | 
			
		||||
           lsign-key populate refresh-keys'
 | 
			
		||||
          'a d e f h l r u v V')
 | 
			
		||||
  opts=('add config delete edit-key export finger gpgdir
 | 
			
		||||
         help import import-trustdb init keyserver list-keys list-sigs
 | 
			
		||||
         lsign-key nocolor populate recv-keys refresh-keys updatedb
 | 
			
		||||
         verify version'
 | 
			
		||||
        'a d e f h l r u v V')
 | 
			
		||||
 | 
			
		||||
  # operations for which we want to complete keyids
 | 
			
		||||
  for o in 'd delete' 'e export' 'f finger' 'l list-keys' 'r recv-keys' \
 | 
			
		||||
      'edit-key' 'list-sigs' 'lsign-key' 'refresh-keys'; do
 | 
			
		||||
    _arch_incomp "$o" && break
 | 
			
		||||
    unset o
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  # options for which we want file completion
 | 
			
		||||
  wantfiles='-@(c|-config|g|-gpgdir)'
 | 
			
		||||
 | 
			
		||||
  if [[ $prev = 'pacman-key' || ( $cur = -* && $prev != $wantfiles ) ]]; then
 | 
			
		||||
    _arch_ptr2comp opts
 | 
			
		||||
  elif [[ $prev = @(-k|--keyserver) ]]; then
 | 
			
		||||
    return
 | 
			
		||||
  elif [[ $prev != $wantfiles && $o ]]; then
 | 
			
		||||
    COMPREPLY=($(compgen -W '$(_pacman_keyids)' -- "$cur"))
 | 
			
		||||
  fi
 | 
			
		||||
  true
 | 
			
		||||
}
 | 
			
		||||
@@ -47,9 +75,10 @@ _makepkg() {
 | 
			
		||||
  COMPREPLY=()
 | 
			
		||||
  _get_comp_words_by_ref cur prev
 | 
			
		||||
  if [[ $cur = -* && ! $prev =~ ^-(-(config|help)$|\w*[Chp]) ]]; then
 | 
			
		||||
    opts=('allsource asroot check clean config force geninteg help holdver ignorearch
 | 
			
		||||
           install log nobuild nocheck nocolor noconfirm nodeps noextract noprogressbar
 | 
			
		||||
           nosign pkg repackage rmdeps sign skipinteg source syncdeps'
 | 
			
		||||
    opts=('allsource asdeps asroot check clean config force geninteg help holdver ignorearch
 | 
			
		||||
           install key log needed nobuild nocheck nocolor noconfirm nodeps noextract
 | 
			
		||||
           noprogressbar nosign pkg repackage rmdeps sign skipchecksums skipinteg
 | 
			
		||||
           skippgpcheck source syncdeps verifysource version'
 | 
			
		||||
          'A L R S c d e f g h i m o p r s')
 | 
			
		||||
    _arch_ptr2comp opts
 | 
			
		||||
  fi
 | 
			
		||||
@@ -59,9 +88,9 @@ _makepkg() {
 | 
			
		||||
_pacman_pkg() {
 | 
			
		||||
  _arch_compgen "$(
 | 
			
		||||
    if [[ $2 ]]; then
 | 
			
		||||
      \pacman -$1 | \cut -d' ' -f1 | \sort -u
 | 
			
		||||
      \pacman -$1 2>/dev/null | \cut -d' ' -f1 | \sort -u
 | 
			
		||||
    else
 | 
			
		||||
      \pacman -$1
 | 
			
		||||
      \pacman -$1 2>/dev/null
 | 
			
		||||
    fi
 | 
			
		||||
  )"
 | 
			
		||||
}
 | 
			
		||||
@@ -76,9 +105,9 @@ _pacman() {
 | 
			
		||||
  remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c n p s u')
 | 
			
		||||
  sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup
 | 
			
		||||
         info list needed nodeps print refresh recursive search sysupgrade'
 | 
			
		||||
        'c f g i l p s u w y')
 | 
			
		||||
  upgrade=('asdeps asexplicit force needed nodeps print recursive' 'f p')
 | 
			
		||||
  common=('arch cachedir config dbpath debug help logfile noconfirm
 | 
			
		||||
        'c g i l p s u w y')
 | 
			
		||||
  upgrade=('asdeps asexplicit force needed nodeps print recursive' 'p')
 | 
			
		||||
  common=('arch cachedir color config dbpath debug help logfile noconfirm
 | 
			
		||||
           noprogressbar noscriptlet quiet root verbose' 'b d h q r v')
 | 
			
		||||
  core=('database help query remove sync upgrade version' 'D Q R S U V h')
 | 
			
		||||
 | 
			
		||||
@@ -89,7 +118,7 @@ _pacman() {
 | 
			
		||||
  if [[ $? != 0 ]]; then
 | 
			
		||||
    _arch_ptr2comp core
 | 
			
		||||
  elif [[ ! $prev =~ ^-\w*[Vbhr] &&
 | 
			
		||||
    ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]]
 | 
			
		||||
    ! $prev = --@(cachedir|color|config|dbpath|help|logfile|root|version) ]]
 | 
			
		||||
  then
 | 
			
		||||
    [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common ||
 | 
			
		||||
      case ${o% *} in
 | 
			
		||||
@@ -111,18 +140,11 @@ _pacman() {
 | 
			
		||||
  true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [[ $(type -t compopt) = "builtin" ]]; then
 | 
			
		||||
  _pacman_file() {
 | 
			
		||||
    compopt -o filenames; _filedir 'pkg.tar.*'
 | 
			
		||||
  }
 | 
			
		||||
  complete -F _pacman -o default pacman
 | 
			
		||||
else
 | 
			
		||||
  _pacman_file() {
 | 
			
		||||
    _filedir 'pkg.tar.*'
 | 
			
		||||
  }
 | 
			
		||||
  complete -F _pacman -o filenames -o default pacman
 | 
			
		||||
fi
 | 
			
		||||
_pacman_file() {
 | 
			
		||||
  compopt -o filenames; _filedir 'pkg.tar*'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
complete -F _pacman -o default pacman
 | 
			
		||||
complete -F _makepkg -o default makepkg
 | 
			
		||||
complete -F _pacman_key -o default pacman-key
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										44
									
								
								contrib/checkupdates.sh.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								contrib/checkupdates.sh.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
#
 | 
			
		||||
#   checkupdates: Safely print a list of pending updates.
 | 
			
		||||
#
 | 
			
		||||
#   Copyright (c) 2013 Kyle Keen <keenerd@gmail.com>
 | 
			
		||||
#
 | 
			
		||||
#   This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#   it under the terms of the GNU General Public License as published by
 | 
			
		||||
#   the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#   (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#   This program is distributed in the hope that it will be useful,
 | 
			
		||||
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#   GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#   You should have received a copy of the GNU General Public License
 | 
			
		||||
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
if (( $# > 0 )); then
 | 
			
		||||
	echo "checkupdate: Safely print a list of pending updates."
 | 
			
		||||
	echo "Use: checkupdates"
 | 
			
		||||
	echo "Export the 'CHECKUPDATE_DB' variable to change the path of the temporary database."
 | 
			
		||||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ -z $CHECKUPDATE_DB ]]; then
 | 
			
		||||
	CHECKUPDATE_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
trap 'rm -f $CHECKUPDATE_DB/db.lck' INT TERM EXIT
 | 
			
		||||
 | 
			
		||||
DBPath="${DBPath:-@localstatedir@/lib/pacman/}"
 | 
			
		||||
eval $(awk -F' *= *' '$1 ~ /DBPath/ { print $1 "=" $2 }' /etc/pacman.conf)
 | 
			
		||||
 | 
			
		||||
mkdir -p "$CHECKUPDATE_DB"
 | 
			
		||||
ln -s "${DBPath}/local" "$CHECKUPDATE_DB" &> /dev/null
 | 
			
		||||
fakeroot pacman -Sy --dbpath "$CHECKUPDATE_DB" &> /dev/null
 | 
			
		||||
pacman -Qqu --dbpath "$CHECKUPDATE_DB" 2> /dev/null
 | 
			
		||||
 | 
			
		||||
exit 0
 | 
			
		||||
 | 
			
		||||
# vim: set ts=2 sw=2 noet:
 | 
			
		||||
							
								
								
									
										179
									
								
								contrib/paccache.in → contrib/paccache.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										179
									
								
								contrib/paccache.in → contrib/paccache.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -20,19 +20,17 @@
 | 
			
		||||
 | 
			
		||||
shopt -s extglob
 | 
			
		||||
 | 
			
		||||
declare -r myname='paccache'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
declare -a candidates=() cmdopts=() whitelist=() blacklist=()
 | 
			
		||||
declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
 | 
			
		||||
declare    cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch=
 | 
			
		||||
 | 
			
		||||
msg() {
 | 
			
		||||
	local mesg=$1; shift
 | 
			
		||||
	printf "==> $mesg\n" "$@"
 | 
			
		||||
} >&2
 | 
			
		||||
USE_COLOR='y'
 | 
			
		||||
 | 
			
		||||
error() {
 | 
			
		||||
	local mesg=$1; shift
 | 
			
		||||
	printf "==> ERROR: $mesg\n" "$@"
 | 
			
		||||
} >&2
 | 
			
		||||
m4_include(../scripts/library/output_format.sh)
 | 
			
		||||
m4_include(../scripts/library/parseopts.sh)
 | 
			
		||||
 | 
			
		||||
die() {
 | 
			
		||||
	error "$@"
 | 
			
		||||
@@ -103,29 +101,10 @@ pkgfilter() {
 | 
			
		||||
	}' "${@:3}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_to_human() {
 | 
			
		||||
	awk -v size="$1" '
 | 
			
		||||
	BEGIN {
 | 
			
		||||
		suffix[1] = "B"
 | 
			
		||||
		suffix[2] = "KiB"
 | 
			
		||||
		suffix[3] = "MiB"
 | 
			
		||||
		suffix[4] = "GiB"
 | 
			
		||||
		suffix[5] = "TiB"
 | 
			
		||||
		count = 1
 | 
			
		||||
 | 
			
		||||
		while (size > 1024) {
 | 
			
		||||
			size /= 1024
 | 
			
		||||
			count++
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sizestr = sprintf("%.2f", size)
 | 
			
		||||
		sub(/\.?0+$/, "", sizestr)
 | 
			
		||||
		printf("%s %s", sizestr, suffix[count])
 | 
			
		||||
	}'
 | 
			
		||||
}
 | 
			
		||||
m4_include(../scripts/library/size_to_human.sh)
 | 
			
		||||
 | 
			
		||||
runcmd() {
 | 
			
		||||
	if (( needsroot )); then
 | 
			
		||||
	if (( needsroot && EUID != 0 )); then
 | 
			
		||||
		msg "Privilege escalation required"
 | 
			
		||||
		if sudo -v &>/dev/null && sudo -l &>/dev/null; then
 | 
			
		||||
			sudo "$@"
 | 
			
		||||
@@ -146,7 +125,7 @@ summarize() {
 | 
			
		||||
	if (( delete )); then
 | 
			
		||||
		printf -v output 'finished: %d packages removed' "$filecount"
 | 
			
		||||
	elif (( move )); then
 | 
			
		||||
		printf -v output "finished: %d packages moved to \`%s'" "$filecount" "$movedir"
 | 
			
		||||
		printf -v output "finished: %d packages moved to '%s'" "$filecount" "$movedir"
 | 
			
		||||
	elif (( dryrun )); then
 | 
			
		||||
		if (( verbose )); then
 | 
			
		||||
			msg "Candidate packages:"
 | 
			
		||||
@@ -163,7 +142,7 @@ summarize() {
 | 
			
		||||
				else
 | 
			
		||||
					printf "%s$delim" "$pkg"
 | 
			
		||||
				fi
 | 
			
		||||
			done < <(printf '%s\n' "$@" | pacsort)
 | 
			
		||||
			done < <(printf '%s\n' "$@" | pacsort --files)
 | 
			
		||||
		fi
 | 
			
		||||
		printf -v output 'finished dry run: %d candidates' "$filecount"
 | 
			
		||||
	fi
 | 
			
		||||
@@ -174,70 +153,106 @@ summarize() {
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	cat <<EOF
 | 
			
		||||
usage: ${0##*/} <operation> [options] [targets...]
 | 
			
		||||
usage: $myname <operation> [options] [targets...]
 | 
			
		||||
 | 
			
		||||
${0##*/} is a flexible pacman cache cleaning utility, which has numerous
 | 
			
		||||
$myname is a flexible pacman cache cleaning utility, which has numerous
 | 
			
		||||
options to help control how much, and what, is deleted from any directory
 | 
			
		||||
containing pacman package tarballs.
 | 
			
		||||
 | 
			
		||||
  Operations:
 | 
			
		||||
    -d               perform a dry run, only finding candidate packages.
 | 
			
		||||
    -m  <movedir>    move candidate packages to 'movedir'.
 | 
			
		||||
    -r               remove candidate packages.
 | 
			
		||||
    -d, --dryrun            perform a dry run, only finding candidate packages.
 | 
			
		||||
    -m, --move <dir>        move candidate packages to 'movedir'.
 | 
			
		||||
    -r, --remove            remove candidate packages.
 | 
			
		||||
 | 
			
		||||
  Options:
 | 
			
		||||
    -a  <arch>       scan for 'arch' (default: all architectures).
 | 
			
		||||
    -c  <cachedir>   scan 'cachedir' for packages (default: @localstatedir@/cache/pacman/pkg).
 | 
			
		||||
    -f               apply force to mv(1) and rm(1) operations.
 | 
			
		||||
    -h               display this help message.
 | 
			
		||||
    -i  <pkgs>       ignore 'pkgs', which is a comma separated. Alternatively,
 | 
			
		||||
                     specify '-' to read package names from stdin, newline delimited.
 | 
			
		||||
    -k  <num>        keep 'num' of each package in 'cachedir' (default: 3).
 | 
			
		||||
    -u               target uninstalled packages.
 | 
			
		||||
    -v               increase verbosity. specify up to 3 times.
 | 
			
		||||
    -z               use null delimiters for candidate names (only with -v and -vv)
 | 
			
		||||
    -a, --arch <arch>       scan for 'arch' (default: all architectures).
 | 
			
		||||
    -c, --cachedir <dir>    scan 'cachedir' for packages (default: @localstatedir@/cache/pacman/pkg).
 | 
			
		||||
    -f, --force             apply force to mv(1) and rm(1) operations.
 | 
			
		||||
    -h, --help              display this help message and exit.
 | 
			
		||||
    -i, --ignore <pkgs>     ignore 'pkgs', comma separated. Alternatively, specify '-' to
 | 
			
		||||
                              read package names from stdin, newline delimited.
 | 
			
		||||
    -k, --keep <num>        keep 'num' of each package in 'cachedir' (default: 3).
 | 
			
		||||
    --nocolor               remove color from output.
 | 
			
		||||
    -u, --uninstalled       target uninstalled packages.
 | 
			
		||||
    -v, --verbose           increase verbosity. specify up to 3 times.
 | 
			
		||||
    -z, --null              use null delimiters for candidate names (only with -v and -vv)
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (( ! UID )); then
 | 
			
		||||
	error "Do not run this script as root. You will be prompted for privilege escalation."
 | 
			
		||||
	exit 42
 | 
			
		||||
fi
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
while getopts ':a:c:dfhi:k:m:rsuvz' opt; do
 | 
			
		||||
	case $opt in
 | 
			
		||||
		a) scanarch=$OPTARG ;;
 | 
			
		||||
		c) cachedir=$OPTARG ;;
 | 
			
		||||
		d) dryrun=1 ;;
 | 
			
		||||
		f) cmdopts=(-f) ;;
 | 
			
		||||
		h) usage
 | 
			
		||||
OPT_SHORT=':a:c:dfhi:k:m:rsuVvz'
 | 
			
		||||
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
 | 
			
		||||
          'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null')
 | 
			
		||||
 | 
			
		||||
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
set -- "${OPTRET[@]}"
 | 
			
		||||
unset OPT_SHORT OPT_LONG OPTRET
 | 
			
		||||
 | 
			
		||||
while :; do
 | 
			
		||||
	case $1 in
 | 
			
		||||
		-a|--arch)
 | 
			
		||||
			scanarch=$2
 | 
			
		||||
			shift ;;
 | 
			
		||||
		-c|--cachedir)
 | 
			
		||||
			cachedir=$2
 | 
			
		||||
			shift ;;
 | 
			
		||||
		-d|--dryrun)
 | 
			
		||||
			dryrun=1 ;;
 | 
			
		||||
		-f|--force)
 | 
			
		||||
			cmdopts=(-f) ;;
 | 
			
		||||
		-h|--help)
 | 
			
		||||
			usage
 | 
			
		||||
			exit 0 ;;
 | 
			
		||||
		i) if [[ $OPTARG = '-' ]]; then
 | 
			
		||||
				 [[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign
 | 
			
		||||
			 else
 | 
			
		||||
				 IFS=',' read -r -a ign <<< "$OPTARG"
 | 
			
		||||
			 fi
 | 
			
		||||
			 blacklist+=("${ign[@]}")
 | 
			
		||||
			unset i ign ;;
 | 
			
		||||
		k) keep=$OPTARG
 | 
			
		||||
		-i|--ignore)
 | 
			
		||||
			if [[ $2 = '-' ]]; then
 | 
			
		||||
				[[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign
 | 
			
		||||
			else
 | 
			
		||||
				IFS=',' read -r -a ign <<< "$2"
 | 
			
		||||
			fi
 | 
			
		||||
			blacklist+=("${ign[@]}")
 | 
			
		||||
			unset i ign
 | 
			
		||||
			shift ;;
 | 
			
		||||
		-k|--keep)
 | 
			
		||||
			keep=$2
 | 
			
		||||
			if [[ -z $keep || -n ${keep//[0-9]/} ]]; then
 | 
			
		||||
				die 'argument to option -k must be a non-negative integer'
 | 
			
		||||
			else
 | 
			
		||||
				keep=$(( 10#$keep ))
 | 
			
		||||
			fi ;;
 | 
			
		||||
		m) move=1 movedir=$OPTARG ;;
 | 
			
		||||
		r) delete=1 ;;
 | 
			
		||||
		u) IFS=$'\n' read -r -d '' -a ign < <(pacman -Qq)
 | 
			
		||||
			 blacklist+=("${ign[@]}")
 | 
			
		||||
			 unset ign ;;
 | 
			
		||||
		v) (( ++verbose )) ;;
 | 
			
		||||
		z) delim='\0' ;;
 | 
			
		||||
		:) die "option '--%s' requires an argument" "$OPTARG" ;;
 | 
			
		||||
		?) die "invalid option -- '%s'" "$OPTARG" ;;
 | 
			
		||||
			fi
 | 
			
		||||
			shift ;;
 | 
			
		||||
		--nocolor)
 | 
			
		||||
			USE_COLOR='n' ;;
 | 
			
		||||
		-m|--move)
 | 
			
		||||
			move=1 movedir=$2
 | 
			
		||||
			shift ;;
 | 
			
		||||
		-r|--remove)
 | 
			
		||||
			delete=1 ;;
 | 
			
		||||
		-u|--uninstalled)
 | 
			
		||||
			IFS=$'\n' read -r -d '' -a ign < <(pacman -Qq)
 | 
			
		||||
			blacklist+=("${ign[@]}")
 | 
			
		||||
			unset ign ;;
 | 
			
		||||
		-V|--version)
 | 
			
		||||
			version
 | 
			
		||||
			exit 0 ;;
 | 
			
		||||
		-v|--verbose)
 | 
			
		||||
			(( ++verbose )) ;;
 | 
			
		||||
		-z|--null)
 | 
			
		||||
			delim='\0' ;;
 | 
			
		||||
		--)
 | 
			
		||||
			shift
 | 
			
		||||
			break 2 ;;
 | 
			
		||||
	esac
 | 
			
		||||
	shift
 | 
			
		||||
done
 | 
			
		||||
shift $(( OPTIND - 1 ))
 | 
			
		||||
 | 
			
		||||
m4_include(../scripts/library/term_colors.sh)
 | 
			
		||||
 | 
			
		||||
# remaining args are a whitelist
 | 
			
		||||
whitelist=("$@")
 | 
			
		||||
@@ -249,10 +264,10 @@ case $(( dryrun+delete+move )) in
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
[[ -d $cachedir ]] ||
 | 
			
		||||
	die "cachedir \`%s' does not exist or is not a directory" "$cachedir"
 | 
			
		||||
	die "cachedir '%s' does not exist or is not a directory" "$cachedir"
 | 
			
		||||
 | 
			
		||||
[[ $movedir && ! -d $movedir ]] &&
 | 
			
		||||
	die "move-to directory \`%s' does not exist or is not a directory" "$movedir"
 | 
			
		||||
	die "move-to directory '%s' does not exist or is not a directory" "$movedir"
 | 
			
		||||
 | 
			
		||||
if (( move || delete )); then
 | 
			
		||||
	# make it an absolute path since we're about to chdir
 | 
			
		||||
@@ -261,12 +276,12 @@ if (( move || delete )); then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# unlikely that this will fail, but better make sure
 | 
			
		||||
cd "$cachedir" || die "failed to chdir to \`%s'" "$cachedir"
 | 
			
		||||
cd "$cachedir" >/dev/null || die "failed to chdir to '%s'" "$cachedir"
 | 
			
		||||
 | 
			
		||||
# note that these results are returned in an arbitrary order from awk, but
 | 
			
		||||
# they'll be resorted (in summarize) iff we have a verbosity level set.
 | 
			
		||||
IFS=$'\n' read -r -d '' -a candidates < \
 | 
			
		||||
	<(printf '%s\n' *.pkg.tar?(.+([^.])) | pacsort |
 | 
			
		||||
	<(printf '%s\n' *.pkg.tar?(.+([^.])) | pacsort --files |
 | 
			
		||||
		pkgfilter "$keep" "$scanarch" \
 | 
			
		||||
			"${#whitelist[*]}" "${whitelist[@]}" \
 | 
			
		||||
			"${#blacklist[*]}" "${blacklist[@]}")
 | 
			
		||||
@@ -293,9 +308,9 @@ totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }
 | 
			
		||||
# crush. kill. destroy.
 | 
			
		||||
(( verbose )) && cmdopts+=(-v)
 | 
			
		||||
if (( delete )); then
 | 
			
		||||
	runcmd rm "${cmdopts[@]}" "${candidates[@]}"
 | 
			
		||||
	printf '%s\0' "${candidates[@]}" | runcmd xargs -0 rm "${cmdopts[@]}"
 | 
			
		||||
elif (( move )); then
 | 
			
		||||
	runcmd mv "${cmdopts[@]}" "${candidates[@]}" "$movedir"
 | 
			
		||||
	printf '%s\0' "${candidates[@]}" | runcmd xargs -0 mv "${cmdopts[@]}" -t "$movedir"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
summarize "$pkgcount" "${candidates[@]}"
 | 
			
		||||
							
								
								
									
										54
									
								
								contrib/pacdiff.in → contrib/pacdiff.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										54
									
								
								contrib/pacdiff.in → contrib/pacdiff.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -2,6 +2,7 @@
 | 
			
		||||
#   pacdiff : a simple pacnew/pacorig/pacsave updater
 | 
			
		||||
#
 | 
			
		||||
#   Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
 | 
			
		||||
#   Copyright (c) 2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
#
 | 
			
		||||
#   This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#   it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -17,17 +18,31 @@
 | 
			
		||||
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
declare -r myname='pacdiff'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
diffprog=${DIFFPROG:-vimdiff}
 | 
			
		||||
diffsearchpath=${DIFFSEARCHPATH:-/etc}
 | 
			
		||||
locate=0
 | 
			
		||||
USE_COLOR='y'
 | 
			
		||||
 | 
			
		||||
m4_include(../scripts/library/output_format.sh)
 | 
			
		||||
 | 
			
		||||
m4_include(../scripts/library/term_colors.sh)
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	echo "pacdiff : a simple pacnew/pacorig/pacsave updater"
 | 
			
		||||
	echo "Usage : pacdiff [-l]"
 | 
			
		||||
	echo "  -l/--locate makes pacdiff use locate rather than find"
 | 
			
		||||
	echo "$myname : a simple pacnew/pacorig/pacsave updater"
 | 
			
		||||
	echo "Usage : $myname [-l]"
 | 
			
		||||
	echo "  -l/--locate makes $myname use locate rather than find"
 | 
			
		||||
	echo "  DIFFPROG variable allows to override the default vimdiff"
 | 
			
		||||
	echo "  DIFFSEARCHPATH allows to override the default /etc path"
 | 
			
		||||
	echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff"
 | 
			
		||||
	echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" $myname"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
 | 
			
		||||
	echo 'Copyright (C) 2013 Pacman Development Team <pacman-dev@archlinux.org>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cmd() {
 | 
			
		||||
@@ -42,34 +57,41 @@ if [ $# -gt 0 ]; then
 | 
			
		||||
	case $1 in
 | 
			
		||||
		-l|--locate)
 | 
			
		||||
		locate=1;;
 | 
			
		||||
		*)
 | 
			
		||||
		-V|--version)
 | 
			
		||||
		version; exit 0;;
 | 
			
		||||
		-h|--help)
 | 
			
		||||
		usage; exit 0;;
 | 
			
		||||
		*)
 | 
			
		||||
		usage; exit 1;;
 | 
			
		||||
	esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# see http://mywiki.wooledge.org/BashFAQ/020
 | 
			
		||||
while IFS= read -u 3 -r -d '' pacfile; do
 | 
			
		||||
	file="${pacfile%.pac*}"
 | 
			
		||||
	echo "File: $file"
 | 
			
		||||
	file_type="pac${pacfile##*.pac}"
 | 
			
		||||
 | 
			
		||||
	msg "%s file found for %s" "$file_type" "$file"
 | 
			
		||||
	if [ ! -f "$file" ]; then
 | 
			
		||||
		echo "  $file does not exist"
 | 
			
		||||
		rm -i "$pacfile"
 | 
			
		||||
		warning "$file does not exist"
 | 
			
		||||
		rm -iv "$pacfile"
 | 
			
		||||
		continue
 | 
			
		||||
	fi
 | 
			
		||||
	check="$(cmp "$pacfile" "$file")"
 | 
			
		||||
	if [ -z "${check}" ]; then
 | 
			
		||||
		echo "  Files are identical, removing..."
 | 
			
		||||
		rm "$pacfile"
 | 
			
		||||
 | 
			
		||||
	if cmp -s "$pacfile" "$file"; then
 | 
			
		||||
		msg2 "Files are identical, removing..."
 | 
			
		||||
		rm -v "$pacfile"
 | 
			
		||||
	else
 | 
			
		||||
		echo -n "  File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] "
 | 
			
		||||
		ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s: [v/s/r/o] " "$file_type" "$file_type"
 | 
			
		||||
		while read c; do
 | 
			
		||||
			case $c in
 | 
			
		||||
				r|R) rm "$pacfile"; break ;;
 | 
			
		||||
				r|R) rm -v "$pacfile"; break ;;
 | 
			
		||||
				o|O) mv -v "$pacfile" "$file"; break ;;
 | 
			
		||||
				v|V)
 | 
			
		||||
				$diffprog "$pacfile" "$file"
 | 
			
		||||
				rm -i "$pacfile"; break ;;
 | 
			
		||||
				rm -iv "$pacfile"; break ;;
 | 
			
		||||
				s|S) break ;;
 | 
			
		||||
				*) echo -n "  Invalid answer. Try again: [v/s/r] "; continue ;;
 | 
			
		||||
				*) ask "Invalid answer. Try again: [v/s/r/o] "; continue ;;
 | 
			
		||||
			esac
 | 
			
		||||
		done
 | 
			
		||||
	fi
 | 
			
		||||
							
								
								
									
										27
									
								
								contrib/paclist.in → contrib/paclist.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										27
									
								
								contrib/paclist.in → contrib/paclist.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -17,6 +17,9 @@
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
declare -r myname='paclist'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
export TEXTDOMAIN='pacman'
 | 
			
		||||
export TEXTDOMAINDIR='/usr/share/locale'
 | 
			
		||||
 | 
			
		||||
@@ -27,13 +30,31 @@ if ! type gettext &>/dev/null; then
 | 
			
		||||
	}
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	printf '%s - List all packages installed from a given repo\n' "$myname"
 | 
			
		||||
	printf 'Usage:   %s <repo>\n' "$myname"
 | 
			
		||||
	printf 'Example: %s testing\n' "$myname"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>'
 | 
			
		||||
	echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [[ -z $1 ]]; then
 | 
			
		||||
	printf '%s - List all packages installed from a given repo\n' "${0##*/}"
 | 
			
		||||
	printf 'Usage:   %s <repo>\n' "${0##*/}"
 | 
			
		||||
	printf 'Example: %s testing\n' "${0##*/}"
 | 
			
		||||
	usage
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ $1 = -@(h|-help) ]]; then
 | 
			
		||||
	usage
 | 
			
		||||
	exit 0
 | 
			
		||||
elif [[ $1 = -@(V|-version) ]]; then
 | 
			
		||||
	version
 | 
			
		||||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
printf -v installed '[%s]' "$(gettext installed)"
 | 
			
		||||
pacman -Sl $1 | awk -v i="$installed" '$NF == i { print $2,$3 }'
 | 
			
		||||
 | 
			
		||||
@@ -17,15 +17,30 @@
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
declare -r myname='paclog-pkglist'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
export TEXTDOMAIN='pacman'
 | 
			
		||||
export TEXTDOMAINDIR='/usr/share/locale'
 | 
			
		||||
declare logfile=${1:-@localstatedir@/log/pacman.log}
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	printf 'usage:   %s [pacman log]\n' "$myname"
 | 
			
		||||
	printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname"
 | 
			
		||||
	printf '\ndefaults to: @localstatedir@/log/pacman.log\n'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2011 Dave Reisner <dave@archlinux.org>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [[ $1 ]]; then
 | 
			
		||||
	if [[ $1 = -@(h|-help) ]]; then
 | 
			
		||||
		printf 'usage:   %s [pacman log]\n' "${0##*/}"
 | 
			
		||||
		printf 'example: %s @localstatedir@/log/pacman.log\n' "${0##*/}"
 | 
			
		||||
		printf '\ndefaults to: @localstatedir@/log/pacman.log\n'
 | 
			
		||||
		usage
 | 
			
		||||
		exit 0
 | 
			
		||||
	elif [[ $1 = -@(V|-version) ]]; then
 | 
			
		||||
		version
 | 
			
		||||
		exit 0
 | 
			
		||||
	elif [[ ! -e $logfile ]]; then
 | 
			
		||||
		printf $"target not found: %s\n" "$1"
 | 
			
		||||
@@ -35,25 +50,35 @@ fi
 | 
			
		||||
 | 
			
		||||
<"$logfile" awk '
 | 
			
		||||
{
 | 
			
		||||
	action  = $3
 | 
			
		||||
	pkgname = $4
 | 
			
		||||
	pkgver  = $5
 | 
			
		||||
	upgver  = $7
 | 
			
		||||
	if ($3 ~ /^\[.*\]$/) {
 | 
			
		||||
		# new style with caller name
 | 
			
		||||
		action  = $4
 | 
			
		||||
		pkgname = $5
 | 
			
		||||
		pkgver  = $6
 | 
			
		||||
		upgver  = $8
 | 
			
		||||
		nfields = NF
 | 
			
		||||
	} else {
 | 
			
		||||
		action  = $3
 | 
			
		||||
		pkgname = $4
 | 
			
		||||
		pkgver  = $5
 | 
			
		||||
		upgver  = $7
 | 
			
		||||
		nfields = (NF + 1)    # compensate for missing caller field
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NF == 5 && action == "installed" {
 | 
			
		||||
nfields == 6 && action == "installed" {
 | 
			
		||||
	gsub(/[()]/, "", pkgver)
 | 
			
		||||
	pkg[pkgname] = pkgver
 | 
			
		||||
	next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NF == 7 && action == "upgraded" {
 | 
			
		||||
nfields == 8 && (action == "upgraded" || action == "downgraded") {
 | 
			
		||||
	sub(/\)/, "", upgver)
 | 
			
		||||
	pkg[pkgname] = upgver
 | 
			
		||||
	next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NF == 5 && action == "removed" {
 | 
			
		||||
nfields == 6 && action == "removed" {
 | 
			
		||||
	pkg[pkgname] = -1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								contrib/pacscripts.in → contrib/pacscripts.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										18
									
								
								contrib/pacscripts.in → contrib/pacscripts.sh.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -24,8 +24,8 @@
 | 
			
		||||
set -o nounset
 | 
			
		||||
set -o errexit
 | 
			
		||||
 | 
			
		||||
progname=$(basename $0)
 | 
			
		||||
progver="0.4"
 | 
			
		||||
declare -r myname='pacscripts'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
conf="@sysconfdir@/pacman.conf"
 | 
			
		||||
 | 
			
		||||
@@ -47,14 +47,20 @@ error() {
 | 
			
		||||
usage() {
 | 
			
		||||
	echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts"
 | 
			
		||||
	echo "of a given package."
 | 
			
		||||
	echo "Usage: $progname pkgname|pkgfile"
 | 
			
		||||
	echo "Usage: $myname pkgname|pkgfile"
 | 
			
		||||
	echo
 | 
			
		||||
	echo " OPTIONS:"
 | 
			
		||||
	echo "  -h, --help                 Print this help message"
 | 
			
		||||
	echo "  -v, --version              Print program name and version"
 | 
			
		||||
	echo
 | 
			
		||||
	echo "Example: $progname gconf-editor"
 | 
			
		||||
	echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
 | 
			
		||||
	echo "Example: $myname gconf-editor"
 | 
			
		||||
	echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>'
 | 
			
		||||
	echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
spacman() {
 | 
			
		||||
@@ -127,6 +133,6 @@ fi
 | 
			
		||||
 | 
			
		||||
case "$1" in
 | 
			
		||||
	--help|-h) usage; exit 0 ;;
 | 
			
		||||
	--version|-v) echo "$progname version $progver"; exit 0 ;;
 | 
			
		||||
	--version|-V) version; exit 0 ;;
 | 
			
		||||
	*) print_scriptlet $1 ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										26
									
								
								contrib/pacsearch.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										26
									
								
								contrib/pacsearch.in
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -24,22 +24,32 @@
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
my $progname = "pacsearch";
 | 
			
		||||
my $version = "2.0";
 | 
			
		||||
my $myname = 'pacsearch';
 | 
			
		||||
my $myver = '@PACKAGE_VERSION@';
 | 
			
		||||
 | 
			
		||||
sub usage {
 | 
			
		||||
	print "$myname - Add color and install information to a pacman -Ss search\n";
 | 
			
		||||
	print "Usage:   $myname <pattern>\n";
 | 
			
		||||
	print "Example: $myname ^gnome\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub version {
 | 
			
		||||
	printf "%s %s\n", $myname, $myver;
 | 
			
		||||
	print "Copyright (C) 2008-2011 Dan McGee <dan\@archlinux.org>\n\n";
 | 
			
		||||
	print "Based off original shell script version:\n";
 | 
			
		||||
	print "Copyright (C) 2006-2007 Dan McGee <dan\@archlinux.org>\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
 | 
			
		||||
	print "$progname - Add color and install information to a pacman -Ss search\n";
 | 
			
		||||
	print "Usage:   $progname <pattern>\n";
 | 
			
		||||
	print "Example: $progname ^gnome\n";
 | 
			
		||||
	usage;
 | 
			
		||||
	if ($#ARGV lt 0) {
 | 
			
		||||
		exit 1;
 | 
			
		||||
	}
 | 
			
		||||
	exit 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
 | 
			
		||||
	print "$progname version $version\n";
 | 
			
		||||
	print "Copyright (C) 2006-2011 Dan McGee\n";
 | 
			
		||||
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") {
 | 
			
		||||
	version;
 | 
			
		||||
	exit 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										64
									
								
								contrib/pacsysclean.sh.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								contrib/pacsysclean.sh.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# pacsysclean - Sort installed packages by increasing installed size. Useful for system clean-up.
 | 
			
		||||
 | 
			
		||||
declare -r myname='pacsysclean'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
PACMAN_OPTS=
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	echo "$myname - Sort installed packages by increasing installed size."
 | 
			
		||||
	echo
 | 
			
		||||
	echo "Usage: $myname [options]"
 | 
			
		||||
	echo
 | 
			
		||||
	echo "Options:"
 | 
			
		||||
	echo "  -o <options>     Specify custom pacman query options (e.g., dt)"
 | 
			
		||||
	echo "  -h, --help       Show this help message and exit"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2011 Eric Bélanger <snowmaniscool@gmail.com>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if [ -n "$1" ]; then
 | 
			
		||||
	case "$1" in
 | 
			
		||||
		-o) PACMAN_OPTS="${2}" ;;
 | 
			
		||||
		-h|--help) usage; exit 0 ;;
 | 
			
		||||
		-V|--version) version; exit 0 ;;
 | 
			
		||||
		*) usage; exit 1 ;;
 | 
			
		||||
	esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
IFS=$'\n'
 | 
			
		||||
name="^Name.*: (.*)$"
 | 
			
		||||
size="^Installed Size.*: (.*) KiB$"
 | 
			
		||||
 | 
			
		||||
[[ $PACMAN_OPTS && $PACMAN_OPTS != -* ]] && PACMAN_OPTS="-$PACMAN_OPTS"
 | 
			
		||||
 | 
			
		||||
for line in $(LANG=C pacman -Qi $PACMAN_OPTS); do
 | 
			
		||||
	if [[ $line =~ $name ]]; then
 | 
			
		||||
		printf "%s\t" ${BASH_REMATCH[1]}
 | 
			
		||||
	elif [[ $line =~ $size ]]; then
 | 
			
		||||
		printf "%s\n" ${BASH_REMATCH[1]}
 | 
			
		||||
	fi
 | 
			
		||||
done | sort -g -k2 | awk '
 | 
			
		||||
BEGIN {
 | 
			
		||||
	split("KiB MiB GiB TiB PiB EiB ZiB YiB", suffix)
 | 
			
		||||
}
 | 
			
		||||
function format_size(size) {
 | 
			
		||||
	count = 1
 | 
			
		||||
	while (size + 0 > 1024) {
 | 
			
		||||
				 size /= 1024
 | 
			
		||||
				 count++
 | 
			
		||||
	}
 | 
			
		||||
	sizestr = sprintf("%.2f %s", size, suffix[count])
 | 
			
		||||
	return sizestr
 | 
			
		||||
}
 | 
			
		||||
{
 | 
			
		||||
	printf("%s\t%s\n", format_size($2), $1);
 | 
			
		||||
}'
 | 
			
		||||
 | 
			
		||||
# vim: set ts=2 sw=2 noet:
 | 
			
		||||
							
								
								
									
										93
									
								
								contrib/updpkgsums.sh.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								contrib/updpkgsums.sh.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
#
 | 
			
		||||
# updpkgsums - update source checksums in-place in PKGBUILDs
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2012-2013 Dave Reisner <dreisner@archlinux.org>
 | 
			
		||||
#
 | 
			
		||||
# This program is free software; you can redistribute it and/or
 | 
			
		||||
# modify it under the terms of the GNU General Public License
 | 
			
		||||
# as published by the Free Software Foundation; either version 2
 | 
			
		||||
# of the License, or (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# This program is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
# GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
shopt -s extglob
 | 
			
		||||
 | 
			
		||||
declare -r myname='updpkgsums'
 | 
			
		||||
declare -r myver='@PACKAGE_VERSION@'
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
	printf 'usage: %s [buildfile]\n\n' "$myname"
 | 
			
		||||
	printf '    -h, --help        display this help message and exit\n'
 | 
			
		||||
	printf '    -V, --version     display version information and exit\n\n'
 | 
			
		||||
	printf '%s will perform an in place update the checksums in the\n' "$myname"
 | 
			
		||||
	printf 'path specified by [buildfile], defaulting to PKGBUILD in the current\n'
 | 
			
		||||
	printf 'working directory.\n'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
version() {
 | 
			
		||||
	printf "%s %s\n" "$myname" "$myver"
 | 
			
		||||
	echo 'Copyright (C) 2012-2013 Dave Reisner <dreisner@archlinux.org>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
case $1 in
 | 
			
		||||
	-h|--help) usage; exit ;;
 | 
			
		||||
	-V|--version) version; exit ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
buildfile=${1:-PKGBUILD}
 | 
			
		||||
if [[ ! -f $buildfile ]]; then
 | 
			
		||||
	printf '==> ERROR: %s not found or is not a file\n' "$buildfile"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Resolve any symlinks to avoid replacing the symlink with a file. But, we
 | 
			
		||||
# have to do this portably -- readlink's flags are inconsistent across OSes.
 | 
			
		||||
while [[ -L $buildfile ]]; do
 | 
			
		||||
	buildfile=$(readlink "$buildfile")
 | 
			
		||||
	if [[ $buildfile = */* ]]; then
 | 
			
		||||
		cd "${buildfile%/*}"
 | 
			
		||||
		buildfile=${buildfile##*/}
 | 
			
		||||
	fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# cd into the directory with the build file. This avoids creating random src/
 | 
			
		||||
# directories scattered about the filesystem, and avoids cases where we might
 | 
			
		||||
# not be able to write in the $PWD.
 | 
			
		||||
if [[ $buildfile = */* ]]; then
 | 
			
		||||
	cd "${buildfile%/*}"
 | 
			
		||||
	buildfile=${buildfile##*/}
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Check $PWD/ for permission to unlink the $buildfile and write a new one
 | 
			
		||||
if [[ ! -w . ]]; then
 | 
			
		||||
	printf $'==> ERROR: No write permission in `%s\'\n' "$PWD"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
	# Generate the new sums and try to unlink the file before writing stdin back
 | 
			
		||||
	# into it. This final precaution shouldn't fail based on the previous checks,
 | 
			
		||||
	# but it's better to be extra careful before unlinking files.
 | 
			
		||||
	newsums=$(makepkg -g -p "$buildfile") && rm -f "$buildfile" &&
 | 
			
		||||
	exec awk -v newsums="$newsums" '
 | 
			
		||||
	/^[[:blank:]]*(md|sha)[[:digit:]]+sums=/,/\)[[:blank:]]*(#.*)?$/ {
 | 
			
		||||
		if (!w) {
 | 
			
		||||
			print newsums
 | 
			
		||||
			w++
 | 
			
		||||
		}
 | 
			
		||||
		next
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	1
 | 
			
		||||
	END { if (!w) print newsums }
 | 
			
		||||
	' > "$buildfile"
 | 
			
		||||
} < "$buildfile"
 | 
			
		||||
 | 
			
		||||
# vim: set ts=2 sw=2 noet:
 | 
			
		||||
@@ -1,25 +1,29 @@
 | 
			
		||||
#compdef pacman pacman.static=pacman
 | 
			
		||||
#compdef pacman pacman.static=pacman pacman-key makepkg
 | 
			
		||||
 | 
			
		||||
# copy this file to /usr/share/zsh/site-functions/_pacman
 | 
			
		||||
 | 
			
		||||
typeset -A opt_args
 | 
			
		||||
setopt extendedglob
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: main pacman commands
 | 
			
		||||
_pacman_opts_commands=(
 | 
			
		||||
	'-Q[Query the package database]'
 | 
			
		||||
	'-R[Remove a package from the system]'
 | 
			
		||||
	'-S[Synchronize packages]'
 | 
			
		||||
	'-U[Upgrade a package]'
 | 
			
		||||
	'-V[Display version and exit]'
 | 
			
		||||
	'-h[Display usage]'
 | 
			
		||||
	{-D,--database}'[Modify database]'
 | 
			
		||||
	{-Q,--query}'[Query the package database]'
 | 
			
		||||
	{-R,--remove}'[Remove a package from the system]'
 | 
			
		||||
	{-S,--sync}'[Synchronize packages]'
 | 
			
		||||
	{-T,--deptest}'[Check if dependencies are installed]'
 | 
			
		||||
	{-U,--upgrade}'[Upgrade a package]'
 | 
			
		||||
	{-V,--version}'[Display version and exit]'
 | 
			
		||||
	'(-h --help)'{-h,--help}'[Display usage]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options common to all commands
 | 
			
		||||
_pacman_opts_common=(
 | 
			
		||||
	'-b[Alternate database location]:database_location:_files -/'
 | 
			
		||||
	'-h[Display syntax for the given operation]'
 | 
			
		||||
	'-r[Set alternate installation root]:installation root:_files -/'
 | 
			
		||||
	'-v[Be more verbose]'
 | 
			
		||||
	{-b,--dbpath}'[Alternate database location]:database_location:_files -/'
 | 
			
		||||
	'--color[colorize the output]:color options:(always never auto)'
 | 
			
		||||
	{-h,--help}'[Display syntax for the given operation]'
 | 
			
		||||
	{-r,--root}'[Set alternate installation root]:installation root:_files -/'
 | 
			
		||||
	{-v,--verbose}'[Be more verbose]'
 | 
			
		||||
	'--cachedir[Alternate package cache location]:cache_location:_files -/'
 | 
			
		||||
	'--config[An alternate configuration file]:config file:_files'
 | 
			
		||||
	'--logfile[An alternate log file]:config file:_files'
 | 
			
		||||
@@ -31,52 +35,59 @@ _pacman_opts_common=(
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options for --upgrade commands
 | 
			
		||||
_pacman_opts_pkgfile=(
 | 
			
		||||
	'-d[Skip dependency checks]'
 | 
			
		||||
	'-f[Overwrite conflicting files]'
 | 
			
		||||
	'*-d[Skip dependency checks]'
 | 
			
		||||
	'*--nodeps[Skip dependency checks]'
 | 
			
		||||
	'--dbonly[Only remove database entry, do not remove files]'
 | 
			
		||||
	'--force[Overwrite conflicting files]'
 | 
			
		||||
	'--needed[Do not reinstall up to date packages]'
 | 
			
		||||
	'--recursive[Reinstall all dependencies of target packages]'
 | 
			
		||||
	'*:package file:_files -g "*.pkg.tar.*(.)"'
 | 
			
		||||
	'*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: subactions for --query command
 | 
			
		||||
_pacman_opts_query_actions=(
 | 
			
		||||
	'-g[View all members of a package group]:*:package groups:->query_group'
 | 
			
		||||
	'-o[Query the package that owns a file]:file:_files'
 | 
			
		||||
	'-p[Package file to query]:*:package file:->query_file'
 | 
			
		||||
	'-s[Search package names and descriptions]:*:search text:->query_search'
 | 
			
		||||
	'(-Q --query)'{-Q,--query}
 | 
			
		||||
	{-g,--groups}'[View all members of a package group]:*:package groups:->query_group'
 | 
			
		||||
	{-o,--owns}'[Query the package that owns a file]:file:_files'
 | 
			
		||||
	{-p,--file}'[Package file to query]:*:package file:->query_file'
 | 
			
		||||
	{-s,--search}'[Search package names and descriptions]:*:search text:->query_search'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options for --query and subcommands
 | 
			
		||||
_pacman_opts_query_modifiers=(
 | 
			
		||||
	'-c[List package changelog]'
 | 
			
		||||
	'-d[List packages installed as dependencies]'
 | 
			
		||||
	'-e[List packages explicitly installed]'
 | 
			
		||||
	'-i[View package information]'
 | 
			
		||||
	'-ii[View package information including backup files]'
 | 
			
		||||
	'-k[Check package files]'
 | 
			
		||||
	'-l[List package contents]'
 | 
			
		||||
	'-m[List installed packages not found in sync db(s)]'
 | 
			
		||||
	'-t[List packages not required by any package]'
 | 
			
		||||
	'-u[List packages that can be upgraded]'
 | 
			
		||||
	{-c,--changelog}'[List package changelog]'
 | 
			
		||||
	{-d,--deps}'[List packages installed as dependencies]'
 | 
			
		||||
	{-e,--explicit}'[List packages explicitly installed]'
 | 
			
		||||
	{\*-i,\*--info}'[View package information]'
 | 
			
		||||
	{\*-k,\*--check}'[Check package files]'
 | 
			
		||||
	{-l,--list}'[List package contents]'
 | 
			
		||||
	{-m,--foreign}'[List installed packages not found in sync db(s)]'
 | 
			
		||||
	{-n,--native}'[List installed packages found in sync db(s)]'
 | 
			
		||||
	{-t,--unrequired}'[List packages not required by any package]'
 | 
			
		||||
	{-u,--upgrades}'[List packages that can be upgraded]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options for --remove command
 | 
			
		||||
_pacman_opts_remove=(
 | 
			
		||||
	'-c[Remove all dependent packages]'
 | 
			
		||||
	'-d[Skip dependency checks]'
 | 
			
		||||
	'-n[Remove protected configuration files]'
 | 
			
		||||
	'-s[Remove dependencies not required by other packages]'
 | 
			
		||||
	{-c,--cascade}'[Remove all dependent packages]'
 | 
			
		||||
	{*-d,*--nodeps}'[Skip dependency checks]'
 | 
			
		||||
	{-n,--nosave}'[Remove protected configuration files]'
 | 
			
		||||
	{\*-s,\*--recursive}'[Remove dependencies not required by other packages]'
 | 
			
		||||
	'--dbonly[Only remove database entry, do not remove files]'
 | 
			
		||||
	'*:installed package:_pacman_completions_installed_packages'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_pacman_opts_database=(
 | 
			
		||||
	'--asdeps[mark packages as non-explicitly installed]'
 | 
			
		||||
	'--asexplicit[mark packages as explicitly installed]'
 | 
			
		||||
	'*:installed package:_pacman_completions_installed_packages'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options for --sync command
 | 
			
		||||
_pacman_opts_sync_actions=(
 | 
			
		||||
	'*-c[Remove old packages from cache]:*:clean:->sync_clean'
 | 
			
		||||
	'*-cc[Remove all packages from cache]:*:clean:->sync_clean'
 | 
			
		||||
	'-g[View all members of a package group]:*:package groups:->sync_group'
 | 
			
		||||
	'-s[Search package names and descriptions]:*:search text:->sync_search'
 | 
			
		||||
	'(-S --sync)'{-S,--sync}
 | 
			
		||||
	{\*-c,\*--clean}'[Remove old packages from cache]:\*:clean:->sync_clean'
 | 
			
		||||
	{-g,--groups}'[View all members of a package group]:*:package groups:->sync_group'
 | 
			
		||||
	{-s,--search}'[Search package names and descriptions]:*:search text:->sync_search'
 | 
			
		||||
	'--dbonly[Only remove database entry, do not remove files]'
 | 
			
		||||
	'--needed[Do not reinstall up to date packages]'
 | 
			
		||||
	'--recursive[Reinstall all dependencies of target packages]'
 | 
			
		||||
@@ -84,20 +95,18 @@ _pacman_opts_sync_actions=(
 | 
			
		||||
 | 
			
		||||
# options for passing to _arguments: options for --sync command
 | 
			
		||||
_pacman_opts_sync_modifiers=(
 | 
			
		||||
	'-d[Skip dependency checks]'
 | 
			
		||||
	'-f[Overwrite conflicting files]'
 | 
			
		||||
	'-i[View package information]'
 | 
			
		||||
	'-l[List all packages in a repository]'
 | 
			
		||||
	'-p[Print download URIs for each package to be installed]'
 | 
			
		||||
	'-u[Upgrade all out-of-date packages]'
 | 
			
		||||
	'-w[Download packages only]'
 | 
			
		||||
	'-y[Download fresh package databases]'
 | 
			
		||||
	'*--ignore[Ignore a package upgrade]:package:
 | 
			
		||||
		_pacman_completions_all_packages'
 | 
			
		||||
	'*--ignoregroup[Ignore a group upgrade]:package group:
 | 
			
		||||
		_pacman_completions_all_groups'
 | 
			
		||||
	{\*-d,\*--nodeps}'[Skip dependency checks]'
 | 
			
		||||
	{\*-i,\*--info}'[View package information]'
 | 
			
		||||
	{-l,--list}'[List all packages in a repository]'
 | 
			
		||||
	{-p,--print}'[Print download URIs for each package to be installed]'
 | 
			
		||||
	{\*-u,\*--sysupgrade}'[Upgrade all out-of-date packages]'
 | 
			
		||||
	{-w,--downloadonly}'[Download packages only]'
 | 
			
		||||
	{\*-y,\*--refresh}'[Download fresh package databases]'
 | 
			
		||||
	'*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
 | 
			
		||||
	'*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
 | 
			
		||||
	'--asdeps[Install packages as non-explicitly installed]'
 | 
			
		||||
	'--asexplicit[Install packages as explicitly installed]'
 | 
			
		||||
	'--force[Overwrite conflicting files]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# handles --help subcommand
 | 
			
		||||
@@ -117,94 +126,111 @@ _pacman_action_query() {
 | 
			
		||||
	local context state line
 | 
			
		||||
	typeset -A opt_args
 | 
			
		||||
 | 
			
		||||
#	_arguments -s : \
 | 
			
		||||
#		"$_pacman_opts_common[@]" \
 | 
			
		||||
#		"$_pacman_opts_query_actions[@]" \
 | 
			
		||||
#		"$_pacman_opts_query_modifiers[@]"
 | 
			
		||||
 | 
			
		||||
	case $state in
 | 
			
		||||
		query_file)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:package file:_files -g "*.pkg.tar.*"'
 | 
			
		||||
				;;
 | 
			
		||||
				'*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
 | 
			
		||||
			;;
 | 
			
		||||
		query_group)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:groups:_pacman_completions_installed_groups'
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
		query_owner)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:file:_files'
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
		query_search)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:search text: '
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_actions[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:package:_pacman_completions_installed_packages'
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# handles --remove subcommand
 | 
			
		||||
_pacman_action_remove() {
 | 
			
		||||
	_arguments -s : \
 | 
			
		||||
		'(--remove -R)'{-R,--remove} \
 | 
			
		||||
		"$_pacman_opts_common[@]" \
 | 
			
		||||
		"$_pacman_opts_remove[@]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# handles --database subcommand
 | 
			
		||||
_pacman_action_database() {
 | 
			
		||||
	_arguments -s : \
 | 
			
		||||
		'(--database -D)'{-D,--database} \
 | 
			
		||||
		"$_pacman_opts_common[@]" \
 | 
			
		||||
		"$_pacman_opts_database[@]"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_action_deptest () {
 | 
			
		||||
	_arguments -s : \
 | 
			
		||||
		'(--deptest)-T' \
 | 
			
		||||
		"$_pacman_opts_common[@]" \
 | 
			
		||||
		":packages:_pacman_all_packages"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# handles --sync subcommand
 | 
			
		||||
_pacman_action_sync() {
 | 
			
		||||
	local context state line
 | 
			
		||||
	typeset -A opt_args
 | 
			
		||||
 | 
			
		||||
#	_arguments -s : \
 | 
			
		||||
#		"$_pacman_opts_common[@]" \
 | 
			
		||||
#		"$_pacman_opts_sync_actions[@]" #\
 | 
			
		||||
#		#"$_pacman_opts_sync_modifiers[@]"
 | 
			
		||||
	if (( $+words[(r)--clean] )); then
 | 
			
		||||
		state=sync_clean
 | 
			
		||||
	elif (( $+words[(r)--groups] )); then
 | 
			
		||||
		state=sync_group
 | 
			
		||||
	elif (( $+words[(r)--search] )); then
 | 
			
		||||
		state=sync_search
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	case $state in
 | 
			
		||||
		sync_clean)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				{\*-c,\*--clean}'[Remove old packages from cache]' \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'*-c[Remove old packages from cache]' \
 | 
			
		||||
				;;
 | 
			
		||||
		sync_group)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'(-g --group)'{-g,--groups} \
 | 
			
		||||
				'*:package group:_pacman_completions_all_groups'
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
		sync_search)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'*:search text: '
 | 
			
		||||
				;;
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_actions[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'*:package:_pacman_completions_all_packages'
 | 
			
		||||
				;;
 | 
			
		||||
		esac
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# handles --upgrade subcommand
 | 
			
		||||
_pacman_action_upgrade() {
 | 
			
		||||
	_arguments -s : \
 | 
			
		||||
		'(-U --upgrade)'{-U,--upgrade} \
 | 
			
		||||
		"$_pacman_opts_common[@]" \
 | 
			
		||||
		"$_pacman_opts_pkgfile[@]"
 | 
			
		||||
}
 | 
			
		||||
@@ -262,6 +288,12 @@ _pacman_completions_installed_packages() {
 | 
			
		||||
	compadd "$@" -a packages
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_all_packages() {
 | 
			
		||||
	_alternative : \
 | 
			
		||||
		'localpkgs:local packages:_pacman_completions_installed_packages' \
 | 
			
		||||
		'repopkgs:repository packages:_pacman_completions_all_packages'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# provides completions for repository names
 | 
			
		||||
_pacman_completions_repositories() {
 | 
			
		||||
	local -a cmd repositories
 | 
			
		||||
@@ -276,7 +308,7 @@ _pacman_completions_repositories() {
 | 
			
		||||
# $cmd must be declared by calling function
 | 
			
		||||
_pacman_get_command() {
 | 
			
		||||
	# this is mostly nicked from _perforce
 | 
			
		||||
	cmd=( "pacman" )
 | 
			
		||||
	cmd=( "pacman" "2>/dev/null")
 | 
			
		||||
	integer i
 | 
			
		||||
	for (( i = 2; i < CURRENT - 1; i++ )); do
 | 
			
		||||
		if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then
 | 
			
		||||
@@ -286,51 +318,337 @@ _pacman_get_command() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# main dispatcher
 | 
			
		||||
_pacman() {
 | 
			
		||||
	case $words[2] in
 | 
			
		||||
		-Q*g*) # ipkg groups
 | 
			
		||||
_pacman_zsh_comp() {
 | 
			
		||||
	local -a args cmds;
 | 
			
		||||
	local tmp
 | 
			
		||||
	args=( ${${${(M)words:#-*}#-}:#-*} )
 | 
			
		||||
	for tmp in $words; do
 | 
			
		||||
		cmds+=("${${_pacman_opts_commands[(r)*$tmp\[*]%%\[*}#*\)}")
 | 
			
		||||
	done
 | 
			
		||||
	case $args in #$words[2] in
 | 
			
		||||
		h*)
 | 
			
		||||
			if (( ${(c)#args} <= 1 && ${(w)#cmds} <= 1 )); then
 | 
			
		||||
				_pacman_action_help
 | 
			
		||||
			else
 | 
			
		||||
				_message "no more arguments"
 | 
			
		||||
			fi
 | 
			
		||||
			;;
 | 
			
		||||
		*h*)
 | 
			
		||||
			_message "no more arguments"
 | 
			
		||||
			;;
 | 
			
		||||
		D*)
 | 
			
		||||
			_pacman_action_database
 | 
			
		||||
			;;
 | 
			
		||||
		Q*g*) # ipkg groups
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:groups:_pacman_completions_installed_groups'
 | 
			
		||||
				;;
 | 
			
		||||
		-Q*o*) # file
 | 
			
		||||
			;;
 | 
			
		||||
		Q*o*) # file
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:package file:_files'
 | 
			
		||||
				;;
 | 
			
		||||
		-Q*p*) # file *.pkg.tar.*
 | 
			
		||||
			;;
 | 
			
		||||
		Q*p*) # file *.pkg.tar*
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_query_modifiers[@]" \
 | 
			
		||||
				'*:package file:_files -g "*.pkg.tar.*"'
 | 
			
		||||
				;;
 | 
			
		||||
		-Q*)  _pacman_action_query    ;;
 | 
			
		||||
		-R*)  _pacman_action_remove   ;;
 | 
			
		||||
		-S*c*) # no completion
 | 
			
		||||
			return 0
 | 
			
		||||
				'*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
 | 
			
		||||
			;;
 | 
			
		||||
		-S*l*) # repos
 | 
			
		||||
		T*)
 | 
			
		||||
			_pacman_action_deptest
 | 
			
		||||
			;;
 | 
			
		||||
		Q*)
 | 
			
		||||
			_pacman_action_query
 | 
			
		||||
			;;
 | 
			
		||||
		R*)
 | 
			
		||||
			_pacman_action_remove
 | 
			
		||||
			;;
 | 
			
		||||
		S*c*) # no completion
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				'(-c --clean)'{\*-c,\*--clean}'[Remove all files from the cache]' \
 | 
			
		||||
				"$_pacman_opts_common[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		S*l*) # repos
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'*:package repo:_pacman_completions_repositories' \
 | 
			
		||||
				;;
 | 
			
		||||
		-S*g*) # pkg groups
 | 
			
		||||
			;;
 | 
			
		||||
		S*g*) # pkg groups
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				"$_pacman_opts_sync_modifiers[@]" \
 | 
			
		||||
				'*:package group:_pacman_completions_all_groups'
 | 
			
		||||
				;;
 | 
			
		||||
		-S*)  _pacman_action_sync     ;;
 | 
			
		||||
		-U*)  _pacman_action_upgrade  ;;
 | 
			
		||||
		-V*)  _pacman_action_version  ;;
 | 
			
		||||
		-h*)  _pacman_action_help     ;;
 | 
			
		||||
		-  )  _pacman_action_none     ;;
 | 
			
		||||
		*  )  return 1                ;;
 | 
			
		||||
			;;
 | 
			
		||||
		S*)
 | 
			
		||||
			_pacman_action_sync
 | 
			
		||||
			;;
 | 
			
		||||
		T*)
 | 
			
		||||
			 _arguments -s : \
 | 
			
		||||
				'-T' \
 | 
			
		||||
				"$_pacman_opts_common[@]" \
 | 
			
		||||
				":packages:_pacman_all_packages"
 | 
			
		||||
			;;
 | 
			
		||||
		U*)
 | 
			
		||||
			_pacman_action_upgrade
 | 
			
		||||
			;;
 | 
			
		||||
		V*)
 | 
			
		||||
			_pacman_action_version
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
 | 
			
		||||
			case ${(M)words:#--*} in
 | 
			
		||||
				*--help*)
 | 
			
		||||
					if (( ${(w)#cmds} == 1 )); then
 | 
			
		||||
						_pacman_action_help
 | 
			
		||||
					else
 | 
			
		||||
						return 0;
 | 
			
		||||
					fi
 | 
			
		||||
					;;
 | 
			
		||||
				*--sync*)
 | 
			
		||||
					_pacman_action_sync
 | 
			
		||||
					;;
 | 
			
		||||
				*--query*)
 | 
			
		||||
					_pacman_action_query
 | 
			
		||||
					;;
 | 
			
		||||
				*--remove*)
 | 
			
		||||
					_pacman_action_remove
 | 
			
		||||
					;;
 | 
			
		||||
				*--deptest*)
 | 
			
		||||
					_pacman_action_deptest
 | 
			
		||||
					;;
 | 
			
		||||
				*--database*)
 | 
			
		||||
					_pacman_action_database
 | 
			
		||||
					;;
 | 
			
		||||
				*--version*)
 | 
			
		||||
					_pacman_action_version
 | 
			
		||||
					;;
 | 
			
		||||
				*--upgrade*)
 | 
			
		||||
					_pacman_action_upgrade
 | 
			
		||||
					;;
 | 
			
		||||
				*)
 | 
			
		||||
					_pacman_action_none
 | 
			
		||||
					;;
 | 
			
		||||
			esac
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# run the main dispatcher
 | 
			
		||||
_pacman "$@"
 | 
			
		||||
_key_shortopts=(
 | 
			
		||||
	'-h[show help]'
 | 
			
		||||
	'-a[Add the specified keys (empty for stdin)]: :_files'
 | 
			
		||||
	'-d[Remove the Specified keyids]:*: :_keys'
 | 
			
		||||
	'-e[Export the specified or all keyids]:*: :_keys'
 | 
			
		||||
	'-f[List fingreprint for specidied or all keyids]:*: :_keys'
 | 
			
		||||
	'-l[List the specified or all keys]:*: :_keys'
 | 
			
		||||
	'-r[Fetch the specified keyids]:*: :_keys'
 | 
			
		||||
	'-u[Update the trustdb of pacman]'
 | 
			
		||||
	'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
 | 
			
		||||
	'-V[Show program version]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_key_longopts=(
 | 
			
		||||
	'--help[show help]'
 | 
			
		||||
	'--add[Add the specified keys (empty for stdin)]: :_files'
 | 
			
		||||
	'--delete[Remove the Specified keyids]:*: :_keys'
 | 
			
		||||
	'--export[Export the specified or all keyids]:*: :_keys'
 | 
			
		||||
	'--finger[List fingreprint for specidied or all keyids]:*: :_keys'
 | 
			
		||||
	'--list-keys[List the specified or all keys]:*: :_keys'
 | 
			
		||||
	'--recv-keys[Fetch the specified keyids]:*: :_keys'
 | 
			
		||||
	'--updatedb[Update the trustdb of pacman]'
 | 
			
		||||
	'--verify[Verify the file specified by the signature]: :_files -g "*.sig"'
 | 
			
		||||
	'--version[Show program version]'
 | 
			
		||||
	'--edit-key[Present a menu for key management task on keyids]:*: :_keys'
 | 
			
		||||
	'--import[Imports pubring.gpg from dir(s)]: :_files -g "*.gpg"'
 | 
			
		||||
	'--import-tb[Imports ownertrust values from trustdb.gpg in dir(s)]: :_files -g "*.gpg"'
 | 
			
		||||
	'--init[Ensure the keyring is properly initialized]'
 | 
			
		||||
	'--list-sigs[List keys and their signatures]:*: :_keys'
 | 
			
		||||
	'--lsign-key[Locally sign the specified keyid]:*: :_keys'
 | 
			
		||||
	'--populate[Reload the default keys from the (given) keyrings in '/usr/share/pacman/keyrings']: :_path_files -W /usr/share/pacman/keyrings'
 | 
			
		||||
	'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_pacman_key_options=(
 | 
			
		||||
	'--config[Use an alternate config file (instead of /etc/pacman.con)]: :_files'
 | 
			
		||||
	'--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
 | 
			
		||||
	'--keyserver[Specify a keyserver to use if necessary]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_pacman_key() {
 | 
			
		||||
	case $words[CURRENT] in
 | 
			
		||||
		--*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_key_options[@]" \
 | 
			
		||||
				"$_key_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		-*)
 | 
			
		||||
			_arguments -s : \
 | 
			
		||||
				"$_pacman_key_options[@]" \
 | 
			
		||||
				"$_key_shortopts[@]" \
 | 
			
		||||
				"$_key_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			i=$#;
 | 
			
		||||
			while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do
 | 
			
		||||
				i=$(($i-1))
 | 
			
		||||
			done
 | 
			
		||||
			case $i in
 | 
			
		||||
				--*)
 | 
			
		||||
					_arguments -s : \
 | 
			
		||||
						"$_pacman_key_options[@]" \
 | 
			
		||||
						"$_key_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				-*)
 | 
			
		||||
					_arguments -s : \
 | 
			
		||||
						"$_pacman_key_options[@]" \
 | 
			
		||||
						"$_key_shortopts[@]" \
 | 
			
		||||
						"$_key_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				*)
 | 
			
		||||
					return 1
 | 
			
		||||
					;;
 | 
			
		||||
			esac
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_keys() {
 | 
			
		||||
	local keylist keys
 | 
			
		||||
	keylist=$(pacman-key --list-keys 2>/dev/null | awk '
 | 
			
		||||
		$1 == "pub" {
 | 
			
		||||
			# key id
 | 
			
		||||
			split($2, a, "/"); print a[2]
 | 
			
		||||
		}
 | 
			
		||||
		$1 == "uid" {
 | 
			
		||||
			# email
 | 
			
		||||
			if (match($NF, /<[^>]+>/))
 | 
			
		||||
				print substr($NF, RSTART + 1, RLENGTH - 2)
 | 
			
		||||
		#this adds support for names as well if that is ever added
 | 
			
		||||
			}
 | 
			
		||||
		$1 == "uid" {
 | 
			
		||||
		for (i=2;i<NF;i++) {printf "%s%s",sep, $i;sep=" "}; printf "\n"
 | 
			
		||||
		}' |sed -e 's/(.*)//g' -e 's/^\ //g' -e 's/\ *$//g' |uniq
 | 
			
		||||
		)
 | 
			
		||||
		keys=(${(s:/:)${keylist//$'\n'/\/}})
 | 
			
		||||
	_describe -t modules 'keys in keyring' keys && return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_makepkg_shortopts=(
 | 
			
		||||
	'-s[Install missing dependencies with pacman]'
 | 
			
		||||
	'-i[Install package after successful build]'
 | 
			
		||||
	'-A[Ignore incomplete arch field in PKGBUILD]'
 | 
			
		||||
	'-c[Clean up work files after build]'
 | 
			
		||||
	'-d[Skip all dependency checks]'
 | 
			
		||||
	'-e[Do not extract source files (use existing src/ dir)]'
 | 
			
		||||
	'-f[Overwrite existing package]'
 | 
			
		||||
	'-g[Generate integrity checks for source files]'
 | 
			
		||||
	'-h[Show help message and exit]'
 | 
			
		||||
	'-L[Log package build process]'
 | 
			
		||||
	'-m[Disable colorized output messages]'
 | 
			
		||||
	'-o[Download and extract files only]'
 | 
			
		||||
	'-p[Use an alternate build script (instead of 'PKGBUILD')]: :_files'
 | 
			
		||||
	'-r[Remove installed dependencies after a successful build]'
 | 
			
		||||
	'-R[Repackage contents of the package without rebuilding]'
 | 
			
		||||
	'-S[Generate a source-only tarball without downloading sources]'
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
_makepkg_action_none(){
 | 
			
		||||
	_arguments \
 | 
			
		||||
		"$_makepkg_shortopts[@]" \
 | 
			
		||||
		"$_makepkg_longopts[@]"
 | 
			
		||||
}
 | 
			
		||||
_makepkg_longopts=(
 | 
			
		||||
	'--ignorearch[Ignore incomplete arch field in PKGBUILD]'
 | 
			
		||||
	'--clean[Clean up work files after build]'
 | 
			
		||||
	'--nodeps[Skip all dependency checks]'
 | 
			
		||||
	'--noextract[Do not extract source files (use existing src/ dir)]'
 | 
			
		||||
	'--force[Overwrite existing package]'
 | 
			
		||||
	'--geninteg[Generate integrity checks for source files]'
 | 
			
		||||
	'--help[Show help message and exit]'
 | 
			
		||||
	'--install[Install package after successful build]'
 | 
			
		||||
	'--log[Log package build process]'
 | 
			
		||||
	'--nocolor[Disable colorized output messages]'
 | 
			
		||||
	'--nobuild[Download and extract files only]'
 | 
			
		||||
	'--rmdeps[Remove installed dependencies after a successful build]'
 | 
			
		||||
	'--repackage[Repackage contents of the package without rebuilding]'
 | 
			
		||||
	'--syncdeps[Install missing dependencies with pacman]'
 | 
			
		||||
	'--source[Generate a source-only tarball without downloading sources]'
 | 
			
		||||
	'--allsource[Generate a source-only tarball including downloaded source]'
 | 
			
		||||
	'--asroot[Allow makepkg to run as root user]'
 | 
			
		||||
	'--check[Run check() function in the PKGBUILD]'
 | 
			
		||||
	'--config[Use an alternate config file instead of '/etc/makepkg.conf']: :_files'
 | 
			
		||||
	'--holdver[Prevent automatic version bumping for development PKGBUILDs]'
 | 
			
		||||
	'--key[Specify key to use for gpg signing instead of the default]: :_keys'
 | 
			
		||||
	'--nocheck[Do not run the check() function in the PKGBUILD]'
 | 
			
		||||
	'--nosign[Do not create a signature for the package]'
 | 
			
		||||
	'--pkg[Only build listed packages from a split package]'
 | 
			
		||||
	'--sign[Sign the resulting package with gpg]'
 | 
			
		||||
	'--skipchecksums[Do not verify checksums of the source files]'
 | 
			
		||||
	'--skipinteg[do not perform any verification checks on source files]'
 | 
			
		||||
	'--skippgpcheck[Do not verify source files with PGP signatures]'
 | 
			
		||||
	'--noconfirm[do not ask for confirmation when resolving dependencies]'
 | 
			
		||||
	'--asdeps[Install packages as non-explicitly installed]'
 | 
			
		||||
	'--noprogressbar[Do not show a progress bar when downloading files]'
 | 
			
		||||
	'--needed[Do not reinstall up-to-date packages]'
 | 
			
		||||
	'--verifysource[Only download sources and verify checksums]'
 | 
			
		||||
)
 | 
			
		||||
_makepkg(){
 | 
			
		||||
	case $words[CURRENT] in
 | 
			
		||||
		-*)
 | 
			
		||||
			_arguments -s -w : \
 | 
			
		||||
				"$_makepkg_shortopts[@]" \
 | 
			
		||||
				"$_makepkg_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		--* )
 | 
			
		||||
			_arguments -s \
 | 
			
		||||
				"$_makepkg_longopts[@]"
 | 
			
		||||
			;;
 | 
			
		||||
		- )
 | 
			
		||||
			_makepkg_action_none
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			i=$#
 | 
			
		||||
			while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do
 | 
			
		||||
				i=$((i-1));
 | 
			
		||||
			done
 | 
			
		||||
			case $words[$i] in
 | 
			
		||||
				-*)
 | 
			
		||||
					_arguments -s -w : \
 | 
			
		||||
						"$_makepkg_shortopts[@]" \
 | 
			
		||||
						"$_makepkg_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				--* )
 | 
			
		||||
					_arguments -s \
 | 
			
		||||
						"$_makepkg_longopts[@]"
 | 
			
		||||
					;;
 | 
			
		||||
				- )
 | 
			
		||||
					_makepkg_action_none
 | 
			
		||||
					;;
 | 
			
		||||
				* )
 | 
			
		||||
					return 1
 | 
			
		||||
					;;
 | 
			
		||||
			esac
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
_pacman_comp() {
 | 
			
		||||
	case "$service" in
 | 
			
		||||
		makepkg)
 | 
			
		||||
			_makepkg "$@"
 | 
			
		||||
			;;
 | 
			
		||||
		pacman-key)
 | 
			
		||||
			_pacman_key "$@"
 | 
			
		||||
			;;
 | 
			
		||||
		pacman)
 | 
			
		||||
			_pacman_zsh_comp "$@"
 | 
			
		||||
			;;
 | 
			
		||||
		*)
 | 
			
		||||
			_message "Error"
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_pacman_comp "$@"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								doc/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								doc/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -5,6 +5,7 @@ makepkg.conf.5
 | 
			
		||||
pacman.8
 | 
			
		||||
pacman-key.8
 | 
			
		||||
pacman.conf.5
 | 
			
		||||
pactree.8
 | 
			
		||||
pkgdelta.8
 | 
			
		||||
repo-add.8
 | 
			
		||||
repo-remove.8
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								doc/Doxyfile
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								doc/Doxyfile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
# Doxyfile 1.7.5.1
 | 
			
		||||
# Doxyfile 1.8.2
 | 
			
		||||
 | 
			
		||||
#---------------------------------------------------------------------------
 | 
			
		||||
# Project related configuration options
 | 
			
		||||
@@ -37,11 +37,14 @@ INHERIT_DOCS           = YES
 | 
			
		||||
SEPARATE_MEMBER_PAGES  = NO
 | 
			
		||||
TAB_SIZE               = 4
 | 
			
		||||
ALIASES                =
 | 
			
		||||
TCL_SUBST              =
 | 
			
		||||
OPTIMIZE_OUTPUT_FOR_C  = YES
 | 
			
		||||
OPTIMIZE_OUTPUT_JAVA   = NO
 | 
			
		||||
OPTIMIZE_FOR_FORTRAN   = NO
 | 
			
		||||
OPTIMIZE_OUTPUT_VHDL   = NO
 | 
			
		||||
EXTENSION_MAPPING      =
 | 
			
		||||
MARKDOWN_SUPPORT       = YES
 | 
			
		||||
AUTOLINK_SUPPORT       = YES
 | 
			
		||||
BUILTIN_STL_SUPPORT    = NO
 | 
			
		||||
CPP_CLI_SUPPORT        = NO
 | 
			
		||||
SIP_SUPPORT            = NO
 | 
			
		||||
@@ -52,11 +55,13 @@ INLINE_GROUPED_CLASSES = NO
 | 
			
		||||
INLINE_SIMPLE_STRUCTS  = NO
 | 
			
		||||
TYPEDEF_HIDES_STRUCT   = NO
 | 
			
		||||
SYMBOL_CACHE_SIZE      = 0
 | 
			
		||||
LOOKUP_CACHE_SIZE      = 0
 | 
			
		||||
#---------------------------------------------------------------------------
 | 
			
		||||
# Build related configuration options
 | 
			
		||||
#---------------------------------------------------------------------------
 | 
			
		||||
EXTRACT_ALL            = NO
 | 
			
		||||
EXTRACT_PRIVATE        = NO
 | 
			
		||||
EXTRACT_PACKAGE        = NO
 | 
			
		||||
EXTRACT_STATIC         = NO
 | 
			
		||||
EXTRACT_LOCAL_CLASSES  = YES
 | 
			
		||||
EXTRACT_LOCAL_METHODS  = NO
 | 
			
		||||
@@ -84,7 +89,6 @@ GENERATE_DEPRECATEDLIST= YES
 | 
			
		||||
ENABLED_SECTIONS       =
 | 
			
		||||
MAX_INITIALIZER_LINES  = 30
 | 
			
		||||
SHOW_USED_FILES        = YES
 | 
			
		||||
SHOW_DIRECTORIES       = NO
 | 
			
		||||
SHOW_FILES             = YES
 | 
			
		||||
SHOW_NAMESPACES        = YES
 | 
			
		||||
FILE_VERSION_FILTER    =
 | 
			
		||||
@@ -145,13 +149,14 @@ HTML_FILE_EXTENSION    = .html
 | 
			
		||||
HTML_HEADER            =
 | 
			
		||||
HTML_FOOTER            =
 | 
			
		||||
HTML_STYLESHEET        =
 | 
			
		||||
HTML_EXTRA_STYLESHEET  =
 | 
			
		||||
HTML_EXTRA_FILES       =
 | 
			
		||||
HTML_COLORSTYLE_HUE    = 220
 | 
			
		||||
HTML_COLORSTYLE_SAT    = 100
 | 
			
		||||
HTML_COLORSTYLE_GAMMA  = 80
 | 
			
		||||
HTML_TIMESTAMP         = YES
 | 
			
		||||
HTML_ALIGN_MEMBERS     = YES
 | 
			
		||||
HTML_DYNAMIC_SECTIONS  = NO
 | 
			
		||||
HTML_INDEX_NUM_ENTRIES = 100
 | 
			
		||||
GENERATE_DOCSET        = NO
 | 
			
		||||
DOCSET_FEEDNAME        = "Doxygen generated docs"
 | 
			
		||||
DOCSET_BUNDLE_ID       = org.doxygen.Project
 | 
			
		||||
@@ -175,9 +180,8 @@ QHG_LOCATION           =
 | 
			
		||||
GENERATE_ECLIPSEHELP   = NO
 | 
			
		||||
ECLIPSE_DOC_ID         = org.doxygen.Project
 | 
			
		||||
DISABLE_INDEX          = NO
 | 
			
		||||
ENUM_VALUES_PER_LINE   = 4
 | 
			
		||||
GENERATE_TREEVIEW      = NO
 | 
			
		||||
USE_INLINE_TREES       = NO
 | 
			
		||||
ENUM_VALUES_PER_LINE   = 4
 | 
			
		||||
TREEVIEW_WIDTH         = 250
 | 
			
		||||
EXT_LINKS_IN_WINDOW    = NO
 | 
			
		||||
FORMULA_FONTSIZE       = 10
 | 
			
		||||
@@ -280,6 +284,7 @@ CLASS_GRAPH            = YES
 | 
			
		||||
COLLABORATION_GRAPH    = YES
 | 
			
		||||
GROUP_GRAPHS           = YES
 | 
			
		||||
UML_LOOK               = NO
 | 
			
		||||
UML_LIMIT_NUM_FIELDS   = 10
 | 
			
		||||
TEMPLATE_RELATIONS     = NO
 | 
			
		||||
INCLUDE_GRAPH          = YES
 | 
			
		||||
INCLUDED_BY_GRAPH      = YES
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ ASCIIDOC_MANS = \
 | 
			
		||||
	vercmp.8 \
 | 
			
		||||
	pkgdelta.8 \
 | 
			
		||||
	pacman-key.8 \
 | 
			
		||||
	pactree.8 \
 | 
			
		||||
	PKGBUILD.5 \
 | 
			
		||||
	makepkg.conf.5 \
 | 
			
		||||
	pacman.conf.5 \
 | 
			
		||||
@@ -24,6 +25,7 @@ HTML_MANPAGES = \
 | 
			
		||||
	vercmp.8.html \
 | 
			
		||||
	pkgdelta.8.html \
 | 
			
		||||
	pacman-key.8.html \
 | 
			
		||||
	pactree.8.html \
 | 
			
		||||
	PKGBUILD.5.html \
 | 
			
		||||
	makepkg.conf.5.html \
 | 
			
		||||
	pacman.conf.5.html \
 | 
			
		||||
@@ -48,6 +50,7 @@ EXTRA_DIST = \
 | 
			
		||||
	vercmp.8.txt \
 | 
			
		||||
	pkgdelta.8.txt \
 | 
			
		||||
	pacman-key.8.txt \
 | 
			
		||||
	pactree.8.txt \
 | 
			
		||||
	PKGBUILD.5.txt \
 | 
			
		||||
	PKGBUILD-example.txt \
 | 
			
		||||
	makepkg.conf.5.txt \
 | 
			
		||||
@@ -90,8 +93,12 @@ endif
 | 
			
		||||
 | 
			
		||||
html: $(HTML_DOCS)
 | 
			
		||||
 | 
			
		||||
website: html
 | 
			
		||||
	bsdtar czf website.tar.gz $(HTML_DOCS) \
 | 
			
		||||
website: website.tar.gz
 | 
			
		||||
 | 
			
		||||
.PHONY: html website
 | 
			
		||||
 | 
			
		||||
website.tar.gz: html
 | 
			
		||||
	$(AM_V_GEN)bsdtar czf $@ $(HTML_DOCS) \
 | 
			
		||||
		asciidoc-override.css \
 | 
			
		||||
		-C /etc/asciidoc/stylesheets/ \
 | 
			
		||||
		asciidoc.css \
 | 
			
		||||
@@ -118,20 +125,20 @@ A2X_OPTS = \
 | 
			
		||||
	--destination-dir='./'
 | 
			
		||||
 | 
			
		||||
# These rules are due to the includes and files of the asciidoc text
 | 
			
		||||
$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile
 | 
			
		||||
	a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.txt
 | 
			
		||||
$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile.am
 | 
			
		||||
	$(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.txt
 | 
			
		||||
 | 
			
		||||
%.html: %.txt
 | 
			
		||||
	asciidoc $(ASCIIDOC_OPTS) $*.txt
 | 
			
		||||
	dos2unix $@
 | 
			
		||||
	$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.txt | \
 | 
			
		||||
		sed -e 's/\r$$//' > $@
 | 
			
		||||
 | 
			
		||||
HACKING.html: ../HACKING
 | 
			
		||||
	asciidoc $(ASCIIDOC_OPTS) -o $@ ../HACKING
 | 
			
		||||
	dos2unix $@
 | 
			
		||||
	$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - ../HACKING | \
 | 
			
		||||
		sed -e 's/\r$$//' > $@
 | 
			
		||||
 | 
			
		||||
# Customizations for certain HTML docs
 | 
			
		||||
$(HTML_MANPAGES): asciidoc.conf footer.txt Makefile
 | 
			
		||||
$(HTML_OTHER): asciidoc.conf Makefile
 | 
			
		||||
$(HTML_MANPAGES): asciidoc.conf footer.txt Makefile.am
 | 
			
		||||
$(HTML_OTHER): asciidoc.conf Makefile.am
 | 
			
		||||
%.html: ASCIIDOC_OPTS += -a linkcss -a toc -a icons -a max-width=960px -a stylesheet=asciidoc-override.css
 | 
			
		||||
%.8.html: ASCIIDOC_OPTS += -d manpage
 | 
			
		||||
%.5.html: ASCIIDOC_OPTS += -d manpage
 | 
			
		||||
@@ -144,6 +151,7 @@ repo-add.8 repo-add.8.html: repo-add.8.txt
 | 
			
		||||
vercmp.8 vercmp.8.html: vercmp.8.txt
 | 
			
		||||
pkgdelta.8 pkgdelta.8.html: pkgdelta.8.txt
 | 
			
		||||
pacman-key.8 pacman-key.8.html: pacman-key.8.txt
 | 
			
		||||
pactree.8 pactree.8.html: pactree.8.txt
 | 
			
		||||
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.txt PKGBUILD-example.txt
 | 
			
		||||
makepkg.conf.5 makepkg.conf.5.html: makepkg.conf.5.txt
 | 
			
		||||
pacman.conf.5 pacman.conf.5.html: pacman.conf.5.txt
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ pkgver=2.5.4
 | 
			
		||||
pkgrel=3
 | 
			
		||||
pkgdesc="A utility to apply patch files to original sources"
 | 
			
		||||
arch=('i686' 'x86_64')
 | 
			
		||||
url="http://www.gnu.org/software/patch/patch.html"
 | 
			
		||||
url="https://www.gnu.org/software/patch/patch.html"
 | 
			
		||||
license=('GPL')
 | 
			
		||||
groups=('base-devel')
 | 
			
		||||
depends=('glibc' 'ed')
 | 
			
		||||
 
 | 
			
		||||
@@ -40,12 +40,18 @@ similar to `$_basekernver`.
 | 
			
		||||
 | 
			
		||||
*pkgname (array)*::
 | 
			
		||||
	Either the name of the package or an array of names for split packages.
 | 
			
		||||
	Because it will be used in the package filename, this has to be unix-friendly.
 | 
			
		||||
	Members of the array are not allowed to start with hyphens.
 | 
			
		||||
	Valid characters for members of this array are alphanumerics, and any of
 | 
			
		||||
	the following characters: ```@ . _ + -`''. Additionally, names are not
 | 
			
		||||
	allowed to start with hyphens.
 | 
			
		||||
 | 
			
		||||
*pkgver*::
 | 
			
		||||
	The version of the software as released from the author (e.g., '2.7.1').
 | 
			
		||||
	The variable is not allowed to contain colons or hyphens.
 | 
			
		||||
+
 | 
			
		||||
The `pkgver` variable can be automatically updated by providing a `pkgver()` function
 | 
			
		||||
in the PKGBUILD that outputs the new package version.  This is run after downloading
 | 
			
		||||
and extracting the sources so can use those files in determining the new `pkgver`.
 | 
			
		||||
This is most useful when used with sources from version control systems (see below).
 | 
			
		||||
 | 
			
		||||
*pkgrel*::
 | 
			
		||||
	This is the release number specific to the Arch Linux release. This
 | 
			
		||||
@@ -108,6 +114,10 @@ It is also possible to change the name of the downloaded file, which is helpful
 | 
			
		||||
with weird URLs and for handling multiple source files with the same
 | 
			
		||||
name. The syntax is: `source=('filename::url')`.
 | 
			
		||||
+
 | 
			
		||||
makepkg also supports building developmental versions of packages using sources
 | 
			
		||||
downloaded from version control systems (VCS). For more information, see
 | 
			
		||||
<<VCS,Using VCS Sources>> below.
 | 
			
		||||
+
 | 
			
		||||
Files in the source array with extensions `.sig`, `.sign` or `.asc` are recognized by
 | 
			
		||||
makepkg as PGP signatures and will be automatically used to verify the integrity
 | 
			
		||||
of the corresponding source file.
 | 
			
		||||
@@ -120,9 +130,10 @@ of the corresponding source file.
 | 
			
		||||
*md5sums (array)*::
 | 
			
		||||
	This array contains an MD5 hash for every source file specified in the
 | 
			
		||||
	source array (in the same order). makepkg will use this to verify source
 | 
			
		||||
	file integrity during subsequent builds. To easily generate md5sums, run
 | 
			
		||||
	`makepkg -g >> PKGBUILD`. If desired, move the md5sums line to an
 | 
			
		||||
	appropriate location.
 | 
			
		||||
	file integrity during subsequent builds. If 'SKIP' is put in the array
 | 
			
		||||
	in place of a normal hash, the integrity check for that source file will
 | 
			
		||||
	be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
 | 
			
		||||
	If desired, move the md5sums line to an appropriate location.
 | 
			
		||||
 | 
			
		||||
*sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
 | 
			
		||||
	Alternative integrity checks that makepkg supports; these all behave
 | 
			
		||||
@@ -232,6 +243,10 @@ A normal sync or upgrade will not use its value.
 | 
			
		||||
		Leave libtool (.la) files in packages. Specify `!libtool` to
 | 
			
		||||
		remove them.
 | 
			
		||||
 | 
			
		||||
	*staticlibs*;;
 | 
			
		||||
		Leave static library (.a) files in packages. Specify `!staticlibs` to
 | 
			
		||||
		remove them.
 | 
			
		||||
 | 
			
		||||
	*emptydirs*;;
 | 
			
		||||
		Leave empty directories in packages.
 | 
			
		||||
 | 
			
		||||
@@ -252,10 +267,10 @@ A normal sync or upgrade will not use its value.
 | 
			
		||||
		with distcc.
 | 
			
		||||
 | 
			
		||||
	*buildflags*;;
 | 
			
		||||
		Allow the use of user-specific buildflags (CFLAGS, CXXFLAGS, LDFLAGS)
 | 
			
		||||
		during build as specified in linkman:makepkg.conf[5]. More useful in
 | 
			
		||||
		its negative form `!buildflags` with select packages that have problems
 | 
			
		||||
		building with custom buildflags.
 | 
			
		||||
		Allow the use of user-specific buildflags (CPPFLAGS, CFLAGS, CXXFLAGS,
 | 
			
		||||
		LDFLAGS) during build as specified in linkman:makepkg.conf[5]. More
 | 
			
		||||
		useful in its negative form `!buildflags` with select packages that
 | 
			
		||||
		have problems building with custom buildflags.
 | 
			
		||||
 | 
			
		||||
	*makeflags*;;
 | 
			
		||||
		Allow the use of user-specific makeflags during build as specified
 | 
			
		||||
@@ -263,55 +278,72 @@ A normal sync or upgrade will not use its value.
 | 
			
		||||
		`!makeflags` with select packages that have problems building with
 | 
			
		||||
		custom makeflags such as `-j2` (or higher).
 | 
			
		||||
 | 
			
		||||
	*debug*;;
 | 
			
		||||
		Add the user-specified debug flags (DEBUG_CFLAGS, DEBUG_CXXFLAGS) to
 | 
			
		||||
		their counterpart buildflags as specified in linkman:makepkg.conf[5].
 | 
			
		||||
		When used in combination with the `strip' option, a separate package
 | 
			
		||||
		containing the debug symbols is created.
 | 
			
		||||
 | 
			
		||||
build() Function
 | 
			
		||||
----------------
 | 
			
		||||
In addition to the above directives, the optional build() function usually
 | 
			
		||||
comprises the remainder of the PKGBUILD. This is directly sourced and executed
 | 
			
		||||
by makepkg, so anything that bash or the system has available is available for
 | 
			
		||||
use here. The function is run in `bash -e` mode, meaning any command that exits
 | 
			
		||||
with a non-zero status will cause the function to exit. Be sure any exotic
 | 
			
		||||
commands used are covered by `makedepends`.
 | 
			
		||||
 | 
			
		||||
Packaging Functions
 | 
			
		||||
-------------------
 | 
			
		||||
 | 
			
		||||
In addition to the above directives, PKGBUILDs require a set of functions that
 | 
			
		||||
provide instructions to build and install the package.  As a minimum, the PKGBUILD
 | 
			
		||||
must contain a package() function which installs all the package's files into the
 | 
			
		||||
packaging directory, with optional prepare(), build() and check() being used to
 | 
			
		||||
create those files from source.
 | 
			
		||||
 | 
			
		||||
*package() Function*::
 | 
			
		||||
	The package() function is used to install files into the directory that
 | 
			
		||||
	will become the root directory of the built package and is run after all
 | 
			
		||||
	the optional functions listed below. When specified in combination with
 | 
			
		||||
	the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
 | 
			
		||||
	will be limited to running the packaging stage. All other functions will
 | 
			
		||||
	be run as the user calling makepkg.
 | 
			
		||||
 | 
			
		||||
*prepare() Function*::
 | 
			
		||||
	An optional prepare() function can be specified in which operations that
 | 
			
		||||
	are to be run in order to prepare the sources for building (such as
 | 
			
		||||
	patching) are performed. This function is run after the source extraction
 | 
			
		||||
	and before the build() function and is skipped when source extraction is
 | 
			
		||||
	skipped.
 | 
			
		||||
 | 
			
		||||
*build() Function*::
 | 
			
		||||
	The optional build() function is use to compile and/or adjust the source
 | 
			
		||||
	files in preparation to be installed by the package() function. This is
 | 
			
		||||
	directly sourced and executed by makepkg, so anything that bash or the
 | 
			
		||||
	system has available is available for use here. Be sure any exotic
 | 
			
		||||
	commands used are covered by `makedepends`.
 | 
			
		||||
+
 | 
			
		||||
If you create any variables of your own in the build function, it is
 | 
			
		||||
recommended to use the bash `local` keyword to scope the variable to inside
 | 
			
		||||
the build function.
 | 
			
		||||
 | 
			
		||||
*check() Function*::
 | 
			
		||||
	An optional check() function can be specified in which a package's
 | 
			
		||||
	test-suite may be run. This function is run between the build() and
 | 
			
		||||
	package() functions. Be sure any exotic commands used are covered by
 | 
			
		||||
	`checkdepends`.
 | 
			
		||||
 | 
			
		||||
All of the above variables such as `$pkgname` and `$pkgver` are available for use
 | 
			
		||||
in the build function. In addition, makepkg defines the following three
 | 
			
		||||
variables for use during the build and install process:
 | 
			
		||||
in the build function. In addition, makepkg defines the following variables for use
 | 
			
		||||
during the build and install process:
 | 
			
		||||
 | 
			
		||||
*srcdir*::
 | 
			
		||||
       This contains the directory where makepkg extracts, or copies, all source
 | 
			
		||||
       files.
 | 
			
		||||
 | 
			
		||||
*pkgdir*::
 | 
			
		||||
       This contains the directory where makepkg bundles the installed package
 | 
			
		||||
       (this directory will become the root directory of your built package).
 | 
			
		||||
       This variable should only be used in the package() function.
 | 
			
		||||
 | 
			
		||||
*startdir*::
 | 
			
		||||
	This contains the absolute path to the directory where the PKGBUILD is
 | 
			
		||||
	located, which is usually the output of `$(pwd)` when makepkg is started.
 | 
			
		||||
	Use of this variable is deprecated and strongly discouraged.
 | 
			
		||||
 | 
			
		||||
*srcdir*::
 | 
			
		||||
	This contains the directory where makepkg extracts, or copies, all source
 | 
			
		||||
	files.
 | 
			
		||||
 | 
			
		||||
*pkgdir*::
 | 
			
		||||
	This contains the directory where makepkg bundles the installed package
 | 
			
		||||
	(this directory will become the root directory of your built package).
 | 
			
		||||
 | 
			
		||||
If you create any variables of your own in the build function, it is
 | 
			
		||||
recommended to use the bash `local` keyword to scope the variable to inside
 | 
			
		||||
the build function.
 | 
			
		||||
 | 
			
		||||
check() Function
 | 
			
		||||
----------------
 | 
			
		||||
An optional check() function can be specified in which a packages test-suite
 | 
			
		||||
may be run. This function is run between the build() and package() functions.
 | 
			
		||||
The function is run in `bash -e` mode, meaning any command that exits with a
 | 
			
		||||
non-zero status will cause the function to exit. Be sure any exotic commands
 | 
			
		||||
used are covered by `checkdepends`.
 | 
			
		||||
 | 
			
		||||
package() Function
 | 
			
		||||
------------------
 | 
			
		||||
An optional package() function can be specified in addition to the build()
 | 
			
		||||
function. This function is run after the build() and check() functions. The
 | 
			
		||||
function is run in `bash -e` mode, meaning any command that exits with a
 | 
			
		||||
non-zero status will cause the function to exit. When specified in combination
 | 
			
		||||
with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
 | 
			
		||||
will be limited to running the packaging stage. An existing build() function
 | 
			
		||||
will be run as the user calling makepkg.
 | 
			
		||||
 | 
			
		||||
Package Splitting
 | 
			
		||||
-----------------
 | 
			
		||||
makepkg supports building multiple packages from a single PKGBUILD. This is
 | 
			
		||||
@@ -322,9 +354,9 @@ Each split package uses a corresponding packaging function with name
 | 
			
		||||
All options and directives for the split packages default to the global values
 | 
			
		||||
given in the PKGBUILD. Nevertheless, the following ones can be overridden within
 | 
			
		||||
each split package's packaging function:
 | 
			
		||||
`pkgver`, `pkgrel`, `epoch`, `pkgdesc`, `arch`, `license`, `groups`, `depends`,
 | 
			
		||||
`optdepends`, `provides`, `conflicts`, `replaces`, `backup`, `options`,
 | 
			
		||||
`install` and `changelog`.
 | 
			
		||||
`pkgver`, `pkgrel`, `epoch`, `pkgdesc`, `arch`, `url`, `license`, `groups`,
 | 
			
		||||
`depends`, `optdepends`, `provides`, `conflicts`, `replaces`, `backup`,
 | 
			
		||||
`options`, `install` and `changelog`.
 | 
			
		||||
 | 
			
		||||
An optional global directive is available when building a split package:
 | 
			
		||||
 | 
			
		||||
@@ -381,69 +413,43 @@ The install script does not need to be specified in the source array. A
 | 
			
		||||
template install file is available in '{pkgdatadir}' as 'proto.install' for
 | 
			
		||||
reference with all of the available functions defined.
 | 
			
		||||
 | 
			
		||||
Using VCS Sources[[VCS]]
 | 
			
		||||
------------------------
 | 
			
		||||
Building a developmental version of a package using sources from a version control
 | 
			
		||||
system (VCS) is enabled by specifying the source in the form
 | 
			
		||||
`source=('folder::url#fragment')`. Currently makepkg supports the `bzr`, `git`, `hg` and
 | 
			
		||||
`svn` protocols.
 | 
			
		||||
 | 
			
		||||
Development Directives
 | 
			
		||||
----------------------
 | 
			
		||||
makepkg supports building development versions of packages without having to
 | 
			
		||||
manually update the pkgver in the PKGBUILD. This was formerly done using the
 | 
			
		||||
separate utility 'versionpkg'. In order to utilize this functionality, your
 | 
			
		||||
PKGBUILD must use correct variable names depending on the SCM being fetched
 | 
			
		||||
from (e.g., 'makepkg-git', 'mplayer-svn').
 | 
			
		||||
The source URL is divided into three components:
 | 
			
		||||
 | 
			
		||||
*CVS*::
 | 
			
		||||
	The generated pkgver will be the date the package is built.
 | 
			
		||||
*folder*::
 | 
			
		||||
	(optional) Specifies an alternate folder name for makepkg to download the VCS
 | 
			
		||||
	source into.
 | 
			
		||||
 | 
			
		||||
	*_cvsroot*;;
 | 
			
		||||
		The root of the CVS repository.
 | 
			
		||||
*url*::
 | 
			
		||||
	The url to the VCS repo. This must include the the vcs in the URL protocol for
 | 
			
		||||
	makepkg to recognize this as a VCS source.  If the protocol does not include
 | 
			
		||||
	the VCS name, it can be added by prefixing the URL with `vcs+`. For example,
 | 
			
		||||
	using a git repository over `http` would have a source URL in the form
 | 
			
		||||
	`git+http://...`.
 | 
			
		||||
 | 
			
		||||
	*_cvsmod*;;
 | 
			
		||||
		The CVS module to fetch.
 | 
			
		||||
*fragment*::
 | 
			
		||||
	(optional) Allows specifying a revision number or branch for makepkg to checkout
 | 
			
		||||
	from the VCS. For example, to checkout a given revision, the source line would
 | 
			
		||||
	have the format `source=(url#revision=123)`. The available fragments depends on
 | 
			
		||||
	the VCS being used:
 | 
			
		||||
 | 
			
		||||
*SVN*::
 | 
			
		||||
	The generated pkgver will be the latest SVN revision number.
 | 
			
		||||
	*bzr*;;
 | 
			
		||||
		revision (see `'bzr help revisionspec'` for details)
 | 
			
		||||
 | 
			
		||||
	*_svntrunk*;;
 | 
			
		||||
		The trunk of the SVN repository.
 | 
			
		||||
	*git*;;
 | 
			
		||||
		branch, commit, tag
 | 
			
		||||
 | 
			
		||||
	*_svnmod*;;
 | 
			
		||||
		The SVN module to fetch.
 | 
			
		||||
 | 
			
		||||
*Git*::
 | 
			
		||||
	The generated pkgver will be the date the package is built.
 | 
			
		||||
 | 
			
		||||
	*_gitroot*;;
 | 
			
		||||
		The URL (all protocols supported) to the GIT repository.
 | 
			
		||||
 | 
			
		||||
	*_gitname*;;
 | 
			
		||||
		GIT tag or branch to use.
 | 
			
		||||
 | 
			
		||||
*Mercurial*::
 | 
			
		||||
	The generated pkgver will be the hg tip revision number.
 | 
			
		||||
 | 
			
		||||
	*_hgroot*;;
 | 
			
		||||
		The URL of the mercurial repository.
 | 
			
		||||
 | 
			
		||||
	*_hgrepo*;;
 | 
			
		||||
		The repository to follow.
 | 
			
		||||
 | 
			
		||||
*Darcs*::
 | 
			
		||||
	The generated pkgver will be the date the package is built.
 | 
			
		||||
 | 
			
		||||
	*_darcstrunk*;;
 | 
			
		||||
		URL to the repository trunk.
 | 
			
		||||
 | 
			
		||||
	*_darcsmod*;;
 | 
			
		||||
		Darcs module to use.
 | 
			
		||||
 | 
			
		||||
*Bazaar*::
 | 
			
		||||
	The generated pkgver will be the latest Bazaar revision number (revno).
 | 
			
		||||
 | 
			
		||||
	*_bzrtrunk*;;
 | 
			
		||||
		URL to the bazaar repository.
 | 
			
		||||
 | 
			
		||||
	*_bzrmod*;;
 | 
			
		||||
		Bazaar module to use.
 | 
			
		||||
	*hg*;;
 | 
			
		||||
		branch, revision, tag
 | 
			
		||||
 | 
			
		||||
	*svn*;;
 | 
			
		||||
		revision
 | 
			
		||||
 | 
			
		||||
Example
 | 
			
		||||
-------
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
 | 
			
		||||
/////
 | 
			
		||||
 | 
			
		||||
See the pacman website at http://www.archlinux.org/pacman/[] for current
 | 
			
		||||
See the pacman website at https://www.archlinux.org/pacman/[] for current
 | 
			
		||||
information on pacman and its related tools.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -53,11 +53,11 @@ configuration files dealing with pacman.
 | 
			
		||||
Changelog
 | 
			
		||||
~~~~~~~~~
 | 
			
		||||
For a good idea of what is going on in pacman development, take a look at the
 | 
			
		||||
link:http://projects.archlinux.org/pacman.git/[Git summary page] for the
 | 
			
		||||
link:https://projects.archlinux.org/pacman.git/[Git summary page] for the
 | 
			
		||||
project.
 | 
			
		||||
 | 
			
		||||
See the most recent
 | 
			
		||||
link:http://projects.archlinux.org/pacman.git/tree/NEWS[NEWS]
 | 
			
		||||
link:https://projects.archlinux.org/pacman.git/tree/NEWS[NEWS]
 | 
			
		||||
file for a not-as-frequently-updated list of changes. However, this should
 | 
			
		||||
contain the biggest changes in a format more concise than the commit log.
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +71,12 @@ Releases
 | 
			
		||||
[frame="topbot",grid="none",options="header,autowidth"]
 | 
			
		||||
!======
 | 
			
		||||
!Version !Date
 | 
			
		||||
!4.0.0 !2011-09-13
 | 
			
		||||
!4.1.0  !2013-04-01
 | 
			
		||||
!4.1.0rc1 !2013-03-09
 | 
			
		||||
!4.0.3 !2012-04-07
 | 
			
		||||
!4.0.2 !2012-02-11
 | 
			
		||||
!4.0.1 !2011-11-20
 | 
			
		||||
!4.0.0 !2011-10-13
 | 
			
		||||
!4.0.0rc2 !2011-09-22
 | 
			
		||||
!4.0.0rc1 !2011-08-11
 | 
			
		||||
!3.5.4 !2011-08-10
 | 
			
		||||
@@ -94,12 +99,19 @@ Releases
 | 
			
		||||
!3.1.3 !2008-03-06
 | 
			
		||||
!3.1.2 !2008-02-20
 | 
			
		||||
!3.1.1 !2008-01-20
 | 
			
		||||
!3.1.0 !2008-01-09
 | 
			
		||||
!======
 | 
			
		||||
|
 | 
			
		||||
[frame="topbot",grid="none",options="header,autowidth"]
 | 
			
		||||
!======
 | 
			
		||||
!Version !Date
 | 
			
		||||
!3.1.0 !2008-01-09
 | 
			
		||||
!3.0.6 !2007-09-16
 | 
			
		||||
!3.0.5 !2007-06-17
 | 
			
		||||
!3.0.4 !2007-05-08
 | 
			
		||||
!3.0.3 !2007-04-28
 | 
			
		||||
!3.0.2 !2007-04-23
 | 
			
		||||
!3.0.1 !2007-04-04
 | 
			
		||||
!3.0.0 !2007-03-25
 | 
			
		||||
!2.9.8 !2006-02-02
 | 
			
		||||
!2.9.7 !2005-09-16
 | 
			
		||||
!2.9.7-TEST3 !2005-09-11
 | 
			
		||||
@@ -120,15 +132,15 @@ Releases
 | 
			
		||||
!2.7.9 !2004-04-30
 | 
			
		||||
!2.7.8 !2004-04-29
 | 
			
		||||
!2.7.7 !2004-04-15
 | 
			
		||||
!2.7.6 !2004-04-04
 | 
			
		||||
!2.7.5 !2004-03-02
 | 
			
		||||
!2.7.4 !2004-02-18
 | 
			
		||||
!2.7.3 !2004-02-07
 | 
			
		||||
!======
 | 
			
		||||
|
 | 
			
		||||
[frame="topbot",grid="none",options="header,autowidth"]
 | 
			
		||||
!======
 | 
			
		||||
!Version !Date
 | 
			
		||||
!2.7.6 !2004-04-04
 | 
			
		||||
!2.7.5 !2004-03-02
 | 
			
		||||
!2.7.4 !2004-02-18
 | 
			
		||||
!2.7.3 !2004-02-07
 | 
			
		||||
!2.7.2 !2004-01-04
 | 
			
		||||
!2.7.1 !2003-12-21
 | 
			
		||||
!2.7 !2003-11-25
 | 
			
		||||
@@ -175,8 +187,8 @@ Development
 | 
			
		||||
Mailing List
 | 
			
		||||
~~~~~~~~~~~~
 | 
			
		||||
There is a mailing list devoted to pacman development, hosted by Arch Linux.
 | 
			
		||||
link:http://mailman.archlinux.org/mailman/listinfo/pacman-dev/[Subscribe] or
 | 
			
		||||
link:http://mailman.archlinux.org/pipermail/pacman-dev/[view the archives].
 | 
			
		||||
link:https://mailman.archlinux.org/mailman/listinfo/pacman-dev/[Subscribe] or
 | 
			
		||||
link:https://mailman.archlinux.org/pipermail/pacman-dev/[view the archives].
 | 
			
		||||
 | 
			
		||||
Source Code
 | 
			
		||||
~~~~~~~~~~~
 | 
			
		||||
@@ -191,7 +203,7 @@ The current development tree can be fetched with the following command:
 | 
			
		||||
 | 
			
		||||
which will fetch the full development history into a directory named pacman.
 | 
			
		||||
You can browse the source as well using
 | 
			
		||||
link:http://projects.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also
 | 
			
		||||
link:https://projects.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also
 | 
			
		||||
available for cloning purposes; these URLs are listed at the above page.
 | 
			
		||||
 | 
			
		||||
If you are interested in hacking on pacman, it is highly recommended you join
 | 
			
		||||
@@ -208,17 +220,17 @@ Other Utilities
 | 
			
		||||
~~~~~~~~~~~~~~~
 | 
			
		||||
Although the package manager itself is quite simple, many scripts have been
 | 
			
		||||
developed that help automate building and installing packages. These are used
 | 
			
		||||
extensively in link:http://archlinux.org/[Arch Linux]. Most of these utilities
 | 
			
		||||
extensively in link:https://www.archlinux.org/[Arch Linux]. Most of these utilities
 | 
			
		||||
are available in the Arch Linux projects
 | 
			
		||||
link:http://projects.archlinux.org/[code browser].
 | 
			
		||||
link:https://projects.archlinux.org/[code browser].
 | 
			
		||||
 | 
			
		||||
Utilities available:
 | 
			
		||||
 | 
			
		||||
* link:http://projects.archlinux.org/abs.git/[abs] - ABS (Arch Build System), scripts to download  & use the Arch Linux PKGBUILD tree
 | 
			
		||||
* link:http://projects.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories
 | 
			
		||||
* link:http://projects.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking
 | 
			
		||||
* link:http://projects.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python
 | 
			
		||||
* link:http://projects.archlinux.org/srcpac.git/[srcpac] - a bash build-from-source pacman wrapper
 | 
			
		||||
* link:https://projects.archlinux.org/abs.git/[abs] - ABS (Arch Build System), scripts to download & use the Arch Linux PKGBUILD tree
 | 
			
		||||
* link:https://projects.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories
 | 
			
		||||
* link:https://projects.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking
 | 
			
		||||
* link:https://projects.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python
 | 
			
		||||
* link:https://projects.archlinux.org/srcpac.git/[srcpac] - a bash build-from-source pacman wrapper
 | 
			
		||||
 | 
			
		||||
Bugs
 | 
			
		||||
----
 | 
			
		||||
@@ -228,34 +240,12 @@ such as your commandline, the nature of the bug, and even the package database
 | 
			
		||||
if it helps.
 | 
			
		||||
 | 
			
		||||
You can also post a bug to the Arch Linux bug tracker
 | 
			
		||||
link:http://bugs.archlinux.org/index.php?project=3[Flyspray]. Be sure to file
 | 
			
		||||
link:https://bugs.archlinux.org/index.php?project=3[Flyspray]. Be sure to file
 | 
			
		||||
bugs under the Pacman project.
 | 
			
		||||
 | 
			
		||||
Pacman/libalpm in the Wild
 | 
			
		||||
--------------------------
 | 
			
		||||
Although Arch Linux is the primary user of pacman and libalpm, other
 | 
			
		||||
distributions and projects also use pacman as a package management tool. In
 | 
			
		||||
addition, there have been several projects started to provide a frontend GUI to
 | 
			
		||||
pacman and/or libalpm.
 | 
			
		||||
 | 
			
		||||
Arch derivatives:
 | 
			
		||||
 | 
			
		||||
* link:http://archie.dotsrc.org/[Archie] - Arch Live on steroids
 | 
			
		||||
* link:http://www.faunos.com/[FaunOS] - A portable, fully integrated operating system based on Arch Linux
 | 
			
		||||
* link:http://larch.berlios.de/[larch] - A live CD/DVD/USB-stick construction kit for Arch Linux
 | 
			
		||||
 | 
			
		||||
Other distributions:
 | 
			
		||||
 | 
			
		||||
* link:http://www.delilinux.org/[DeLi Linux] - "Desktop Light" Linux, a Linux distribution for old computers
 | 
			
		||||
* link:http://www.frugalware.org/[Frugalware Linux] - A general purpose Linux distribution for intermediate users (pacman is forked and maintained separately)
 | 
			
		||||
 | 
			
		||||
Pacman/libalpm frontends:
 | 
			
		||||
 | 
			
		||||
* link:http://shaman.iskrembilen.com/[Shaman] - A GUI frontend using Qt and libalpm
 | 
			
		||||
 | 
			
		||||
Copyright
 | 
			
		||||
---------
 | 
			
		||||
pacman is Copyright (C) 2006-2011 Pacman Development Team
 | 
			
		||||
pacman is Copyright (C) 2006-2013 Pacman Development Team
 | 
			
		||||
<pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet
 | 
			
		||||
<jvinet@zeroflux.org> and is licensed through the GNU General Public License,
 | 
			
		||||
version 2 or later.
 | 
			
		||||
 
 | 
			
		||||
@@ -59,11 +59,16 @@ Options
 | 
			
		||||
	installed.
 | 
			
		||||
 | 
			
		||||
*-e, \--noextract*::
 | 
			
		||||
	Do not extract source files; use whatever source already exists in the
 | 
			
		||||
	src/ directory. This is handy if you want to go into src/ and manually
 | 
			
		||||
	patch or tweak code, then make a package out of the result. Keep in mind
 | 
			
		||||
	that creating a patch may be a better solution to allow others to use
 | 
			
		||||
	your PKGBUILD.
 | 
			
		||||
	Do not extract source files or run the prepare() function (if present);
 | 
			
		||||
	use whatever source already exists in the $srcdir/ directory. This is
 | 
			
		||||
	handy if you want to go into $srcdir/ and manually patch or tweak code,
 | 
			
		||||
	then make a package out of the result. Keep in mind that creating a
 | 
			
		||||
	patch may be a better solution to allow others to use your PKGBUILD.
 | 
			
		||||
 | 
			
		||||
*\--verifysource*::
 | 
			
		||||
	For each source file in the source array of PKGBUILD, download the file
 | 
			
		||||
	if required and perform the integrity checks. No extraction or build is
 | 
			
		||||
	performed. Useful for performing subsequent offline builds.
 | 
			
		||||
 | 
			
		||||
*-f, \--force*::
 | 
			
		||||
	makepkg will not build a package if a built package already exists in
 | 
			
		||||
@@ -71,11 +76,6 @@ Options
 | 
			
		||||
	default to the current directory. This allows the built package to be
 | 
			
		||||
	overwritten.
 | 
			
		||||
 | 
			
		||||
*--forcever*::
 | 
			
		||||
	This is a hidden option that should *not* be used unless you really know
 | 
			
		||||
	what you are doing. makepkg uses this internally when calling itself to
 | 
			
		||||
	set the new development pkgver of the package.
 | 
			
		||||
 | 
			
		||||
*-g, \--geninteg*::
 | 
			
		||||
	For each source file in the source array of PKGBUILD, download the file
 | 
			
		||||
	if required and generate integrity checks. The integrity checks generated
 | 
			
		||||
@@ -96,10 +96,9 @@ Options
 | 
			
		||||
*-h, \--help*::
 | 
			
		||||
	Output syntax and command line options.
 | 
			
		||||
 | 
			
		||||
*\--holdver*::
 | 
			
		||||
	Useful when building development versions of packages. Prevents makepkg
 | 
			
		||||
	from automatically bumping the pkgver to the latest revision number in
 | 
			
		||||
	the package's development tree.
 | 
			
		||||
*--holdver*::
 | 
			
		||||
	When using VCS sources (linkman:PKGBUILD[5]) any currently checked out source
 | 
			
		||||
	will not be updated to the latest revision.
 | 
			
		||||
 | 
			
		||||
*-i, \--install*::
 | 
			
		||||
	Install or upgrade the package after a successful build using
 | 
			
		||||
@@ -116,9 +115,9 @@ Options
 | 
			
		||||
	Disable color in output messages.
 | 
			
		||||
 | 
			
		||||
*-o, \--nobuild*::
 | 
			
		||||
	Download and extract files only, but do not build them. Useful with the
 | 
			
		||||
	'\--noextract' option if you wish to tweak the files in src/ before
 | 
			
		||||
	building.
 | 
			
		||||
	Download and extract files, run the prepare() function, but do not build
 | 
			
		||||
	them. Useful with the '\--noextract' option if you wish to tweak the files
 | 
			
		||||
	in $srcdir/ before building.
 | 
			
		||||
 | 
			
		||||
*-p* <buildscript>::
 | 
			
		||||
	Read the package script `buildscript` instead of the `PKGBUILD` default;
 | 
			
		||||
@@ -152,8 +151,9 @@ Options
 | 
			
		||||
	such as a chroot or remote builder. It will also satisfy requirements of
 | 
			
		||||
	the GPL when distributing binary packages.
 | 
			
		||||
 | 
			
		||||
*\--pkg <list>*::
 | 
			
		||||
	Only build listed packages from a split package.
 | 
			
		||||
*\--pkg* <list>::
 | 
			
		||||
	Only build listed packages from a split package. Multiple packages should
 | 
			
		||||
	be comma separated in the list. This option can be specified multiple times.
 | 
			
		||||
 | 
			
		||||
*\--check*::
 | 
			
		||||
	Run the check() function in the PKGBUILD, overriding the setting in
 | 
			
		||||
@@ -178,6 +178,14 @@ Options
 | 
			
		||||
	(Passed to pacman) Prevent pacman from waiting for user input before
 | 
			
		||||
	proceeding with operations.
 | 
			
		||||
 | 
			
		||||
*\--needed*::
 | 
			
		||||
	(Passed to pacman) Tell pacman not to reinstall a target if it is already
 | 
			
		||||
	up to date. (used with -i / --install).
 | 
			
		||||
 | 
			
		||||
*\--asdeps*::
 | 
			
		||||
	(Passed to pacman) Install packages as non-explicitly installed (used
 | 
			
		||||
	with -i / --install).
 | 
			
		||||
 | 
			
		||||
*\--noprogressbar*::
 | 
			
		||||
	(Passed to pacman) Prevent pacman from displaying a progress bar;
 | 
			
		||||
	useful if you are redirecting makepkg output to file.
 | 
			
		||||
@@ -207,6 +215,10 @@ Environment Variables
 | 
			
		||||
	Folder where the downloaded sources will be stored. Overrides the
 | 
			
		||||
	corresponding value defined in linkman:makepkg.conf[5].
 | 
			
		||||
 | 
			
		||||
**PACKAGER=**"John Doe <john@doe.com>"::
 | 
			
		||||
	String to identify the creator of the resulting package. Overrides
 | 
			
		||||
	the corresponding value defined in linkman:makepkg.conf[5].
 | 
			
		||||
 | 
			
		||||
**BUILDDIR=**"/path/to/folder"::
 | 
			
		||||
	Folder where the package will be built. Overrides the corresponding
 | 
			
		||||
	value defined in linkman:makepkg.conf[5].
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,10 @@ build environment.
 | 
			
		||||
NOTE: This does not guarantee that all package Makefiles will use your exported
 | 
			
		||||
variables. Some of them are non-standard.
 | 
			
		||||
 | 
			
		||||
The system-wide configuration file is found in {sysconfdir}/makepkg.conf.
 | 
			
		||||
Individual options can be overridden (or added to) on a per user basis in
 | 
			
		||||
~/.makepkg.conf.
 | 
			
		||||
 | 
			
		||||
The default file is fairly well commented, so it may be easiest to simply
 | 
			
		||||
follow directions given there for customization.
 | 
			
		||||
 | 
			
		||||
@@ -51,6 +55,9 @@ Options
 | 
			
		||||
	A string such as ``i686-pc-linux-gnu'', do not touch unless you know what
 | 
			
		||||
	you are doing. This can be commented out by most users if desired.
 | 
			
		||||
 | 
			
		||||
**CPPFLAGS=**"cppflags"::
 | 
			
		||||
	Flags used for the C preprocessor; see CFLAGS for more info.
 | 
			
		||||
 | 
			
		||||
**CFLAGS=**"cflags"::
 | 
			
		||||
	Flags used for the C compiler. This is a key part to the use of makepkg.
 | 
			
		||||
	Usually several options are specified, and the most common string resembles
 | 
			
		||||
@@ -70,11 +77,20 @@ Options
 | 
			
		||||
	This is often used to set the number of jobs used, for example, `-j2`.
 | 
			
		||||
	Other flags that make accepts can also be passed.
 | 
			
		||||
 | 
			
		||||
**DEBUG_CFLAGS=**"debug_cflags"::
 | 
			
		||||
	Additional compiler flags appended to CFLAGS for use in debugging. Usually
 | 
			
		||||
	this would include: ``-g''. Read gcc(1) for more details on the wide
 | 
			
		||||
	variety of compiler flags available.
 | 
			
		||||
 | 
			
		||||
**DEBUG_CXXFLAGS=**"debug_cxxflags"::
 | 
			
		||||
	Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info.
 | 
			
		||||
 | 
			
		||||
**BUILDENV=(**fakeroot !distcc color !ccache check !sign**)**::
 | 
			
		||||
	This array contains options that affect the build environment, the defaults
 | 
			
		||||
	are shown here. All options should always be left in the array; to enable
 | 
			
		||||
	or disable an option simply remove or place an ``!'' at the front of the
 | 
			
		||||
	option. Each works as follows:
 | 
			
		||||
	option. If an option is specified multiple times, the final value takes
 | 
			
		||||
	precedence. Each option works as follows:
 | 
			
		||||
 | 
			
		||||
	*fakeroot*;;
 | 
			
		||||
		Allow building packages as a non-root user. This is highly recommended.
 | 
			
		||||
@@ -122,12 +138,13 @@ Options
 | 
			
		||||
	Specify a key to use for gpg signing instead of the default key in the
 | 
			
		||||
	keyring. Can be overridden with makepkg's '\--key' option.
 | 
			
		||||
 | 
			
		||||
**OPTIONS=(**strip docs libtool emptydirs zipman purge !upx**)**::
 | 
			
		||||
**OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx**)**::
 | 
			
		||||
	This array contains options that affect the default packaging. They are
 | 
			
		||||
	equivalent to options that can be placed in the PKGBUILD; the defaults are
 | 
			
		||||
	shown here. All options should always be left in the array; to enable or
 | 
			
		||||
	disable an option simply remove or place an ``!'' at the front of the
 | 
			
		||||
	option. Each works as follows:
 | 
			
		||||
	option. If an option is specified multiple times, the final value takes
 | 
			
		||||
	precedence. Each option works as follows:
 | 
			
		||||
 | 
			
		||||
	*strip*;;
 | 
			
		||||
		Strip symbols from binaries and libraries. If you frequently use a
 | 
			
		||||
@@ -143,6 +160,10 @@ Options
 | 
			
		||||
		Leave libtool (.la) files in packages. Specify `!libtool` to remove
 | 
			
		||||
		them.
 | 
			
		||||
 | 
			
		||||
	*staticlibs*;;
 | 
			
		||||
		Leave static library (.a) files in packages. Specify `!staticlibs` to
 | 
			
		||||
		remove them.
 | 
			
		||||
 | 
			
		||||
	*emptydirs*;;
 | 
			
		||||
		Leave empty directories in packages.
 | 
			
		||||
 | 
			
		||||
@@ -158,6 +179,11 @@ Options
 | 
			
		||||
		Compress binary executable files using UPX.  Additional options
 | 
			
		||||
		can be passed to UPX by specifying the `UPXFLAGS` variable.
 | 
			
		||||
 | 
			
		||||
	*debug*;;
 | 
			
		||||
		Add the user-specified debug flags as specified in DEBUG_CFLAGS and
 | 
			
		||||
		DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
 | 
			
		||||
		package containing the debug symbols with used with `strip'.
 | 
			
		||||
 | 
			
		||||
**INTEGRITY_CHECK=(**check1 ...**)**::
 | 
			
		||||
	File integrity checks to use. Multiple checks may be specified; this
 | 
			
		||||
	affects both generation and checking. The current valid options are:
 | 
			
		||||
@@ -209,14 +235,28 @@ Options
 | 
			
		||||
	in the current directory. Many people like to keep all source package files
 | 
			
		||||
	in a central location for easy cleanup, so this path can be set here.
 | 
			
		||||
 | 
			
		||||
**LOGDEST=**"/path/to/folder"::
 | 
			
		||||
	If this value is not set, log files are written to the current
 | 
			
		||||
	directory. This centralizes the log location, facilitating cleanup
 | 
			
		||||
	and compression.
 | 
			
		||||
 | 
			
		||||
**PACKAGER=**"John Doe <john@example.com>"::
 | 
			
		||||
	This value is used when querying a package to see who was the builder.
 | 
			
		||||
	It is recommended you change this to your name and email address.
 | 
			
		||||
 | 
			
		||||
**COMPRESSGZ=**"(gzip -c -f -n)"::
 | 
			
		||||
**COMPRESSBZ2=**"(bzip2 -c -f)"::
 | 
			
		||||
**COMPRESSXZ=**"(xz -c -z -)"::
 | 
			
		||||
**COMPRESSLZO**"(lzop -q)"::
 | 
			
		||||
**COMPRESSLRZ=**"(lrzip -q)"::
 | 
			
		||||
**COMPRESSZ=**"(compress -c -f)"::
 | 
			
		||||
	Sets the command and options used when compressing compiled or source
 | 
			
		||||
	packages in the named format.
 | 
			
		||||
 | 
			
		||||
**PKGEXT=**".pkg.tar.gz", **SRCEXT=**".src.tar.gz"::
 | 
			
		||||
	Sets the compression used when making compiled or source packages. The
 | 
			
		||||
	current valid suffixes are `.tar`, `.tar.gz`, `.tar,bz2`, `.tar.xz`, and
 | 
			
		||||
	`.tar.Z`.
 | 
			
		||||
	current valid suffixes are `.tar`, `.tar.gz`, `.tar.bz2`, `.tar.xz`,
 | 
			
		||||
	`.tar.lzo`, `.tar.lrz` and `.tar.Z`.
 | 
			
		||||
	Do not touch these unless you know what you are doing.
 | 
			
		||||
 | 
			
		||||
See Also
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ pacman-key - manage pacman's list of trusted keys
 | 
			
		||||
 | 
			
		||||
Synopsis
 | 
			
		||||
--------
 | 
			
		||||
'pacman-key' [options]
 | 
			
		||||
'pacman-key' [options] operation [targets]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Description
 | 
			
		||||
@@ -26,45 +26,40 @@ More complex keyring management can be achieved using GnuPG directly combined wi
 | 
			
		||||
the '\--homedir' option pointing at the pacman keyring (located in
 | 
			
		||||
+{sysconfdir}/pacman.d/gnupg+ by default).
 | 
			
		||||
 | 
			
		||||
Invoking pacman-key consists of supplying an operation with any potential
 | 
			
		||||
options and targets to operate on. Depending on the operation, a 'target' may
 | 
			
		||||
be a valid key identifier, filename, or directory.
 | 
			
		||||
 | 
			
		||||
Options
 | 
			
		||||
-------
 | 
			
		||||
*-a, \--add* [file(s)]::
 | 
			
		||||
Operations
 | 
			
		||||
----------
 | 
			
		||||
*-a, \--add*::
 | 
			
		||||
	Add the key(s) contained in the specified file or files to pacman's
 | 
			
		||||
	keyring. If a key already exists, update it.
 | 
			
		||||
 | 
			
		||||
*\--config* <file>::
 | 
			
		||||
	Use an alternate config file instead of the +{sysconfdir}/pacman.conf+
 | 
			
		||||
	default.
 | 
			
		||||
 | 
			
		||||
*-d, \--delete* <keyid(s)>::
 | 
			
		||||
*-d, \--delete*::
 | 
			
		||||
	Remove the key(s) identified by the specified keyid(s) from pacman's
 | 
			
		||||
	keyring.
 | 
			
		||||
 | 
			
		||||
*-e, \--export* [keyid(s)]::
 | 
			
		||||
*-e, \--export*::
 | 
			
		||||
	Export key(s) identified by the specified keyid(s) to 'stdout'. If no keyid
 | 
			
		||||
	is specified, all keys will be exported.
 | 
			
		||||
 | 
			
		||||
*\--edit-key* <keyid(s)>::
 | 
			
		||||
*\--edit-key*::
 | 
			
		||||
	Present a menu for key management task on the specified keyid(s). Useful
 | 
			
		||||
	for adjusting a keys trust level.
 | 
			
		||||
 | 
			
		||||
*-f, \--finger* [keyid(s)]::
 | 
			
		||||
*-f, \--finger*::
 | 
			
		||||
	List a fingerprint for each specified keyid, or for all known keys if no
 | 
			
		||||
	keyids are specified.
 | 
			
		||||
 | 
			
		||||
*\--gpgdir* <dir>::
 | 
			
		||||
	Set an alternate home directory for GnuPG. If unspecified, the value is
 | 
			
		||||
	read from +{sysconfdir}/pacman.conf+.
 | 
			
		||||
 | 
			
		||||
*-h, \--help*::
 | 
			
		||||
	Output syntax and command line options.
 | 
			
		||||
 | 
			
		||||
*\--import* <dir(s)>::
 | 
			
		||||
*\--import*::
 | 
			
		||||
	Imports keys from `pubring.gpg` into the public keyring from the specified
 | 
			
		||||
	directories.
 | 
			
		||||
 | 
			
		||||
*\--import-trustdb* <dir(s)> ::
 | 
			
		||||
*\--import-trustdb*::
 | 
			
		||||
	Imports ownertrust values from `trustdb.gpg` into the shared trust database
 | 
			
		||||
	from the specified directories.
 | 
			
		||||
 | 
			
		||||
@@ -72,45 +67,59 @@ Options
 | 
			
		||||
	Ensure the keyring is properly initialized and has the required access
 | 
			
		||||
	permissions.
 | 
			
		||||
 | 
			
		||||
*-l, \--list-keys*::
 | 
			
		||||
	Lists all or specified keys from the public keyring.
 | 
			
		||||
 | 
			
		||||
*\--list-sigs*::
 | 
			
		||||
	Same as '\--list-keys', but the signatures are listed too.
 | 
			
		||||
 | 
			
		||||
*\--lsign-key*::
 | 
			
		||||
	Locally sign the given key. This is primarily used to root the web of trust
 | 
			
		||||
	in the local private key generated by '\--init'.
 | 
			
		||||
 | 
			
		||||
*\--nocolor*::
 | 
			
		||||
	Disable colored output from pacman-key.
 | 
			
		||||
 | 
			
		||||
*-r, \--recv-keys*::
 | 
			
		||||
	Equivalent to '\--recv-keys' in GnuPG.
 | 
			
		||||
 | 
			
		||||
*\--refresh-keys*::
 | 
			
		||||
	Equivalent to '\--refresh-keys' in GnuPG.
 | 
			
		||||
 | 
			
		||||
*\--populate*::
 | 
			
		||||
	Reload the default keys from the (optionally provided) keyrings in
 | 
			
		||||
	+{pkgdatadir}/keyrings+. For more information, see
 | 
			
		||||
	<<PK,Providing a Keyring for Import>> below.
 | 
			
		||||
 | 
			
		||||
*-u, \--updatedb*::
 | 
			
		||||
	Equivalent to '\--check-trustdb' in GnuPG. This operation can be specified with
 | 
			
		||||
	other operations.
 | 
			
		||||
 | 
			
		||||
*-V, \--version*::
 | 
			
		||||
	Displays the program version.
 | 
			
		||||
 | 
			
		||||
*-v, \--verify*::
 | 
			
		||||
	Verify the file(s) specified by the signature(s).
 | 
			
		||||
 | 
			
		||||
Options
 | 
			
		||||
-------
 | 
			
		||||
*\--config* <file>::
 | 
			
		||||
	Use an alternate config file instead of the +{sysconfdir}/pacman.conf+
 | 
			
		||||
	default.
 | 
			
		||||
 | 
			
		||||
*\--gpgdir* <dir>::
 | 
			
		||||
	Set an alternate home directory for GnuPG. If unspecified, the value is
 | 
			
		||||
	read from +{sysconfdir}/pacman.conf+.
 | 
			
		||||
 | 
			
		||||
*\--keyserver* <keyserver>::
 | 
			
		||||
	Use the specified keyserver if the operation requires one. This will take
 | 
			
		||||
	precedence over any keyserver option specified in a `gpg.conf`
 | 
			
		||||
	configuration file. Running '\--init' with this option will set the default
 | 
			
		||||
	keyserver if one was not already configured.
 | 
			
		||||
 | 
			
		||||
*-l, \--list-keys* [keyid(s)]::
 | 
			
		||||
	Lists all or specified keys from the public keyring.
 | 
			
		||||
 | 
			
		||||
*\--list-sigs* [keyid(s)]::
 | 
			
		||||
	Same as '\--list-keys', but the signatures are listed too.
 | 
			
		||||
 | 
			
		||||
*\--lsign-key* <keyid>::
 | 
			
		||||
	Locally sign the given key. This is primarily used to root the web of trust
 | 
			
		||||
	in the local private key generated by '\--init'.
 | 
			
		||||
 | 
			
		||||
*-r, \--recv-keys* <keyid(s)>::
 | 
			
		||||
	Equivalent to '\--recv-keys' in GnuPG.
 | 
			
		||||
 | 
			
		||||
*\--refresh-keys* [keyid(s)]::
 | 
			
		||||
	Equivalent to '\--refresh-keys' in GnuPG.
 | 
			
		||||
 | 
			
		||||
*\--populate* [keyring(s)]::
 | 
			
		||||
	Reload the default keys from the (optionally provided) keyrings in
 | 
			
		||||
	+{pkgdatadir}/keyrings+. For more information, see
 | 
			
		||||
	<<SC,Providing a Keyring for Import>> below.
 | 
			
		||||
 | 
			
		||||
*-u, \--updatedb*::
 | 
			
		||||
	Equivalent to '\--check-trustdb' in GnuPG.
 | 
			
		||||
 | 
			
		||||
*-v, \--verify* <signature>::
 | 
			
		||||
	Verify the given signature file.
 | 
			
		||||
 | 
			
		||||
*-V, \--version*::
 | 
			
		||||
	Displays the program version.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Providing a Keyring for Import
 | 
			
		||||
------------------------------
 | 
			
		||||
Providing a Keyring for Import[[PK]]
 | 
			
		||||
------------------------------------
 | 
			
		||||
A distribution or other repository provided may want to provide a set of
 | 
			
		||||
PGP keys used in the signing of its packages and repository databases that can
 | 
			
		||||
be readily imported into the pacman keyring. This is achieved by providing a
 | 
			
		||||
@@ -129,11 +138,6 @@ any signing", so should be used with prudence. A key being marked as revoked
 | 
			
		||||
will be disabled in the keyring and no longer treated as valid, so this always
 | 
			
		||||
takes priority over it's trusted state in any other keyring.
 | 
			
		||||
 | 
			
		||||
All files are required to be signed (detached) by a trusted PGP key that the
 | 
			
		||||
user must manually import to the pacman keyring. This prevents a potentially
 | 
			
		||||
malicious repository adding keys to the pacman keyring without the users
 | 
			
		||||
knowledge.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
See Also
 | 
			
		||||
--------
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,8 @@ front ends to be written (for instance, a GUI front end).
 | 
			
		||||
Invoking pacman involves specifying an operation with any potential options and
 | 
			
		||||
targets to operate on. A 'target' is usually a package name, filename, URL, or
 | 
			
		||||
a search string. Targets can be provided as command line arguments.
 | 
			
		||||
Additionally, if a single dash (-) is passed as an argument, targets will be
 | 
			
		||||
read from stdin.
 | 
			
		||||
Additionally, if stdin is not from a terminal and a single dash (-) is passed
 | 
			
		||||
as an argument, targets will be read from stdin.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Operations
 | 
			
		||||
@@ -70,10 +70,10 @@ Operations
 | 
			
		||||
In addition to packages, groups can be specified as well. For example, if
 | 
			
		||||
gnome is a defined package group, then `pacman -S gnome` will provide a
 | 
			
		||||
prompt allowing you to select which packages to install from a numbered list.
 | 
			
		||||
The package selection is specified using a space separated list of package
 | 
			
		||||
numbers. Sequential packages may be selected by specifying the first and last
 | 
			
		||||
package numbers separated by a hyphen (`-`). Excluding packages is achieved by
 | 
			
		||||
prefixing a number or range of numbers with a caret (`^`).
 | 
			
		||||
The package selection is specified using a space and/or comma separated list of
 | 
			
		||||
package numbers. Sequential packages may be selected by specifying the first
 | 
			
		||||
and last package numbers separated by a hyphen (`-`). Excluding packages is
 | 
			
		||||
achieved by prefixing a number or range of numbers with a caret (`^`).
 | 
			
		||||
+
 | 
			
		||||
Packages that provide other packages are also handled. For example, `pacman -S
 | 
			
		||||
foo` will first look for a foo package. If foo is not found, packages that
 | 
			
		||||
@@ -146,6 +146,11 @@ Options
 | 
			
		||||
	and they are tried in the order they are passed to pacman. *NOTE*: this
 | 
			
		||||
	is an absolute path, the root path is not automatically prepended.
 | 
			
		||||
 | 
			
		||||
*\--color* <when>::
 | 
			
		||||
	Specify when to enable coloring, can be 'always', 'never' or 'auto'.  Always
 | 
			
		||||
	forces colours on, never forces colours off, and auto only automatically enables
 | 
			
		||||
	colours when outputting onto a tty.
 | 
			
		||||
 | 
			
		||||
*\--config* <file>::
 | 
			
		||||
	Specify an alternate configuration file.
 | 
			
		||||
 | 
			
		||||
@@ -201,10 +206,12 @@ Transaction Options (apply to '-S', '-R' and '-U')
 | 
			
		||||
 | 
			
		||||
Upgrade Options (apply to '-S' and '-U')[[UO]]
 | 
			
		||||
--------------------------------------------
 | 
			
		||||
*-f, \--force*::
 | 
			
		||||
*\--force*::
 | 
			
		||||
	Bypass file conflict checks and overwrite conflicting files. If the
 | 
			
		||||
	package that is about to be installed contains files that are already
 | 
			
		||||
	installed, this option will cause all those files to be overwritten.
 | 
			
		||||
	Using '--force' will not allow overwriting a directory with a file or
 | 
			
		||||
	installing packages with conflicting files and directories.
 | 
			
		||||
	This option should be used with care, ideally not at all.
 | 
			
		||||
 | 
			
		||||
*\--asdeps*::
 | 
			
		||||
@@ -232,13 +239,6 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
 | 
			
		||||
*\--needed*::
 | 
			
		||||
	Do not reinstall the targets that are already up to date.
 | 
			
		||||
 | 
			
		||||
*\--recursive*::
 | 
			
		||||
	Recursively reinstall all dependencies of the targets. This forces upgrades
 | 
			
		||||
	or reinstalls of all dependencies without requiring explicit version
 | 
			
		||||
	requirements. This is most useful in combination with the '\--needed' flag,
 | 
			
		||||
	which will induce a deep dependency upgrade without any unnecessary
 | 
			
		||||
	reinstalls.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Query Options[[QO]]
 | 
			
		||||
-------------------
 | 
			
		||||
@@ -269,7 +269,9 @@ Query Options[[QO]]
 | 
			
		||||
*-k \--check*::
 | 
			
		||||
	Check that all files owned by the given package(s) are present on the
 | 
			
		||||
	system. If packages are not specified or filter flags are not provided,
 | 
			
		||||
	check all installed packages.
 | 
			
		||||
	check all installed packages.  Specifying this option twice will perform
 | 
			
		||||
	more detailed file checking (including permissions, file sizes and
 | 
			
		||||
	modification times) for packages that contain the needed mtree file.
 | 
			
		||||
 | 
			
		||||
*-l, \--list*::
 | 
			
		||||
	List all files owned by a given package. Multiple packages can be
 | 
			
		||||
@@ -280,6 +282,10 @@ Query Options[[QO]]
 | 
			
		||||
	database(s).  Typically these are packages that were downloaded manually
 | 
			
		||||
	and installed with '\--upgrade'.
 | 
			
		||||
 | 
			
		||||
*-n, \--native*::
 | 
			
		||||
	Restrict or filter output to packages that are found in the sync
 | 
			
		||||
	database(s).  This is the inverse filter of '\--foreign'.
 | 
			
		||||
 | 
			
		||||
*-o, \--owns* <file>::
 | 
			
		||||
	Search for packages that own the specified file(s). The path can be
 | 
			
		||||
	relative or absolute and one or more files can be specified.
 | 
			
		||||
@@ -349,7 +355,7 @@ Sync Options[[SO]]
 | 
			
		||||
	databases are saved for every sync DB you download from, and are not
 | 
			
		||||
	deleted even if they are removed from the configuration file
 | 
			
		||||
	linkman:pacman.conf[5]. Use one '\--clean' switch to only remove
 | 
			
		||||
	packages that are no longer installed; use two to remove all packages
 | 
			
		||||
	packages that are no longer installed; use two to remove all files
 | 
			
		||||
	from the cache. In both cases, you will have a yes or no option to
 | 
			
		||||
	remove packages and/or unused downloaded databases.
 | 
			
		||||
+
 | 
			
		||||
@@ -408,16 +414,6 @@ system upgrade and install/upgrade the foo package in the same operation.
 | 
			
		||||
	will force a refresh of all package lists even if they appear to be up
 | 
			
		||||
	to date.
 | 
			
		||||
 | 
			
		||||
*\--needed*::
 | 
			
		||||
	Do not reinstall the targets that are already up to date.
 | 
			
		||||
 | 
			
		||||
*\--recursive*::
 | 
			
		||||
	Recursively reinstall all dependencies of the targets. This forces upgrades
 | 
			
		||||
	or reinstalls of all dependencies without requiring explicit version
 | 
			
		||||
	requirements. This is most useful in combination with the '\--needed' flag,
 | 
			
		||||
	which will induce a deep dependency upgrade without any unnecessary
 | 
			
		||||
	reinstalls.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Handling Config Files[[HCF]]
 | 
			
		||||
----------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -79,31 +79,24 @@ Options
 | 
			
		||||
	*NOTE*: this is an absolute path, the root path is not automatically
 | 
			
		||||
	prepended.
 | 
			
		||||
 | 
			
		||||
*LogFile =* '/path/to/file'::
 | 
			
		||||
*LogFile =* /path/to/file::
 | 
			
		||||
	Overrides the default location of the pacman log file. A typical default
 | 
			
		||||
	is +{localstatedir}/log/pacman.log+. This is an absolute path and the root directory
 | 
			
		||||
	is not prepended.
 | 
			
		||||
 | 
			
		||||
*HoldPkg =* package ...::
 | 
			
		||||
	If a user tries to '\--remove' a package that's listed in `HoldPkg`,
 | 
			
		||||
	pacman will ask for confirmation before proceeding.
 | 
			
		||||
	pacman will ask for confirmation before proceeding. Shell-style glob
 | 
			
		||||
	patterns are allowed.
 | 
			
		||||
 | 
			
		||||
*IgnorePkg =* package ...::
 | 
			
		||||
	Instructs pacman to ignore any upgrades for this package when performing
 | 
			
		||||
	a '\--sysupgrade'.
 | 
			
		||||
 | 
			
		||||
*SyncFirst =* package ...::
 | 
			
		||||
	Instructs pacman to check for newer version of these packages before any
 | 
			
		||||
	sync operation. The user will have the choice to either cancel the current
 | 
			
		||||
	operation and upgrade these packages first or go on with the current
 | 
			
		||||
	operation. This option is typically used with the 'pacman' package.
 | 
			
		||||
	*NOTE*: when a `SyncFirst` transaction takes place, no command line flags
 | 
			
		||||
	(e.g. '\--force') are honored. If this is not ideal, disabling `SyncFirst`
 | 
			
		||||
	and performing a manual sync of the involved packages may be required.
 | 
			
		||||
	a '\--sysupgrade'. Shell-style glob patterns are allowed.
 | 
			
		||||
 | 
			
		||||
*IgnoreGroup =* group ...::
 | 
			
		||||
	Instructs pacman to ignore any upgrades for all packages in this
 | 
			
		||||
	group when performing a '\--sysupgrade'.
 | 
			
		||||
	group when performing a '\--sysupgrade'. Shell-style glob patterns are
 | 
			
		||||
	allowed.
 | 
			
		||||
 | 
			
		||||
*Include =* path::
 | 
			
		||||
	Include another config file. This file can include repositories or
 | 
			
		||||
@@ -134,7 +127,8 @@ Options
 | 
			
		||||
	a package install/upgrade, and the new files will be installed with a
 | 
			
		||||
	'.pacnew' extension.
 | 
			
		||||
	These files refer to files in the package archive, so do not include the
 | 
			
		||||
	leading slash (the RootDir) when specifying them.
 | 
			
		||||
	leading slash (the RootDir) when specifying them. Shell-style glob patterns
 | 
			
		||||
	are allowed.
 | 
			
		||||
 | 
			
		||||
*NoExtract =* file ...::
 | 
			
		||||
	All files listed with a `NoExtract` directive will never be extracted from
 | 
			
		||||
@@ -143,7 +137,8 @@ Options
 | 
			
		||||
	'index.php', then you would not want the 'index.html' file to be extracted
 | 
			
		||||
	from the 'apache' package.
 | 
			
		||||
	These files refer to files in the package archive, so do not include the
 | 
			
		||||
	leading slash (the RootDir) when specifying them.
 | 
			
		||||
	leading slash (the RootDir) when specifying them. Shell-style glob patterns
 | 
			
		||||
	are allowed.
 | 
			
		||||
 | 
			
		||||
*CleanMethod =* KeepInstalled &| KeepCurrent::
 | 
			
		||||
	If set to `KeepInstalled` (the default), the '-Sc' operation will clean
 | 
			
		||||
@@ -160,13 +155,28 @@ Options
 | 
			
		||||
	Set the default signature verification level. For more information, see
 | 
			
		||||
	<<SC,Package and Database Signature Checking>> below.
 | 
			
		||||
 | 
			
		||||
*LocalFileSigLevel =* ...::
 | 
			
		||||
	Set the signature verification level for installing packages using the "-U"
 | 
			
		||||
	operation on a local file. Uses the value from SigLevel as the default.
 | 
			
		||||
 | 
			
		||||
*RemoteFileSigLevel =* ...::
 | 
			
		||||
	Set the signature verification level for installing  packages using the "-U"
 | 
			
		||||
	operation on a remote file URL. Uses the value from SigLevel as the default.
 | 
			
		||||
 | 
			
		||||
*UseSyslog*::
 | 
			
		||||
	Log action messages through syslog(). This will insert log entries into
 | 
			
		||||
	+{localstatedir}/log/messages+ or equivalent.
 | 
			
		||||
 | 
			
		||||
*UseDelta*::
 | 
			
		||||
	Download delta files instead of complete packages if possible.  Requires
 | 
			
		||||
	the xdelta3 program to be installed.
 | 
			
		||||
*Color*::
 | 
			
		||||
	Automatically enable colors only when pacman's output is on a tty.
 | 
			
		||||
 | 
			
		||||
*UseDelta* [= ratio]::
 | 
			
		||||
	Download delta files instead of complete packages if possible. Requires
 | 
			
		||||
	the `xdelta3` program to be installed. If a ratio is specified (e.g.,
 | 
			
		||||
	`0.5`), then it is used as a cutoff for determining whether to use deltas.
 | 
			
		||||
	Allowed values are between `0.0` and `2.0`; sensible values are between
 | 
			
		||||
	`0.2` and `0.9`.  Using a value above `1.0` is not recommended.  The
 | 
			
		||||
	default is `0.7` if left unspecified.
 | 
			
		||||
 | 
			
		||||
*TotalDownload*::
 | 
			
		||||
	When downloading, display the amount downloaded, download rate, ETA,
 | 
			
		||||
@@ -227,8 +237,8 @@ even be used for different architectures.
 | 
			
		||||
	Set the signature verification level for this repository. For more
 | 
			
		||||
	information, see <<SC,Package and Database Signature Checking>> below.
 | 
			
		||||
 | 
			
		||||
Package and Database Signature Checking
 | 
			
		||||
---------------------------------------
 | 
			
		||||
Package and Database Signature Checking[[SC]]
 | 
			
		||||
---------------------------------------------
 | 
			
		||||
The 'SigLevel' directive is valid in both the `[options]` and repository
 | 
			
		||||
sections. If used in `[options]`, it sets a default value for any repository
 | 
			
		||||
that does not provide the setting.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										66
									
								
								doc/pactree.8.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								doc/pactree.8.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
/////
 | 
			
		||||
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
 | 
			
		||||
/////
 | 
			
		||||
pactree(8)
 | 
			
		||||
=========
 | 
			
		||||
 | 
			
		||||
Name
 | 
			
		||||
----
 | 
			
		||||
pactree - package dependency tree viewer
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Synopsis
 | 
			
		||||
--------
 | 
			
		||||
'pactree' [options] package
 | 
			
		||||
 | 
			
		||||
Description
 | 
			
		||||
-----------
 | 
			
		||||
Pactree produces a dependency tree for a package.
 | 
			
		||||
 | 
			
		||||
By default a tree like output is generated, but with the -g option a graphviz
 | 
			
		||||
description is generated.
 | 
			
		||||
 | 
			
		||||
Options
 | 
			
		||||
-------
 | 
			
		||||
*-a, \--ascii*::
 | 
			
		||||
	Use ascii characters for tree formatting. By default, pactree will use unicode
 | 
			
		||||
	line drawing characters if it is able to detect that the locale supports them.
 | 
			
		||||
 | 
			
		||||
*-b, \--dbpath*::
 | 
			
		||||
	Specify an alternative database location.
 | 
			
		||||
 | 
			
		||||
*-c, \--color*::
 | 
			
		||||
	Colorize output.
 | 
			
		||||
 | 
			
		||||
*-d, \--depth <num>*::
 | 
			
		||||
	Limits the number of levels of dependency to show. A zero means
 | 
			
		||||
	show the named package only, one shows the packages that are directly
 | 
			
		||||
	required.
 | 
			
		||||
 | 
			
		||||
*-g, \--graph*::
 | 
			
		||||
	Generate graphviz description. If this option is given, the -c and -l
 | 
			
		||||
	options are ignored.
 | 
			
		||||
 | 
			
		||||
*-h, \--help*::
 | 
			
		||||
	Output syntax and command line options.
 | 
			
		||||
 | 
			
		||||
*-l, \--linear*::
 | 
			
		||||
	Prints package names at the start of each line, one per line.
 | 
			
		||||
 | 
			
		||||
*-r, \--reverse*::
 | 
			
		||||
	Show packages that depend on the named package.
 | 
			
		||||
 | 
			
		||||
*-s, \--sync*::
 | 
			
		||||
	Read package data from sync databases instead of local database.
 | 
			
		||||
 | 
			
		||||
*-u, \--unique*::
 | 
			
		||||
	List dependent packages once. Implies --linear.
 | 
			
		||||
 | 
			
		||||
*\--config <file>*::
 | 
			
		||||
	Specify an alternate pacman configuration file.
 | 
			
		||||
 | 
			
		||||
See Also
 | 
			
		||||
--------
 | 
			
		||||
linkman:pacman[8], linkman:pacman.conf[5], linkman:makepkg[8]
 | 
			
		||||
 | 
			
		||||
include::footer.txt[]
 | 
			
		||||
@@ -11,7 +11,7 @@ pkgdelta - package delta generation utility
 | 
			
		||||
 | 
			
		||||
Synopsis
 | 
			
		||||
--------
 | 
			
		||||
'pkgdelta' [-q] <package1> <package2>
 | 
			
		||||
'pkgdelta' [options] <package1> <package2>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Description
 | 
			
		||||
@@ -27,6 +27,17 @@ significantly.
 | 
			
		||||
 | 
			
		||||
Options
 | 
			
		||||
-------
 | 
			
		||||
*--max-delta-size <ratio>*::
 | 
			
		||||
	Only create delta files if the delta is smaller than ratio * package_size.
 | 
			
		||||
	Possible values: 0.0 to 2.0.
 | 
			
		||||
	Recommended values: 0.2 to 0.9.
 | 
			
		||||
	Default value: 0.7
 | 
			
		||||
 | 
			
		||||
*--min-pkg-size <size>*::
 | 
			
		||||
	Minimal size of the package file in bytes to be considered for delta creation.
 | 
			
		||||
	Default value: 1048576 bytes = 1MiB. This may be any absolute size in bytes, or
 | 
			
		||||
	a human readable value such as `4 MiB` or `3.5MB`.
 | 
			
		||||
 | 
			
		||||
*-q, \--quiet*::
 | 
			
		||||
	Be quiet. Do not output anything but warnings and errors.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,9 @@ Common Options
 | 
			
		||||
	If the signature is invalid, an error is produced and the update does not
 | 
			
		||||
	proceed.
 | 
			
		||||
 | 
			
		||||
*\--nocolor*::
 | 
			
		||||
	Remove color from repo-add and repo-remove output.
 | 
			
		||||
 | 
			
		||||
repo-add Options
 | 
			
		||||
----------------
 | 
			
		||||
*-d, \--delta*::
 | 
			
		||||
@@ -68,6 +71,10 @@ repo-add Options
 | 
			
		||||
	specified packages. This is useful for creating databases listing all files
 | 
			
		||||
	in a given sync repository for tools that may use this information.
 | 
			
		||||
 | 
			
		||||
*-n, \--new*::
 | 
			
		||||
	Only add packages that are not already in the database.  Warnings will be
 | 
			
		||||
	printed upon detection of existing packages, but they will not be re-added.
 | 
			
		||||
 | 
			
		||||
See Also
 | 
			
		||||
--------
 | 
			
		||||
linkman:makepkg[8], linkman:pacman[8], linkman:pkgdelta[8]
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,8 @@ Patches need to be submitted in GIT format and are best if they are against the
 | 
			
		||||
latest version of the code. There are several helpful tutorials for getting
 | 
			
		||||
started with GIT if you have not worked with it before.
 | 
			
		||||
 | 
			
		||||
* http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
 | 
			
		||||
* http://wiki.archlinux.org/index.php/Super_Quick_Git_Guide
 | 
			
		||||
* https://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
 | 
			
		||||
* https://wiki.archlinux.org/index.php/Super_Quick_Git_Guide
 | 
			
		||||
 | 
			
		||||
The pacman code can be fetched using the following command:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ http://www.transifex.net/projects/p/archlinux-pacman/[pacman project page].
 | 
			
		||||
NOTE: This may be old information due to our switch to Transifex, but the
 | 
			
		||||
gettext website is a very useful guide to read before embarking on translation
 | 
			
		||||
work, as it describes many of the commands in more detail than I will here:
 | 
			
		||||
http://www.gnu.org/software/gettext/manual/html_node/gettext.html[].  In
 | 
			
		||||
https://www.gnu.org/software/gettext/manual/html_node/gettext.html[].  In
 | 
			
		||||
addition, this site presents a small tutorial that I found useful:
 | 
			
		||||
http://oriya.sarovar.org/docs/gettext/[].
 | 
			
		||||
 | 
			
		||||
@@ -155,7 +155,7 @@ source, please contact the pacman-dev mailing list at
 | 
			
		||||
mailto:pacman-dev@archlinux.org[].
 | 
			
		||||
 | 
			
		||||
Some community efforts have been made to translate manpages, and these can be
 | 
			
		||||
found in the link:http://aur.archlinux.org[AUR] (Arch User Repository). Please
 | 
			
		||||
found in the link:https://aur.archlinux.org[AUR] (Arch User Repository). Please
 | 
			
		||||
check there first before undergoing a translation effort to ensure you are not
 | 
			
		||||
duplicating efforts.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ vercmp(8)
 | 
			
		||||
 | 
			
		||||
Name
 | 
			
		||||
----
 | 
			
		||||
vercmp - version comparsion utility
 | 
			
		||||
vercmp - version comparison utility
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Synopsis
 | 
			
		||||
@@ -23,7 +23,7 @@ numbers. It outputs values as follows:
 | 
			
		||||
*  = 0 : if ver1 == ver2
 | 
			
		||||
*  > 0 : if ver1 > ver2
 | 
			
		||||
 | 
			
		||||
Version comparsion operates as follows:
 | 
			
		||||
Version comparison operates as follows:
 | 
			
		||||
 | 
			
		||||
  Alphanumeric:
 | 
			
		||||
    1.0a < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0 < 1.0.a < 1.0.1
 | 
			
		||||
@@ -35,6 +35,11 @@ overrule any version comparison (unless the epoch values are equal). This is
 | 
			
		||||
specified in an `epoch:version-rel` format. For example, `2:1.0-1` is always
 | 
			
		||||
greater than `1:3.6-1`.
 | 
			
		||||
 | 
			
		||||
Keep in mind that the 'pkgrel' is only compared if it is available on both
 | 
			
		||||
versions given to this tool. For example, comparing `1.5-1` and `1.5` will
 | 
			
		||||
yield 0; comparing `1.5-1` and `1.5-2` will yield < 0 as expected. This is
 | 
			
		||||
mainly for supporting versioned dependencies that do not include the 'pkgrel'.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Options
 | 
			
		||||
-------
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,9 @@ EXTRA_DIST = makepkg.conf.in pacman.conf.in
 | 
			
		||||
# Files that should be removed, but which Automake does not know.
 | 
			
		||||
MOSTLYCLEANFILES = $(dist_sysconf_DATA)
 | 
			
		||||
 | 
			
		||||
#### Taken from the autoconf scripts Makefile.am ####
 | 
			
		||||
edit = sed \
 | 
			
		||||
SED_PROCESS = \
 | 
			
		||||
	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 | 
			
		||||
	$(SED) \
 | 
			
		||||
	-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
 | 
			
		||||
	-e 's|@localstatedir[@]|$(localstatedir)|g' \
 | 
			
		||||
	-e 's|@prefix[@]|$(prefix)|g' \
 | 
			
		||||
@@ -19,15 +20,10 @@ edit = sed \
 | 
			
		||||
	-e 's|@CARCH[@]|$(CARCH)|g' \
 | 
			
		||||
	-e 's|@CHOST[@]|$(CHOST)|g' \
 | 
			
		||||
	-e 's|@ARCHSWITCH[@]|$(ARCHSWITCH)|g' \
 | 
			
		||||
	-e 's|@ROOTDIR[@]|$(ROOTDIR)|g'
 | 
			
		||||
	-e 's|@ROOTDIR[@]|$(ROOTDIR)|g' \
 | 
			
		||||
	< $< > $@
 | 
			
		||||
 | 
			
		||||
$(dist_sysconf_DATA): Makefile
 | 
			
		||||
	@echo '    ' GEN $@;
 | 
			
		||||
	@$(RM) $@ $@.tmp
 | 
			
		||||
	@$(edit) `test -f ./$@.in || echo $(srcdir)/`$@.in >$@.tmp
 | 
			
		||||
	@mv $@.tmp $@
 | 
			
		||||
 | 
			
		||||
makepkg.conf: $(srcdir)/makepkg.conf.in
 | 
			
		||||
pacman.conf: $(srcdir)/pacman.conf.in
 | 
			
		||||
%.conf: %.conf.in Makefile
 | 
			
		||||
	$(SED_PROCESS)
 | 
			
		||||
 | 
			
		||||
# vim:set ts=2 sw=2 noet:
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,9 @@
 | 
			
		||||
#
 | 
			
		||||
#-- The download utilities that makepkg should use to acquire sources
 | 
			
		||||
#  Format: 'protocol::agent'
 | 
			
		||||
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
          'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
          'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
DLAGENTS=('ftp::/usr/bin/curl -qfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
          'http::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
          'https::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
 | 
			
		||||
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
 | 
			
		||||
          'scp::/usr/bin/scp -C %u %o')
 | 
			
		||||
 | 
			
		||||
@@ -27,11 +27,15 @@ CARCH="@CARCH@"
 | 
			
		||||
CHOST="@CHOST@"
 | 
			
		||||
 | 
			
		||||
#-- Compiler and Linker Flags
 | 
			
		||||
#CPPFLAGS=""
 | 
			
		||||
#CFLAGS="-O2 -pipe"
 | 
			
		||||
#CXXFLAGS="-O2 -pipe"
 | 
			
		||||
#LDFLAGS=""
 | 
			
		||||
#-- Make Flags: change this for DistCC/SMP systems
 | 
			
		||||
#MAKEFLAGS="-j2"
 | 
			
		||||
#-- Debugging flags
 | 
			
		||||
#DEBUG_CFLAGS="-g"
 | 
			
		||||
#DEBUG_CXXFLAGS="-g"
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# BUILD ENVIRONMENT
 | 
			
		||||
@@ -61,18 +65,20 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
 | 
			
		||||
#   These are default values for the options=() settings
 | 
			
		||||
#########################################################################
 | 
			
		||||
#
 | 
			
		||||
# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
 | 
			
		||||
# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
 | 
			
		||||
#  A negated option will do the opposite of the comments below.
 | 
			
		||||
#
 | 
			
		||||
#-- strip:     Strip symbols from binaries/libraries
 | 
			
		||||
#-- docs:      Save doc directories specified by DOC_DIRS
 | 
			
		||||
#-- libtool:   Leave libtool (.la) files in packages
 | 
			
		||||
#-- emptydirs: Leave empty directories in packages
 | 
			
		||||
#-- zipman:    Compress manual (man and info) pages in MAN_DIRS with gzip
 | 
			
		||||
#-- purge:     Remove files specified by PURGE_TARGETS
 | 
			
		||||
#-- upx:       Compress binary executable files using UPX
 | 
			
		||||
#-- strip:      Strip symbols from binaries/libraries
 | 
			
		||||
#-- docs:       Save doc directories specified by DOC_DIRS
 | 
			
		||||
#-- libtool:    Leave libtool (.la) files in packages
 | 
			
		||||
#-- staticlibs: Leave static library (.a) files in packages
 | 
			
		||||
#-- emptydirs:  Leave empty directories in packages
 | 
			
		||||
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
 | 
			
		||||
#-- purge:      Remove files specified by PURGE_TARGETS
 | 
			
		||||
#-- upx:        Compress binary executable files using UPX
 | 
			
		||||
#-- debug:      Add debugging flags as specified in DEBUG_* variables
 | 
			
		||||
#
 | 
			
		||||
OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
 | 
			
		||||
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
 | 
			
		||||
 | 
			
		||||
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
 | 
			
		||||
INTEGRITY_CHECK=(md5)
 | 
			
		||||
@@ -101,11 +107,24 @@ PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
 | 
			
		||||
#SRCDEST=/home/sources
 | 
			
		||||
#-- Source packages: specify a fixed directory where all src packages will be placed
 | 
			
		||||
#SRCPKGDEST=/home/srcpackages
 | 
			
		||||
#-- Log files: specify a fixed directory where all log files will be placed
 | 
			
		||||
#LOGDEST=/home/makepkglogs
 | 
			
		||||
#-- Packager: name/email of the person or organization building packages
 | 
			
		||||
#PACKAGER="John Doe <john@doe.com>"
 | 
			
		||||
#-- Specify a key to use for package signing
 | 
			
		||||
#GPGKEY=""
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# COMPRESSION DEFAULTS
 | 
			
		||||
#########################################################################
 | 
			
		||||
#
 | 
			
		||||
COMPRESSGZ=(gzip -c -f -n)
 | 
			
		||||
COMPRESSBZ2=(bzip2 -c -f)
 | 
			
		||||
COMPRESSXZ=(xz -c -z -)
 | 
			
		||||
COMPRESSLRZ=(lrzip -q)
 | 
			
		||||
COMPRESSLZO=(lzop -q)
 | 
			
		||||
COMPRESSZ=(compress -c -f)
 | 
			
		||||
 | 
			
		||||
#########################################################################
 | 
			
		||||
# EXTENSION DEFAULTS
 | 
			
		||||
#########################################################################
 | 
			
		||||
 
 | 
			
		||||
@@ -15,11 +15,10 @@
 | 
			
		||||
#LogFile     = @localstatedir@/log/pacman.log
 | 
			
		||||
#GPGDir      = @sysconfdir@/pacman.d/gnupg/
 | 
			
		||||
HoldPkg     = pacman glibc
 | 
			
		||||
# If upgrades are available for these packages they will be asked for first
 | 
			
		||||
SyncFirst   = pacman
 | 
			
		||||
#XferCommand = /usr/bin/curl -C - -f %u > %o
 | 
			
		||||
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
 | 
			
		||||
#CleanMethod = KeepInstalled
 | 
			
		||||
#UseDelta    = 0.7
 | 
			
		||||
Architecture = auto
 | 
			
		||||
 | 
			
		||||
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
 | 
			
		||||
@@ -31,13 +30,15 @@ Architecture = auto
 | 
			
		||||
 | 
			
		||||
# Misc options
 | 
			
		||||
#UseSyslog
 | 
			
		||||
#UseDelta
 | 
			
		||||
#Color
 | 
			
		||||
#TotalDownload
 | 
			
		||||
CheckSpace
 | 
			
		||||
#VerbosePkgLists
 | 
			
		||||
 | 
			
		||||
# PGP signature checking
 | 
			
		||||
#SigLevel = Optional
 | 
			
		||||
#LocalFileSigLevel = Optional
 | 
			
		||||
#RemoteFileSigLevel = Optional
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# REPOSITORIES
 | 
			
		||||
@@ -73,4 +74,3 @@ CheckSpace
 | 
			
		||||
#[custom]
 | 
			
		||||
#SigLevel = Optional TrustAll
 | 
			
		||||
#Server = file:///home/custompkgs
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								lib/libalpm/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								lib/libalpm/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -2,3 +2,4 @@
 | 
			
		||||
.libs
 | 
			
		||||
*.lo
 | 
			
		||||
*.la
 | 
			
		||||
libalpm.pc
 | 
			
		||||
 
 | 
			
		||||
@@ -5,9 +5,11 @@ SUBDIRS = po
 | 
			
		||||
lib_LTLIBRARIES = libalpm.la
 | 
			
		||||
include_HEADERS = alpm_list.h alpm.h
 | 
			
		||||
 | 
			
		||||
DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@
 | 
			
		||||
AM_CPPFLAGS = \
 | 
			
		||||
	-imacros $(top_builddir)/config.h \
 | 
			
		||||
	-DLOCALEDIR=\"@localedir@\"
 | 
			
		||||
 | 
			
		||||
AM_CFLAGS = -pedantic -D_GNU_SOURCE
 | 
			
		||||
AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS)
 | 
			
		||||
 | 
			
		||||
if ENABLE_VISIBILITY_CC
 | 
			
		||||
if DARWIN
 | 
			
		||||
@@ -20,6 +22,9 @@ if ENABLE_GNU89_INLINE_CC
 | 
			
		||||
AM_CFLAGS += -fgnu89-inline
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
pkgconfigdir = $(libdir)/pkgconfig
 | 
			
		||||
pkgconfig_DATA = libalpm.pc
 | 
			
		||||
 | 
			
		||||
libalpm_la_SOURCES = \
 | 
			
		||||
	add.h add.c \
 | 
			
		||||
	alpm.h alpm.c \
 | 
			
		||||
@@ -35,9 +40,11 @@ libalpm_la_SOURCES = \
 | 
			
		||||
	diskspace.h diskspace.c \
 | 
			
		||||
	dload.h dload.c \
 | 
			
		||||
	error.c \
 | 
			
		||||
	filelist.h filelist.c \
 | 
			
		||||
	graph.h graph.c \
 | 
			
		||||
	group.h group.c \
 | 
			
		||||
	handle.h handle.c \
 | 
			
		||||
	libarchive-compat.h \
 | 
			
		||||
	log.h log.c \
 | 
			
		||||
	package.h package.c \
 | 
			
		||||
	pkghash.h pkghash.c \
 | 
			
		||||
@@ -47,6 +54,7 @@ libalpm_la_SOURCES = \
 | 
			
		||||
	sync.h sync.c \
 | 
			
		||||
	trans.h trans.c \
 | 
			
		||||
	util.h util.c \
 | 
			
		||||
	util-common.h util-common.c \
 | 
			
		||||
	version.c
 | 
			
		||||
 | 
			
		||||
if !HAVE_LIBSSL
 | 
			
		||||
@@ -60,7 +68,20 @@ libalpm_la_SOURCES += \
 | 
			
		||||
	base64.h base64.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) @LIBCURL@
 | 
			
		||||
libalpm_la_LIBADD = $(LTLIBINTL)
 | 
			
		||||
libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
 | 
			
		||||
 | 
			
		||||
libalpm_la_CFLAGS = \
 | 
			
		||||
	$(AM_CFLAGS) \
 | 
			
		||||
	$(GPGME_CFLAGS) \
 | 
			
		||||
	$(LIBARCHIVE_CFLAGS) \
 | 
			
		||||
	$(LIBCURL_CFLAGS) \
 | 
			
		||||
	$(LIBSSL_CFLAGS)
 | 
			
		||||
 | 
			
		||||
libalpm_la_LIBADD = \
 | 
			
		||||
	$(LTLIBINTL) \
 | 
			
		||||
	$(GPGME_LIBS) \
 | 
			
		||||
	$(LIBARCHIVE_LIBS) \
 | 
			
		||||
	$(LIBCURL_LIBS) \
 | 
			
		||||
	$(LIBSSL_LIBS)
 | 
			
		||||
 | 
			
		||||
# vim:set ts=2 sw=2 noet:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  add.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,19 +18,15 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <inttypes.h> /* int64_t */
 | 
			
		||||
#include <stdint.h> /* intmax_t */
 | 
			
		||||
#include <stdint.h> /* int64_t */
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
@@ -41,6 +37,7 @@
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "handle.h"
 | 
			
		||||
#include "libarchive-compat.h"
 | 
			
		||||
#include "trans.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
@@ -71,7 +68,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname);
 | 
			
		||||
 | 
			
		||||
	if(_alpm_pkg_find(trans->add, pkgname)) {
 | 
			
		||||
	if(alpm_pkg_find(trans->add, pkgname)) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -125,13 +122,26 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
	} else if(ret != ARCHIVE_OK) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not extract %s (%s)\n"),
 | 
			
		||||
				origname, archive_error_string(archive));
 | 
			
		||||
		alpm_logaction(handle, "error: could not extract %s (%s)\n",
 | 
			
		||||
		alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
				"error: could not extract %s (%s)\n",
 | 
			
		||||
				origname, archive_error_string(archive));
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int try_rename(alpm_handle_t *handle, const char *src, const char *dest)
 | 
			
		||||
{
 | 
			
		||||
	if(rename(src, dest)) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
 | 
			
		||||
				src, dest, strerror(errno));
 | 
			
		||||
		alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
				"error: could not rename %s to %s (%s)\n", src, dest, strerror(errno));
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
		struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg)
 | 
			
		||||
{
 | 
			
		||||
@@ -146,8 +156,6 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
	entryname = archive_entry_pathname(entry);
 | 
			
		||||
	entrymode = archive_entry_mode(entry);
 | 
			
		||||
 | 
			
		||||
	memset(filename, 0, PATH_MAX); /* just to be sure */
 | 
			
		||||
 | 
			
		||||
	if(strcmp(entryname, ".INSTALL") == 0) {
 | 
			
		||||
		/* the install script goes inside the db */
 | 
			
		||||
		snprintf(filename, PATH_MAX, "%s%s-%s/install",
 | 
			
		||||
@@ -158,6 +166,11 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
		snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
 | 
			
		||||
				_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
 | 
			
		||||
		archive_entry_set_perm(entry, 0644);
 | 
			
		||||
	} else if(strcmp(entryname, ".MTREE") == 0) {
 | 
			
		||||
		/* the mtree file goes inside the db */
 | 
			
		||||
		snprintf(filename, PATH_MAX, "%s%s-%s/mtree",
 | 
			
		||||
				_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
 | 
			
		||||
		archive_entry_set_perm(entry, 0644);
 | 
			
		||||
	} else if(*entryname == '.') {
 | 
			
		||||
		/* for now, ignore all files starting with '.' that haven't
 | 
			
		||||
		 * already been handled (for future possibilities) */
 | 
			
		||||
@@ -170,11 +183,12 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* if a file is in NoExtract then we never extract it */
 | 
			
		||||
	if(alpm_list_find_str(handle->noextract, entryname)) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n",
 | 
			
		||||
				entryname);
 | 
			
		||||
		alpm_logaction(handle, "note: %s is in NoExtract, skipping extraction\n",
 | 
			
		||||
				entryname);
 | 
			
		||||
	if(alpm_list_find(handle->noextract, entryname, _alpm_fnmatch)) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoExtract,"
 | 
			
		||||
				" skipping extraction of %s\n",
 | 
			
		||||
				entryname, filename);
 | 
			
		||||
		alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
				"note: %s is in NoExtract, skipping extraction\n", entryname);
 | 
			
		||||
		archive_read_data_skip(archive);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -211,20 +225,21 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
					/* if filesystem perms are different than pkg perms, warn user */
 | 
			
		||||
					mode_t mask = 07777;
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
 | 
			
		||||
								"filesystem: %o  package: %o\n"), entryname, lsbuf.st_mode & mask,
 | 
			
		||||
								"filesystem: %o  package: %o\n"), filename, lsbuf.st_mode & mask,
 | 
			
		||||
							entrymode & mask);
 | 
			
		||||
					alpm_logaction(handle, "warning: directory permissions differ on %s\n"
 | 
			
		||||
							"filesystem: %o  package: %o\n", entryname, lsbuf.st_mode & mask,
 | 
			
		||||
					alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
							"warning: directory permissions differ on %s\n"
 | 
			
		||||
							"filesystem: %o  package: %o\n", filename, lsbuf.st_mode & mask,
 | 
			
		||||
							entrymode & mask);
 | 
			
		||||
				}
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
 | 
			
		||||
						entryname);
 | 
			
		||||
						filename);
 | 
			
		||||
				archive_read_data_skip(archive);
 | 
			
		||||
				return 0;
 | 
			
		||||
			} else {
 | 
			
		||||
				/* case 10/11: trying to overwrite dir with file/symlink, don't allow it */
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
 | 
			
		||||
						entryname);
 | 
			
		||||
						filename);
 | 
			
		||||
				archive_read_data_skip(archive);
 | 
			
		||||
				return 1;
 | 
			
		||||
			}
 | 
			
		||||
@@ -233,24 +248,24 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
			if(S_ISDIR(sbuf.st_mode)) {
 | 
			
		||||
				/* the symlink on FS is to a directory, so we'll use it */
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping symlink overwrite of %s\n",
 | 
			
		||||
						entryname);
 | 
			
		||||
						filename);
 | 
			
		||||
				archive_read_data_skip(archive);
 | 
			
		||||
				return 0;
 | 
			
		||||
			} else {
 | 
			
		||||
				/* this is BAD. symlink was not to a directory */
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("extract: symlink %s does not point to dir\n"),
 | 
			
		||||
						entryname);
 | 
			
		||||
						filename);
 | 
			
		||||
				archive_read_data_skip(archive);
 | 
			
		||||
				return 1;
 | 
			
		||||
			}
 | 
			
		||||
		} else if(S_ISREG(lsbuf.st_mode) && S_ISDIR(entrymode)) {
 | 
			
		||||
			/* case 6: trying to overwrite file with dir */
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
 | 
			
		||||
					entryname);
 | 
			
		||||
					filename);
 | 
			
		||||
		} else if(S_ISREG(entrymode)) {
 | 
			
		||||
			/* case 4,7: */
 | 
			
		||||
			/* if file is in NoUpgrade, don't touch it */
 | 
			
		||||
			if(alpm_list_find_str(handle->noupgrade, entryname)) {
 | 
			
		||||
			if(alpm_list_find(handle->noupgrade, entryname, _alpm_fnmatch)) {
 | 
			
		||||
				notouch = 1;
 | 
			
		||||
			} else {
 | 
			
		||||
				alpm_backup_t *backup;
 | 
			
		||||
@@ -282,17 +297,18 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
	STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
 | 
			
		||||
 | 
			
		||||
	if(needbackup) {
 | 
			
		||||
		char checkfile[PATH_MAX];
 | 
			
		||||
		char *checkfile;
 | 
			
		||||
		char *hash_local = NULL, *hash_pkg = NULL;
 | 
			
		||||
		int ret;
 | 
			
		||||
		size_t len;
 | 
			
		||||
 | 
			
		||||
		snprintf(checkfile, PATH_MAX, "%s.paccheck", filename);
 | 
			
		||||
		len = strlen(filename) + 10;
 | 
			
		||||
		MALLOC(checkfile, len,
 | 
			
		||||
				errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
 | 
			
		||||
		snprintf(checkfile, len, "%s.paccheck", filename);
 | 
			
		||||
 | 
			
		||||
		ret = perform_extraction(handle, archive, entry, checkfile, entryname_orig);
 | 
			
		||||
		if(ret == 1) {
 | 
			
		||||
			/* error */
 | 
			
		||||
			FREE(entryname_orig);
 | 
			
		||||
			return 1;
 | 
			
		||||
		if(perform_extraction(handle, archive, entry, checkfile, entryname_orig)) {
 | 
			
		||||
			errors++;
 | 
			
		||||
			goto needbackup_cleanup;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		hash_local = alpm_compute_md5sum(filename);
 | 
			
		||||
@@ -320,29 +336,27 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
			if(hash_local && hash_pkg && strcmp(hash_local, hash_pkg) != 0) {
 | 
			
		||||
				/* looks like we have a local file that has a different hash as the
 | 
			
		||||
				 * file in the package, move it to a .pacorig */
 | 
			
		||||
				char newpath[PATH_MAX];
 | 
			
		||||
				snprintf(newpath, PATH_MAX, "%s.pacorig", filename);
 | 
			
		||||
				char *newpath;
 | 
			
		||||
				size_t newlen = strlen(filename) + 9;
 | 
			
		||||
				MALLOC(newpath, newlen,
 | 
			
		||||
						errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
 | 
			
		||||
				snprintf(newpath, newlen, "%s.pacorig", filename);
 | 
			
		||||
 | 
			
		||||
				/* move the existing file to the "pacorig" */
 | 
			
		||||
				if(rename(filename, newpath)) {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
 | 
			
		||||
							filename, newpath, strerror(errno));
 | 
			
		||||
					alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
 | 
			
		||||
							filename, newpath, strerror(errno));
 | 
			
		||||
				if(try_rename(handle, filename, newpath)) {
 | 
			
		||||
						errors++;
 | 
			
		||||
					errors++;
 | 
			
		||||
				} else {
 | 
			
		||||
					/* rename the file we extracted to the real name */
 | 
			
		||||
					if(rename(checkfile, filename)) {
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
 | 
			
		||||
								checkfile, filename, strerror(errno));
 | 
			
		||||
						alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
 | 
			
		||||
								checkfile, filename, strerror(errno));
 | 
			
		||||
					if(try_rename(handle, checkfile, filename)) {
 | 
			
		||||
						errors++;
 | 
			
		||||
					} else {
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath);
 | 
			
		||||
						alpm_logaction(handle, "warning: %s saved as %s\n", filename, newpath);
 | 
			
		||||
						alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
								"warning: %s saved as %s\n", filename, newpath);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				free(newpath);
 | 
			
		||||
			} else {
 | 
			
		||||
				/* local file is identical to pkg one, so just remove pkg one */
 | 
			
		||||
				unlink(checkfile);
 | 
			
		||||
@@ -356,11 +370,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
 | 
			
		||||
							entryname_orig);
 | 
			
		||||
 | 
			
		||||
					if(rename(checkfile, filename)) {
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
 | 
			
		||||
								checkfile, filename, strerror(errno));
 | 
			
		||||
						alpm_logaction(handle, "error: could not rename %s to %s (%s)\n",
 | 
			
		||||
								checkfile, filename, strerror(errno));
 | 
			
		||||
					if(try_rename(handle, checkfile, filename)) {
 | 
			
		||||
						errors++;
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
@@ -382,35 +392,37 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG, "action: leaving existing file in place\n");
 | 
			
		||||
				unlink(checkfile);
 | 
			
		||||
			} else {
 | 
			
		||||
				char newpath[PATH_MAX];
 | 
			
		||||
				char *newpath;
 | 
			
		||||
				size_t newlen = strlen(filename) + 8;
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG, "action: keeping current file and installing"
 | 
			
		||||
						" new one with .pacnew ending\n");
 | 
			
		||||
				snprintf(newpath, PATH_MAX, "%s.pacnew", filename);
 | 
			
		||||
				if(rename(checkfile, newpath)) {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_ERROR, _("could not install %s as %s (%s)\n"),
 | 
			
		||||
							filename, newpath, strerror(errno));
 | 
			
		||||
					alpm_logaction(handle, "error: could not install %s as %s (%s)\n",
 | 
			
		||||
							filename, newpath, strerror(errno));
 | 
			
		||||
				MALLOC(newpath, newlen,
 | 
			
		||||
						errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
 | 
			
		||||
				snprintf(newpath, newlen, "%s.pacnew", filename);
 | 
			
		||||
				if(try_rename(handle, checkfile, newpath)) {
 | 
			
		||||
					errors++;
 | 
			
		||||
				} else {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_WARNING, _("%s installed as %s\n"),
 | 
			
		||||
							filename, newpath);
 | 
			
		||||
					alpm_logaction(handle, "warning: %s installed as %s\n",
 | 
			
		||||
							filename, newpath);
 | 
			
		||||
					alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
							"warning: %s installed as %s\n", filename, newpath);
 | 
			
		||||
				}
 | 
			
		||||
				free(newpath);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		FREE(hash_local);
 | 
			
		||||
		FREE(hash_pkg);
 | 
			
		||||
needbackup_cleanup:
 | 
			
		||||
		free(checkfile);
 | 
			
		||||
		free(hash_local);
 | 
			
		||||
		free(hash_pkg);
 | 
			
		||||
	} else {
 | 
			
		||||
		int ret;
 | 
			
		||||
 | 
			
		||||
		/* we didn't need a backup */
 | 
			
		||||
		if(notouch) {
 | 
			
		||||
			/* change the path to a .pacnew extension */
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING, _("extracting %s as %s.pacnew\n"), filename, filename);
 | 
			
		||||
			alpm_logaction(handle, "warning: extracting %s as %s.pacnew\n", filename, filename);
 | 
			
		||||
			alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
					"warning: extracting %s as %s.pacnew\n", filename, filename);
 | 
			
		||||
			strncat(filename, ".pacnew", PATH_MAX - strlen(filename));
 | 
			
		||||
		} else {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
 | 
			
		||||
@@ -423,11 +435,11 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
			unlink(filename);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ret = perform_extraction(handle, archive, entry, filename, entryname_orig);
 | 
			
		||||
		if(ret == 1) {
 | 
			
		||||
		if(perform_extraction(handle, archive, entry, filename, entryname_orig)) {
 | 
			
		||||
			/* error */
 | 
			
		||||
			FREE(entryname_orig);
 | 
			
		||||
			return 1;
 | 
			
		||||
			free(entryname_orig);
 | 
			
		||||
			errors++;
 | 
			
		||||
			return errors;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* calculate an hash if this is in newpkg's backup */
 | 
			
		||||
@@ -444,7 +456,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
 | 
			
		||||
			backup->hash = newhash;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	FREE(entryname_orig);
 | 
			
		||||
	free(entryname_orig);
 | 
			
		||||
	return errors;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -452,10 +464,13 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
		size_t pkg_current, size_t pkg_count)
 | 
			
		||||
{
 | 
			
		||||
	int i, ret = 0, errors = 0;
 | 
			
		||||
	int is_upgrade;
 | 
			
		||||
	int is_upgrade = 0;
 | 
			
		||||
	alpm_pkg_t *oldpkg = NULL;
 | 
			
		||||
	alpm_db_t *db = handle->db_local;
 | 
			
		||||
	alpm_trans_t *trans = handle->trans;
 | 
			
		||||
	alpm_progress_t event = ALPM_PROGRESS_ADD_START;
 | 
			
		||||
	alpm_event_t done = ALPM_EVENT_ADD_DONE, start = ALPM_EVENT_ADD_START;
 | 
			
		||||
	const char *log_msg = "adding";
 | 
			
		||||
	const char *pkgfile;
 | 
			
		||||
 | 
			
		||||
	ASSERT(trans != NULL, return -1);
 | 
			
		||||
@@ -463,6 +478,23 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
	/* see if this is an upgrade. if so, remove the old package first */
 | 
			
		||||
	alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name);
 | 
			
		||||
	if(local) {
 | 
			
		||||
		int cmp = _alpm_pkg_compare_versions(newpkg, local);
 | 
			
		||||
		if(cmp < 0) {
 | 
			
		||||
			log_msg = "downgrading";
 | 
			
		||||
			event = ALPM_PROGRESS_DOWNGRADE_START;
 | 
			
		||||
			start = ALPM_EVENT_DOWNGRADE_START;
 | 
			
		||||
			done = ALPM_EVENT_DOWNGRADE_DONE;
 | 
			
		||||
		} else if(cmp == 0) {
 | 
			
		||||
			log_msg = "reinstalling";
 | 
			
		||||
			event = ALPM_PROGRESS_REINSTALL_START;
 | 
			
		||||
			start = ALPM_EVENT_REINSTALL_START;
 | 
			
		||||
			done = ALPM_EVENT_REINSTALL_DONE;
 | 
			
		||||
		} else {
 | 
			
		||||
			log_msg = "upgrading";
 | 
			
		||||
			event = ALPM_PROGRESS_UPGRADE_START;
 | 
			
		||||
			start = ALPM_EVENT_UPGRADE_START;
 | 
			
		||||
			done = ALPM_EVENT_UPGRADE_DONE;
 | 
			
		||||
		}
 | 
			
		||||
		is_upgrade = 1;
 | 
			
		||||
 | 
			
		||||
		/* we'll need to save some record for backup checks later */
 | 
			
		||||
@@ -473,23 +505,21 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
 | 
			
		||||
		/* copy over the install reason */
 | 
			
		||||
		newpkg->reason = alpm_pkg_get_reason(local);
 | 
			
		||||
 | 
			
		||||
		EVENT(handle, ALPM_EVENT_UPGRADE_START, newpkg, local);
 | 
			
		||||
	} else {
 | 
			
		||||
		is_upgrade = 0;
 | 
			
		||||
		EVENT(handle, ALPM_EVENT_ADD_START, newpkg, NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	EVENT(handle, start, newpkg, local);
 | 
			
		||||
 | 
			
		||||
	pkgfile = newpkg->origin_data.file;
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "%s package %s-%s\n",
 | 
			
		||||
			is_upgrade ? "upgrading" : "adding", newpkg->name, newpkg->version);
 | 
			
		||||
			log_msg, newpkg->name, newpkg->version);
 | 
			
		||||
		/* pre_install/pre_upgrade scriptlet */
 | 
			
		||||
	if(alpm_pkg_has_scriptlet(newpkg) &&
 | 
			
		||||
			!(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
 | 
			
		||||
		const char *scriptlet_name = is_upgrade ? "pre_upgrade" : "pre_install";
 | 
			
		||||
		_alpm_runscriptlet(handle, pkgfile,
 | 
			
		||||
				scriptlet_name, newpkg->version, NULL, 1);
 | 
			
		||||
 | 
			
		||||
		_alpm_runscriptlet(handle, pkgfile, scriptlet_name,
 | 
			
		||||
				newpkg->version, oldpkg ? oldpkg->version : NULL, 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* we override any pre-set reason if we have alldeps or allexplicit set */
 | 
			
		||||
@@ -511,7 +541,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
	/* prepare directory for database entries so permission are correct after
 | 
			
		||||
	   changelog/install script installation (FS#12263) */
 | 
			
		||||
	if(_alpm_local_db_prepare(db, newpkg)) {
 | 
			
		||||
		alpm_logaction(handle, "error: could not create database entry %s-%s\n",
 | 
			
		||||
		alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
				"error: could not create database entry %s-%s\n",
 | 
			
		||||
				newpkg->name, newpkg->version);
 | 
			
		||||
		handle->pm_errno = ALPM_ERR_DB_WRITE;
 | 
			
		||||
		ret = -1;
 | 
			
		||||
@@ -521,31 +552,20 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
	if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
 | 
			
		||||
		struct archive *archive;
 | 
			
		||||
		struct archive_entry *entry;
 | 
			
		||||
		int cwdfd;
 | 
			
		||||
		struct stat buf;
 | 
			
		||||
		int fd, cwdfd;
 | 
			
		||||
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
 | 
			
		||||
 | 
			
		||||
		if((archive = archive_read_new()) == NULL) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_LIBARCHIVE;
 | 
			
		||||
			ret = -1;
 | 
			
		||||
			goto cleanup;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		archive_read_support_compression_all(archive);
 | 
			
		||||
		archive_read_support_format_all(archive);
 | 
			
		||||
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "archive: %s\n", pkgfile);
 | 
			
		||||
		if(archive_read_open_filename(archive, pkgfile,
 | 
			
		||||
					ALPM_BUFFER_SIZE) != ARCHIVE_OK) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_OPEN;
 | 
			
		||||
		fd = _alpm_open_archive(db->handle, pkgfile, &buf,
 | 
			
		||||
				&archive, ALPM_ERR_PKG_OPEN);
 | 
			
		||||
		if(fd < 0) {
 | 
			
		||||
			ret = -1;
 | 
			
		||||
			goto cleanup;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* save the cwd so we can restore it later */
 | 
			
		||||
		do {
 | 
			
		||||
			cwdfd = open(".", O_RDONLY);
 | 
			
		||||
		} while(cwdfd == -1 && errno == EINTR);
 | 
			
		||||
		OPEN(cwdfd, ".", O_RDONLY);
 | 
			
		||||
		if(cwdfd < 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n"));
 | 
			
		||||
		}
 | 
			
		||||
@@ -554,18 +574,14 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
		if(chdir(handle->root) != 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
 | 
			
		||||
					handle->root, strerror(errno));
 | 
			
		||||
			_alpm_archive_read_free(archive);
 | 
			
		||||
			CLOSE(fd);
 | 
			
		||||
			ret = -1;
 | 
			
		||||
			goto cleanup;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* call PROGRESS once with 0 percent, as we sort-of skip that here */
 | 
			
		||||
		if(is_upgrade) {
 | 
			
		||||
			PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
 | 
			
		||||
					newpkg->name, 0, pkg_count, pkg_current);
 | 
			
		||||
		} else {
 | 
			
		||||
			PROGRESS(handle, ALPM_PROGRESS_ADD_START,
 | 
			
		||||
					newpkg->name, 0, pkg_count, pkg_current);
 | 
			
		||||
		}
 | 
			
		||||
		PROGRESS(handle, event, newpkg->name, 0, pkg_count, pkg_current);
 | 
			
		||||
 | 
			
		||||
		for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
 | 
			
		||||
			int percent;
 | 
			
		||||
@@ -574,7 +590,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
				/* Using compressed size for calculations here, as newpkg->isize is not
 | 
			
		||||
				 * exact when it comes to comparing to the ACTUAL uncompressed size
 | 
			
		||||
				 * (missing metadata sizes) */
 | 
			
		||||
				int64_t pos = archive_position_compressed(archive);
 | 
			
		||||
				int64_t pos = _alpm_archive_compressed_ftell(archive);
 | 
			
		||||
				percent = (pos * 100) / newpkg->size;
 | 
			
		||||
				if(percent >= 100) {
 | 
			
		||||
					percent = 100;
 | 
			
		||||
@@ -583,18 +599,13 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
				percent = 0;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(is_upgrade) {
 | 
			
		||||
				PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
 | 
			
		||||
						newpkg->name, percent, pkg_count, pkg_current);
 | 
			
		||||
			} else {
 | 
			
		||||
				PROGRESS(handle, ALPM_PROGRESS_ADD_START,
 | 
			
		||||
						newpkg->name, percent, pkg_count, pkg_current);
 | 
			
		||||
			}
 | 
			
		||||
			PROGRESS(handle, event, newpkg->name, percent, pkg_count, pkg_current);
 | 
			
		||||
 | 
			
		||||
			/* extract the next file from the archive */
 | 
			
		||||
			errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
 | 
			
		||||
		}
 | 
			
		||||
		archive_read_finish(archive);
 | 
			
		||||
		_alpm_archive_read_free(archive);
 | 
			
		||||
		CLOSE(fd);
 | 
			
		||||
 | 
			
		||||
		/* restore the old cwd if we have it */
 | 
			
		||||
		if(cwdfd >= 0) {
 | 
			
		||||
@@ -602,7 +613,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
						_("could not restore working directory (%s)\n"), strerror(errno));
 | 
			
		||||
			}
 | 
			
		||||
			close(cwdfd);
 | 
			
		||||
			CLOSE(cwdfd);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(errors) {
 | 
			
		||||
@@ -610,12 +621,14 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
			if(is_upgrade) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
 | 
			
		||||
						newpkg->name);
 | 
			
		||||
				alpm_logaction(handle, "error: problem occurred while upgrading %s\n",
 | 
			
		||||
				alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
						"error: problem occurred while upgrading %s\n",
 | 
			
		||||
						newpkg->name);
 | 
			
		||||
			} else {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while installing %s\n"),
 | 
			
		||||
						newpkg->name);
 | 
			
		||||
				alpm_logaction(handle, "error: problem occurred while installing %s\n",
 | 
			
		||||
				alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
						"error: problem occurred while installing %s\n",
 | 
			
		||||
						newpkg->name);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -630,7 +643,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
	if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not update database entry %s-%s\n"),
 | 
			
		||||
				newpkg->name, newpkg->version);
 | 
			
		||||
		alpm_logaction(handle, "error: could not update database entry %s-%s\n",
 | 
			
		||||
		alpm_logaction(handle, ALPM_CALLER_PREFIX,
 | 
			
		||||
				"error: could not update database entry %s-%s\n",
 | 
			
		||||
				newpkg->name, newpkg->version);
 | 
			
		||||
		handle->pm_errno = ALPM_ERR_DB_WRITE;
 | 
			
		||||
		ret = -1;
 | 
			
		||||
@@ -642,13 +656,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
				newpkg->name);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(is_upgrade) {
 | 
			
		||||
		PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
 | 
			
		||||
				newpkg->name, 100, pkg_count, pkg_current);
 | 
			
		||||
	} else {
 | 
			
		||||
		PROGRESS(handle, ALPM_PROGRESS_ADD_START,
 | 
			
		||||
				newpkg->name, 100, pkg_count, pkg_current);
 | 
			
		||||
	}
 | 
			
		||||
	PROGRESS(handle, event, newpkg->name, 100, pkg_count, pkg_current);
 | 
			
		||||
 | 
			
		||||
	/* run the post-install script if it exists  */
 | 
			
		||||
	if(alpm_pkg_has_scriptlet(newpkg)
 | 
			
		||||
@@ -661,11 +669,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
 | 
			
		||||
		free(scriptlet);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(is_upgrade) {
 | 
			
		||||
		EVENT(handle, ALPM_EVENT_UPGRADE_DONE, newpkg, oldpkg);
 | 
			
		||||
	} else {
 | 
			
		||||
		EVENT(handle, ALPM_EVENT_ADD_DONE, newpkg, oldpkg);
 | 
			
		||||
	}
 | 
			
		||||
	EVENT(handle, done, newpkg, oldpkg);
 | 
			
		||||
 | 
			
		||||
cleanup:
 | 
			
		||||
	_alpm_pkg_free(oldpkg);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  add.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  alpm.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
 | 
			
		||||
@@ -21,8 +21,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_LIBCURL
 | 
			
		||||
#include <curl/curl.h>
 | 
			
		||||
#endif
 | 
			
		||||
@@ -39,17 +37,18 @@
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Initializes the library.  This must be called before any other
 | 
			
		||||
 * functions are called.
 | 
			
		||||
/** Initializes the library.
 | 
			
		||||
 * Creates handle, connects to database and creates lockfile.
 | 
			
		||||
 * This must be called before any other functions are called.
 | 
			
		||||
 * @param root the root path for all filesystem operations
 | 
			
		||||
 * @param dbpath the absolute path to the libalpm database
 | 
			
		||||
 * @param err an optional variable to hold any error return codes
 | 
			
		||||
 * @return a context handle on success, NULL on error, err will be set if provided
 | 
			
		||||
 */
 | 
			
		||||
alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
 | 
			
		||||
		enum _alpm_errno_t *err)
 | 
			
		||||
		alpm_errno_t *err)
 | 
			
		||||
{
 | 
			
		||||
	enum _alpm_errno_t myerr;
 | 
			
		||||
	alpm_errno_t myerr;
 | 
			
		||||
	const char *lf = "db.lck";
 | 
			
		||||
	size_t lockfilelen;
 | 
			
		||||
	alpm_handle_t *myhandle = _alpm_handle_new();
 | 
			
		||||
@@ -88,7 +87,9 @@ cleanup:
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Release the library.  This should be the last alpm call you make.
 | 
			
		||||
/** Release the library.
 | 
			
		||||
 * Disconnects from the database, removes handle and lockfile
 | 
			
		||||
 * This should be the last alpm call you make.
 | 
			
		||||
 * After this returns, handle should be considered invalid and cannot be reused
 | 
			
		||||
 * in any way.
 | 
			
		||||
 * @param myhandle the context handle
 | 
			
		||||
@@ -108,7 +109,7 @@ int SYMEXPORT alpm_release(alpm_handle_t *myhandle)
 | 
			
		||||
		myhandle->db_local = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(alpm_db_unregister_all(myhandle) == -1) {
 | 
			
		||||
	if(alpm_unregister_all_syncdbs(myhandle) == -1) {
 | 
			
		||||
		ret = -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 * alpm.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
 | 
			
		||||
@@ -27,14 +27,16 @@
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h> /* for off_t */
 | 
			
		||||
#include <time.h> /* for time_t */
 | 
			
		||||
#include <stdarg.h> /* for va_list */
 | 
			
		||||
#include <stdint.h>    /* int64_t */
 | 
			
		||||
#include <sys/types.h> /* off_t */
 | 
			
		||||
#include <stdarg.h>    /* va_list */
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
#include <archive_entry.h>
 | 
			
		||||
 | 
			
		||||
#include <alpm_list.h>
 | 
			
		||||
 | 
			
		||||
#define DEPRECATED __attribute__((deprecated))
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Arch Linux Package Management library
 | 
			
		||||
 */
 | 
			
		||||
@@ -44,15 +46,14 @@ extern "C" {
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
typedef int64_t alpm_time_t;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Enumerations
 | 
			
		||||
 * These ones are used in multiple contexts, so are forward-declared.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Install reasons.
 | 
			
		||||
 * Why the package was installed.
 | 
			
		||||
 */
 | 
			
		||||
/** Package install reasons. */
 | 
			
		||||
typedef enum _alpm_pkgreason_t {
 | 
			
		||||
	/** Explicitly requested by the user. */
 | 
			
		||||
	ALPM_PKG_REASON_EXPLICIT = 0,
 | 
			
		||||
@@ -60,12 +61,22 @@ typedef enum _alpm_pkgreason_t {
 | 
			
		||||
	ALPM_PKG_REASON_DEPEND = 1
 | 
			
		||||
} alpm_pkgreason_t;
 | 
			
		||||
 | 
			
		||||
/** Location a package object was loaded from. */
 | 
			
		||||
typedef enum _alpm_pkgfrom_t {
 | 
			
		||||
	PKG_FROM_FILE = 1,
 | 
			
		||||
	PKG_FROM_LOCALDB,
 | 
			
		||||
	PKG_FROM_SYNCDB
 | 
			
		||||
	ALPM_PKG_FROM_FILE = 1,
 | 
			
		||||
	ALPM_PKG_FROM_LOCALDB,
 | 
			
		||||
	ALPM_PKG_FROM_SYNCDB
 | 
			
		||||
} alpm_pkgfrom_t;
 | 
			
		||||
 | 
			
		||||
/** Method used to validate a package. */
 | 
			
		||||
typedef enum _alpm_pkgvalidation_t {
 | 
			
		||||
	ALPM_PKG_VALIDATION_UNKNOWN = 0,
 | 
			
		||||
	ALPM_PKG_VALIDATION_NONE = (1 << 0),
 | 
			
		||||
	ALPM_PKG_VALIDATION_MD5SUM = (1 << 1),
 | 
			
		||||
	ALPM_PKG_VALIDATION_SHA256SUM = (1 << 2),
 | 
			
		||||
	ALPM_PKG_VALIDATION_SIGNATURE = (1 << 3)
 | 
			
		||||
} alpm_pkgvalidation_t;
 | 
			
		||||
 | 
			
		||||
/** Types of version constraints in dependency specs. */
 | 
			
		||||
typedef enum _alpm_depmod_t {
 | 
			
		||||
  /** No version constraint */
 | 
			
		||||
@@ -92,9 +103,7 @@ typedef enum _alpm_fileconflicttype_t {
 | 
			
		||||
	ALPM_FILECONFLICT_FILESYSTEM
 | 
			
		||||
} alpm_fileconflicttype_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PGP signature verification options
 | 
			
		||||
 */
 | 
			
		||||
/** PGP signature verification options */
 | 
			
		||||
typedef enum _alpm_siglevel_t {
 | 
			
		||||
	ALPM_SIG_PACKAGE = (1 << 0),
 | 
			
		||||
	ALPM_SIG_PACKAGE_OPTIONAL = (1 << 1),
 | 
			
		||||
@@ -106,12 +115,13 @@ typedef enum _alpm_siglevel_t {
 | 
			
		||||
	ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12),
 | 
			
		||||
	ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13),
 | 
			
		||||
 | 
			
		||||
	ALPM_SIG_PACKAGE_SET = (1 << 27),
 | 
			
		||||
	ALPM_SIG_PACKAGE_TRUST_SET = (1 << 28),
 | 
			
		||||
 | 
			
		||||
	ALPM_SIG_USE_DEFAULT = (1 << 31)
 | 
			
		||||
} alpm_siglevel_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PGP signature verification status return codes
 | 
			
		||||
 */
 | 
			
		||||
/** PGP signature verification status return codes */
 | 
			
		||||
typedef enum _alpm_sigstatus_t {
 | 
			
		||||
	ALPM_SIGSTATUS_VALID,
 | 
			
		||||
	ALPM_SIGSTATUS_KEY_EXPIRED,
 | 
			
		||||
@@ -121,9 +131,7 @@ typedef enum _alpm_sigstatus_t {
 | 
			
		||||
	ALPM_SIGSTATUS_INVALID
 | 
			
		||||
} alpm_sigstatus_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PGP signature verification status return codes
 | 
			
		||||
 */
 | 
			
		||||
/** PGP signature verification status return codes */
 | 
			
		||||
typedef enum _alpm_sigvalidity_t {
 | 
			
		||||
	ALPM_SIGVALIDITY_FULL,
 | 
			
		||||
	ALPM_SIGVALIDITY_MARGINAL,
 | 
			
		||||
@@ -144,6 +152,7 @@ typedef struct __alpm_trans_t alpm_trans_t;
 | 
			
		||||
typedef struct _alpm_depend_t {
 | 
			
		||||
	char *name;
 | 
			
		||||
	char *version;
 | 
			
		||||
	char *desc;
 | 
			
		||||
	unsigned long name_hash;
 | 
			
		||||
	alpm_depmod_t mod;
 | 
			
		||||
} alpm_depend_t;
 | 
			
		||||
@@ -152,7 +161,7 @@ typedef struct _alpm_depend_t {
 | 
			
		||||
typedef struct _alpm_depmissing_t {
 | 
			
		||||
	char *target;
 | 
			
		||||
	alpm_depend_t *depend;
 | 
			
		||||
	/* this is used in case of remove dependency error only */
 | 
			
		||||
	/* this is used only in the case of a remove dependency error */
 | 
			
		||||
	char *causingpkg;
 | 
			
		||||
} alpm_depmissing_t;
 | 
			
		||||
 | 
			
		||||
@@ -208,6 +217,7 @@ typedef struct _alpm_file_t {
 | 
			
		||||
typedef struct _alpm_filelist_t {
 | 
			
		||||
	size_t count;
 | 
			
		||||
	alpm_file_t *files;
 | 
			
		||||
	char **resolved_path;
 | 
			
		||||
} alpm_filelist_t;
 | 
			
		||||
 | 
			
		||||
/** Local package or package file backup entry */
 | 
			
		||||
@@ -222,11 +232,15 @@ typedef struct _alpm_pgpkey_t {
 | 
			
		||||
	char *uid;
 | 
			
		||||
	char *name;
 | 
			
		||||
	char *email;
 | 
			
		||||
	time_t created;
 | 
			
		||||
	time_t expires;
 | 
			
		||||
	alpm_time_t created;
 | 
			
		||||
	alpm_time_t expires;
 | 
			
		||||
	unsigned int length;
 | 
			
		||||
	unsigned int revoked;
 | 
			
		||||
	char pubkey_algo;
 | 
			
		||||
} alpm_pgpkey_t;
 | 
			
		||||
 | 
			
		||||
/** Signature result. Contains the key, status, and validity of a given
 | 
			
		||||
/**
 | 
			
		||||
 * Signature result. Contains the key, status, and validity of a given
 | 
			
		||||
 * signature.
 | 
			
		||||
 */
 | 
			
		||||
typedef struct _alpm_sigresult_t {
 | 
			
		||||
@@ -235,7 +249,8 @@ typedef struct _alpm_sigresult_t {
 | 
			
		||||
	alpm_sigvalidity_t validity;
 | 
			
		||||
} alpm_sigresult_t;
 | 
			
		||||
 | 
			
		||||
/** Signature list. Contains the number of signatures found and a pointer to an
 | 
			
		||||
/**
 | 
			
		||||
 * Signature list. Contains the number of signatures found and a pointer to an
 | 
			
		||||
 * array of results.  The array is of size count.
 | 
			
		||||
 */
 | 
			
		||||
typedef struct _alpm_siglist_t {
 | 
			
		||||
@@ -247,9 +262,7 @@ typedef struct _alpm_siglist_t {
 | 
			
		||||
 * Logging facilities
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Logging Levels
 | 
			
		||||
 */
 | 
			
		||||
/** Logging Levels */
 | 
			
		||||
typedef enum _alpm_loglevel_t {
 | 
			
		||||
	ALPM_LOG_ERROR    = 1,
 | 
			
		||||
	ALPM_LOG_WARNING  = (1 << 1),
 | 
			
		||||
@@ -258,9 +271,12 @@ typedef enum _alpm_loglevel_t {
 | 
			
		||||
} alpm_loglevel_t;
 | 
			
		||||
 | 
			
		||||
typedef void (*alpm_cb_log)(alpm_loglevel_t, const char *, va_list);
 | 
			
		||||
int alpm_logaction(alpm_handle_t *handle, const char *fmt, ...);
 | 
			
		||||
 | 
			
		||||
/** Events.
 | 
			
		||||
int alpm_logaction(alpm_handle_t *handle, const char *prefix,
 | 
			
		||||
		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Events.
 | 
			
		||||
 * NULL parameters are passed to in all events unless specified otherwise.
 | 
			
		||||
 */
 | 
			
		||||
typedef enum _alpm_event_t {
 | 
			
		||||
@@ -305,6 +321,24 @@ typedef enum _alpm_event_t {
 | 
			
		||||
	 * to the callback, respectively.
 | 
			
		||||
	 */
 | 
			
		||||
	ALPM_EVENT_UPGRADE_DONE,
 | 
			
		||||
	/** Package will be downgraded.
 | 
			
		||||
	 * A pointer to the downgraded package is passed to the callback.
 | 
			
		||||
	 */
 | 
			
		||||
	ALPM_EVENT_DOWNGRADE_START,
 | 
			
		||||
	/** Package was downgraded.
 | 
			
		||||
	 * A pointer to the new package, and a pointer to the old package is passed
 | 
			
		||||
	 * to the callback, respectively.
 | 
			
		||||
	 */
 | 
			
		||||
	ALPM_EVENT_DOWNGRADE_DONE,
 | 
			
		||||
	/** Package will be reinstalled.
 | 
			
		||||
	 * A pointer to the reinstalled package is passed to the callback.
 | 
			
		||||
	 */
 | 
			
		||||
	ALPM_EVENT_REINSTALL_START,
 | 
			
		||||
	/** Package was reinstalled.
 | 
			
		||||
	 * A pointer to the new package, and a pointer to the old package is passed
 | 
			
		||||
	 * to the callback, respectively.
 | 
			
		||||
	 */
 | 
			
		||||
	ALPM_EVENT_REINSTALL_DONE,
 | 
			
		||||
	/** Target package's integrity will be checked. */
 | 
			
		||||
	ALPM_EVENT_INTEGRITY_START,
 | 
			
		||||
	/** Target package's integrity was checked. */
 | 
			
		||||
@@ -313,7 +347,7 @@ typedef enum _alpm_event_t {
 | 
			
		||||
	ALPM_EVENT_LOAD_START,
 | 
			
		||||
	/** Target package is finished loading. */
 | 
			
		||||
	ALPM_EVENT_LOAD_DONE,
 | 
			
		||||
	/** Target deltas's integrity will be checked. */
 | 
			
		||||
	/** Target delta's integrity will be checked. */
 | 
			
		||||
	ALPM_EVENT_DELTA_INTEGRITY_START,
 | 
			
		||||
	/** Target delta's integrity was checked. */
 | 
			
		||||
	ALPM_EVENT_DELTA_INTEGRITY_DONE,
 | 
			
		||||
@@ -342,12 +376,30 @@ typedef enum _alpm_event_t {
 | 
			
		||||
	ALPM_EVENT_DISKSPACE_START,
 | 
			
		||||
	/** Disk space usage was computed for a package */
 | 
			
		||||
	ALPM_EVENT_DISKSPACE_DONE,
 | 
			
		||||
	/** An optdepend for another package is being removed
 | 
			
		||||
	 * The requiring package and its dependency are passed to the callback */
 | 
			
		||||
	ALPM_EVENT_OPTDEP_REQUIRED,
 | 
			
		||||
	/** A configured repository database is missing */
 | 
			
		||||
	ALPM_EVENT_DATABASE_MISSING,
 | 
			
		||||
	/** Checking keys used to create signatures are in keyring. */
 | 
			
		||||
	ALPM_EVENT_KEYRING_START,
 | 
			
		||||
	/** Keyring checking is finished. */
 | 
			
		||||
	ALPM_EVENT_KEYRING_DONE,
 | 
			
		||||
	/** Downloading missing keys into keyring. */
 | 
			
		||||
	ALPM_EVENT_KEY_DOWNLOAD_START,
 | 
			
		||||
	/** Key downloading is finished. */
 | 
			
		||||
	ALPM_EVENT_KEY_DOWNLOAD_DONE
 | 
			
		||||
} alpm_event_t;
 | 
			
		||||
 | 
			
		||||
/** Event callback */
 | 
			
		||||
typedef void (*alpm_cb_event)(alpm_event_t, void *, void *);
 | 
			
		||||
 | 
			
		||||
/** Questions */
 | 
			
		||||
/**
 | 
			
		||||
 * Questions.
 | 
			
		||||
 * Unlike the events or progress enumerations, this enum has bitmask values
 | 
			
		||||
 * so a frontend can use a bitmask map to supply preselected answers to the
 | 
			
		||||
 * different types of questions.
 | 
			
		||||
 */
 | 
			
		||||
typedef enum _alpm_question_t {
 | 
			
		||||
	ALPM_QUESTION_INSTALL_IGNOREPKG = 1,
 | 
			
		||||
	ALPM_QUESTION_REPLACE_PKG = (1 << 1),
 | 
			
		||||
@@ -366,11 +418,14 @@ typedef void (*alpm_cb_question)(alpm_question_t, void *, void *, void *, int *)
 | 
			
		||||
typedef enum _alpm_progress_t {
 | 
			
		||||
	ALPM_PROGRESS_ADD_START,
 | 
			
		||||
	ALPM_PROGRESS_UPGRADE_START,
 | 
			
		||||
	ALPM_PROGRESS_DOWNGRADE_START,
 | 
			
		||||
	ALPM_PROGRESS_REINSTALL_START,
 | 
			
		||||
	ALPM_PROGRESS_REMOVE_START,
 | 
			
		||||
	ALPM_PROGRESS_CONFLICTS_START,
 | 
			
		||||
	ALPM_PROGRESS_DISKSPACE_START,
 | 
			
		||||
	ALPM_PROGRESS_INTEGRITY_START,
 | 
			
		||||
	ALPM_PROGRESS_LOAD_START,
 | 
			
		||||
	ALPM_PROGRESS_KEYRING_START
 | 
			
		||||
} alpm_progress_t;
 | 
			
		||||
 | 
			
		||||
/** Progress callback */
 | 
			
		||||
@@ -530,8 +585,8 @@ const char *alpm_option_get_arch(alpm_handle_t *handle);
 | 
			
		||||
/** Sets the targeted architecture. */
 | 
			
		||||
int alpm_option_set_arch(alpm_handle_t *handle, const char *arch);
 | 
			
		||||
 | 
			
		||||
int alpm_option_get_usedelta(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_usedelta(alpm_handle_t *handle, int usedelta);
 | 
			
		||||
double alpm_option_get_deltaratio(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio);
 | 
			
		||||
 | 
			
		||||
int alpm_option_get_checkspace(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
 | 
			
		||||
@@ -539,6 +594,12 @@ int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
 | 
			
		||||
alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
 | 
			
		||||
 | 
			
		||||
alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
 | 
			
		||||
 | 
			
		||||
alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
 | 
			
		||||
int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup alpm_api_databases Database Functions
 | 
			
		||||
@@ -552,7 +613,7 @@ int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t leve
 | 
			
		||||
 * libalpm functions.
 | 
			
		||||
 * @return a reference to the local database
 | 
			
		||||
 */
 | 
			
		||||
alpm_db_t *alpm_option_get_localdb(alpm_handle_t *handle);
 | 
			
		||||
alpm_db_t *alpm_get_localdb(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
/** Get the list of sync databases.
 | 
			
		||||
 * Returns a list of alpm_db_t structures, one for each registered
 | 
			
		||||
@@ -560,7 +621,7 @@ alpm_db_t *alpm_option_get_localdb(alpm_handle_t *handle);
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @return a reference to an internal list of alpm_db_t structures
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_option_get_syncdbs(alpm_handle_t *handle);
 | 
			
		||||
alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
/** Register a sync database of packages.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
@@ -569,21 +630,21 @@ alpm_list_t *alpm_option_get_syncdbs(alpm_handle_t *handle);
 | 
			
		||||
 * database; note that this must be a '.sig' file type verification
 | 
			
		||||
 * @return an alpm_db_t* on success (the value), NULL on error
 | 
			
		||||
 */
 | 
			
		||||
alpm_db_t *alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
 | 
			
		||||
alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename,
 | 
			
		||||
		alpm_siglevel_t level);
 | 
			
		||||
 | 
			
		||||
/** Unregister all package databases.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_unregister_all_syncdbs(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
/** Unregister a package database.
 | 
			
		||||
 * @param db pointer to the package database to unregister
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_db_unregister(alpm_db_t *db);
 | 
			
		||||
 | 
			
		||||
/** Unregister all package databases.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_db_unregister_all(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
/** Get the name of a package database.
 | 
			
		||||
 * @param db pointer to the package database
 | 
			
		||||
 * @return the name of the package database, NULL on error
 | 
			
		||||
@@ -615,7 +676,7 @@ int alpm_db_add_server(alpm_db_t *db, const char *url);
 | 
			
		||||
int alpm_db_remove_server(alpm_db_t *db, const char *url);
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
int alpm_db_update(int level, alpm_db_t *db);
 | 
			
		||||
int alpm_db_update(int force, alpm_db_t *db);
 | 
			
		||||
 | 
			
		||||
/** Get a package entry from a package database.
 | 
			
		||||
 * @param db pointer to the package database to get the package from
 | 
			
		||||
@@ -635,7 +696,7 @@ alpm_list_t *alpm_db_get_pkgcache(alpm_db_t *db);
 | 
			
		||||
 * @param name of the group
 | 
			
		||||
 * @return the groups entry on success, NULL on error
 | 
			
		||||
 */
 | 
			
		||||
alpm_group_t *alpm_db_readgroup(alpm_db_t *db, const char *name);
 | 
			
		||||
alpm_group_t *alpm_db_get_group(alpm_db_t *db, const char *name);
 | 
			
		||||
 | 
			
		||||
/** Get the group cache of a package database.
 | 
			
		||||
 * @param db pointer to the package database to get the group from
 | 
			
		||||
@@ -648,16 +709,7 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
 | 
			
		||||
 * @param needles a list of regular expressions to search for
 | 
			
		||||
 * @return the list of packages matching all regular expressions on success, NULL on error
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t* needles);
 | 
			
		||||
 | 
			
		||||
/** Set install reason for a package in db.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param pkg the package to update
 | 
			
		||||
 * @param reason the new install reason
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_db_set_pkgreason(alpm_handle_t *handle, alpm_pkg_t *pkg,
 | 
			
		||||
		alpm_pkgreason_t reason);
 | 
			
		||||
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
@@ -683,6 +735,13 @@ int alpm_db_set_pkgreason(alpm_handle_t *handle, alpm_pkg_t *pkg,
 | 
			
		||||
int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
 | 
			
		||||
		alpm_siglevel_t level, alpm_pkg_t **pkg);
 | 
			
		||||
 | 
			
		||||
/** Find a package in a list by name.
 | 
			
		||||
 * @param haystack a list of alpm_pkg_t
 | 
			
		||||
 * @param needle the package name
 | 
			
		||||
 * @return a pointer to the package if found or NULL
 | 
			
		||||
 */
 | 
			
		||||
alpm_pkg_t *alpm_pkg_find(alpm_list_t *haystack, const char *needle);
 | 
			
		||||
 | 
			
		||||
/** Free a package.
 | 
			
		||||
 * @param pkg package pointer to free
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
@@ -706,6 +765,14 @@ int alpm_pkg_vercmp(const char *a, const char *b);
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Computes the list of packages optionally requiring a given package.
 | 
			
		||||
 * The return value of this function is a newly allocated
 | 
			
		||||
 * list of package names (char*), it should be freed by the caller.
 | 
			
		||||
 * @param pkg a package
 | 
			
		||||
 * @return the list of packages optionally requiring pkg
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_pkg_compute_optionalfor(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** @name Package Property Accessors
 | 
			
		||||
 * Any pointer returned by these functions points to internal structures
 | 
			
		||||
 * allocated by libalpm. They should not be freed nor modified in any
 | 
			
		||||
@@ -754,13 +821,13 @@ const char *alpm_pkg_get_url(alpm_pkg_t *pkg);
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return the timestamp of the build time
 | 
			
		||||
 */
 | 
			
		||||
time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg);
 | 
			
		||||
alpm_time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Returns the install timestamp of the package.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return the timestamp of the install time
 | 
			
		||||
 */
 | 
			
		||||
time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg);
 | 
			
		||||
alpm_time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Returns the packager's name.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
@@ -827,7 +894,7 @@ alpm_list_t *alpm_pkg_get_depends(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Returns the list of package optional dependencies.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return a reference to an internal list of strings.
 | 
			
		||||
 * @return a reference to an internal list of alpm_depend_t structures.
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_pkg_get_optdepends(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
@@ -869,7 +936,7 @@ alpm_filelist_t *alpm_pkg_get_files(alpm_pkg_t *pkg);
 | 
			
		||||
 * "<filename>\t<md5sum>", where the given md5sum is that of
 | 
			
		||||
 * the file as provided by the package.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return a reference to an internal list of strings.
 | 
			
		||||
 * @return a reference to a list of alpm_backup_t objects
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *alpm_pkg_get_backup(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
@@ -881,12 +948,18 @@ alpm_list_t *alpm_pkg_get_backup(alpm_pkg_t *pkg);
 | 
			
		||||
 */
 | 
			
		||||
alpm_db_t *alpm_pkg_get_db(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Retuns the base64 encoded package signature.
 | 
			
		||||
/** Returns the base64 encoded package signature.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return a reference to an internal string
 | 
			
		||||
 */
 | 
			
		||||
const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Returns the method used to validate a package during install.
 | 
			
		||||
 * @param pkg a pointer to package
 | 
			
		||||
 * @return an enum member giving the validation method
 | 
			
		||||
 */
 | 
			
		||||
alpm_pkgvalidation_t alpm_pkg_get_validation(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/* End of alpm_pkg_t accessors */
 | 
			
		||||
/* @} */
 | 
			
		||||
 | 
			
		||||
@@ -913,6 +986,23 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
 | 
			
		||||
 | 
			
		||||
int alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp);
 | 
			
		||||
 | 
			
		||||
/** Open a package mtree file for reading.
 | 
			
		||||
 * @param pkg the local package to read the changelog of
 | 
			
		||||
 * @return a archive structure for the package mtree file
 | 
			
		||||
 */
 | 
			
		||||
struct archive *alpm_pkg_mtree_open(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Read next entry from a package mtree file.
 | 
			
		||||
 * @param pkg the package that the mtree file is being read from
 | 
			
		||||
 * @param archive the archive structure reading from the mtree file
 | 
			
		||||
 * @param entry an archive_entry to store the entry header information
 | 
			
		||||
 * @return 0 if end of archive is reached, non-zero otherwise.
 | 
			
		||||
 */
 | 
			
		||||
int alpm_pkg_mtree_next(const alpm_pkg_t *pkg, struct archive *archive,
 | 
			
		||||
		struct archive_entry **entry);
 | 
			
		||||
 | 
			
		||||
int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive);
 | 
			
		||||
 | 
			
		||||
/** Returns whether the package has an install scriptlet.
 | 
			
		||||
 * @return 0 if FALSE, TRUE otherwise
 | 
			
		||||
 */
 | 
			
		||||
@@ -928,9 +1018,33 @@ off_t alpm_pkg_download_size(alpm_pkg_t *newpkg);
 | 
			
		||||
 | 
			
		||||
alpm_list_t *alpm_pkg_unused_deltas(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
/** Set install reason for a package in the local database.
 | 
			
		||||
 * The provided package object must be from the local database or this method
 | 
			
		||||
 * will fail. The write to the local database is performed immediately.
 | 
			
		||||
 * @param pkg the package to update
 | 
			
		||||
 * @param reason the new install reason
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* End of alpm_pkg */
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Filelists
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Determines whether a package filelist contains a given path.
 | 
			
		||||
 * The provided path should be relative to the install root with no leading
 | 
			
		||||
 * slashes, e.g. "etc/localtime". When searching for directories, the path must
 | 
			
		||||
 * have a trailing slash.
 | 
			
		||||
 * @param filelist a pointer to a package filelist
 | 
			
		||||
 * @param path the path to search for in the package
 | 
			
		||||
 * @return a pointer to the matching file or NULL if not found
 | 
			
		||||
 */
 | 
			
		||||
char *alpm_filelist_contains(alpm_filelist_t *filelist, const char *path);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Signatures
 | 
			
		||||
 */
 | 
			
		||||
@@ -1032,7 +1146,7 @@ int alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data);
 | 
			
		||||
/** Commit a transaction.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param data the address of an alpm_list where detailed description
 | 
			
		||||
 * of an error can be dumped (ie. list of conflicting files)
 | 
			
		||||
 * of an error can be dumped (i.e. list of conflicting files)
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data);
 | 
			
		||||
@@ -1107,13 +1221,13 @@ char *alpm_dep_compute_string(const alpm_depend_t *dep);
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* checksums */
 | 
			
		||||
char *alpm_compute_md5sum(const char *name);
 | 
			
		||||
char *alpm_compute_md5sum(const char *filename);
 | 
			
		||||
char *alpm_compute_sha256sum(const char *filename);
 | 
			
		||||
 | 
			
		||||
/** @addtogroup alpm_api_errors Error Codes
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
enum _alpm_errno_t {
 | 
			
		||||
typedef enum _alpm_errno_t {
 | 
			
		||||
	ALPM_ERR_MEMORY = 1,
 | 
			
		||||
	ALPM_ERR_SYSTEM,
 | 
			
		||||
	ALPM_ERR_BADPERMS,
 | 
			
		||||
@@ -1177,19 +1291,19 @@ enum _alpm_errno_t {
 | 
			
		||||
	ALPM_ERR_LIBCURL,
 | 
			
		||||
	ALPM_ERR_EXTERNAL_DOWNLOAD,
 | 
			
		||||
	ALPM_ERR_GPGME
 | 
			
		||||
};
 | 
			
		||||
} alpm_errno_t;
 | 
			
		||||
 | 
			
		||||
/** Returns the current error code from the handle. */
 | 
			
		||||
enum _alpm_errno_t alpm_errno(alpm_handle_t *handle);
 | 
			
		||||
alpm_errno_t alpm_errno(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
/** Returns the string corresponding to an error number. */
 | 
			
		||||
const char *alpm_strerror(enum _alpm_errno_t err);
 | 
			
		||||
const char *alpm_strerror(alpm_errno_t err);
 | 
			
		||||
 | 
			
		||||
/* End of alpm_api_errors */
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
 | 
			
		||||
		enum _alpm_errno_t *err);
 | 
			
		||||
		alpm_errno_t *err);
 | 
			
		||||
int alpm_release(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
enum alpm_caps {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  alpm_list.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -204,7 +204,8 @@ alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second)
 | 
			
		||||
 *
 | 
			
		||||
 * @return the resultant list
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn)
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right,
 | 
			
		||||
		alpm_list_fn_cmp fn)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *newlist, *lp, *tail_ptr, *left_tail_ptr, *right_tail_ptr;
 | 
			
		||||
 | 
			
		||||
@@ -273,17 +274,26 @@ alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, a
 | 
			
		||||
 *
 | 
			
		||||
 * @return the resultant list
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn_cmp fn)
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n,
 | 
			
		||||
		alpm_list_fn_cmp fn)
 | 
			
		||||
{
 | 
			
		||||
	if(n > 1) {
 | 
			
		||||
		alpm_list_t *left = list;
 | 
			
		||||
		alpm_list_t *lastleft = alpm_list_nth(list, n/2 - 1);
 | 
			
		||||
		alpm_list_t *right = lastleft->next;
 | 
			
		||||
		/* terminate first list */
 | 
			
		||||
		lastleft->next = NULL;
 | 
			
		||||
		size_t half = n / 2;
 | 
			
		||||
		size_t i = half - 1;
 | 
			
		||||
		alpm_list_t *left = list, *lastleft = list, *right;
 | 
			
		||||
 | 
			
		||||
		left = alpm_list_msort(left, n/2, fn);
 | 
			
		||||
		right = alpm_list_msort(right, n - (n/2), fn);
 | 
			
		||||
		while(i--) {
 | 
			
		||||
			lastleft = lastleft->next;
 | 
			
		||||
		}
 | 
			
		||||
		right = lastleft->next;
 | 
			
		||||
 | 
			
		||||
		/* tidy new lists */
 | 
			
		||||
		lastleft->next = NULL;
 | 
			
		||||
		right->prev = left->prev;
 | 
			
		||||
		left->prev = lastleft;
 | 
			
		||||
 | 
			
		||||
		left = alpm_list_msort(left, half, fn);
 | 
			
		||||
		right = alpm_list_msort(right, n - half, fn);
 | 
			
		||||
		list = alpm_list_mmerge(left, right, fn);
 | 
			
		||||
	}
 | 
			
		||||
	return list;
 | 
			
		||||
@@ -576,19 +586,6 @@ alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Get the data member of a list node.
 | 
			
		||||
 *
 | 
			
		||||
 * @param node the list node
 | 
			
		||||
 *
 | 
			
		||||
 * @return the contained data, or NULL if none
 | 
			
		||||
 */
 | 
			
		||||
void SYMEXPORT *alpm_list_getdata(const alpm_list_t *node)
 | 
			
		||||
{
 | 
			
		||||
	if(node == NULL) return NULL;
 | 
			
		||||
	return node->data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Misc */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  alpm_list.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -71,7 +71,6 @@ alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n);
 | 
			
		||||
alpm_list_t *alpm_list_next(const alpm_list_t *list);
 | 
			
		||||
alpm_list_t *alpm_list_previous(const alpm_list_t *list);
 | 
			
		||||
alpm_list_t *alpm_list_last(const alpm_list_t *list);
 | 
			
		||||
void *alpm_list_getdata(const alpm_list_t *entry);
 | 
			
		||||
 | 
			
		||||
/* misc */
 | 
			
		||||
size_t alpm_list_count(const alpm_list_t *list);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  backup.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
 | 
			
		||||
@@ -21,8 +21,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  backup.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,8 @@
 | 
			
		||||
 *  * removal of SELF_TEST code
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#include "base64.h"
 | 
			
		||||
 | 
			
		||||
static const unsigned char base64_enc_map[64] =
 | 
			
		||||
@@ -62,6 +64,7 @@ static const unsigned char base64_dec_map[128] =
 | 
			
		||||
     49,  50,  51, 127, 127, 127, 127, 127
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
/*
 | 
			
		||||
 * Encode a buffer into base64 format
 | 
			
		||||
 */
 | 
			
		||||
@@ -124,6 +127,7 @@ int base64_encode( unsigned char *dst, size_t *dlen,
 | 
			
		||||
 | 
			
		||||
    return( 0 );
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Decode a base64-formatted buffer
 | 
			
		||||
@@ -131,8 +135,8 @@ int base64_encode( unsigned char *dst, size_t *dlen,
 | 
			
		||||
int base64_decode( unsigned char *dst, size_t *dlen,
 | 
			
		||||
                   const unsigned char *src, size_t slen )
 | 
			
		||||
{
 | 
			
		||||
    size_t i, j, n;
 | 
			
		||||
    unsigned long x;
 | 
			
		||||
    size_t i, n;
 | 
			
		||||
    uint32_t j, x;
 | 
			
		||||
    unsigned char *p;
 | 
			
		||||
 | 
			
		||||
    for( i = j = n = 0; i < slen; i++ )
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@
 | 
			
		||||
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x0010  /**< Output buffer too small. */
 | 
			
		||||
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER              -0x0012  /**< Invalid character in input. */
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
/**
 | 
			
		||||
 * \brief          Encode a buffer into base64 format
 | 
			
		||||
 *
 | 
			
		||||
@@ -47,6 +48,7 @@
 | 
			
		||||
 */
 | 
			
		||||
int base64_encode( unsigned char *dst, size_t *dlen,
 | 
			
		||||
                   const unsigned char *src, size_t slen );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief          Decode a base64-formatted buffer
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  be_local.c : backend for the local database
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,8 +18,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
@@ -28,18 +26,23 @@
 | 
			
		||||
#include <stdint.h> /* intmax_t */
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <limits.h> /* PATH_MAX */
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
#include <archive_entry.h>
 | 
			
		||||
 | 
			
		||||
/* libalpm */
 | 
			
		||||
#include "db.h"
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "libarchive-compat.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "handle.h"
 | 
			
		||||
#include "package.h"
 | 
			
		||||
#include "deps.h"
 | 
			
		||||
#include "filelist.h"
 | 
			
		||||
 | 
			
		||||
static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
 | 
			
		||||
 | 
			
		||||
@@ -69,13 +72,13 @@ static const char *_cache_get_url(alpm_pkg_t *pkg)
 | 
			
		||||
	return pkg->url;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static time_t _cache_get_builddate(alpm_pkg_t *pkg)
 | 
			
		||||
static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	LAZY_LOAD(INFRQ_DESC, 0);
 | 
			
		||||
	return pkg->builddate;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static time_t _cache_get_installdate(alpm_pkg_t *pkg)
 | 
			
		||||
static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	LAZY_LOAD(INFRQ_DESC, 0);
 | 
			
		||||
	return pkg->installdate;
 | 
			
		||||
@@ -105,6 +108,12 @@ static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg)
 | 
			
		||||
	return pkg->reason;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_pkgvalidation_t _cache_get_validation(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	LAZY_LOAD(INFRQ_DESC, -1);
 | 
			
		||||
	return pkg->validation;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_list_t *_cache_get_licenses(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	LAZY_LOAD(INFRQ_DESC, NULL);
 | 
			
		||||
@@ -207,6 +216,73 @@ static int _cache_changelog_close(const alpm_pkg_t UNUSED *pkg, void *fp)
 | 
			
		||||
	return fclose((FILE *)fp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Open a package mtree file for reading.
 | 
			
		||||
 * @param pkg the local package to read the changelog of
 | 
			
		||||
 * @return a archive structure for the package mtree file
 | 
			
		||||
 */
 | 
			
		||||
static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	int r;
 | 
			
		||||
	struct archive *mtree;
 | 
			
		||||
 | 
			
		||||
	alpm_db_t *db = alpm_pkg_get_db(pkg);
 | 
			
		||||
	char *mtfile = _alpm_local_db_pkgpath(db, pkg, "mtree");
 | 
			
		||||
 | 
			
		||||
	if(access(mtfile, F_OK) != 0) {
 | 
			
		||||
		/* there is no mtree file for this package */
 | 
			
		||||
		goto error;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if((mtree = archive_read_new()) == NULL) {
 | 
			
		||||
		pkg->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
 | 
			
		||||
		goto error;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_alpm_archive_read_support_filter_all(mtree);
 | 
			
		||||
	archive_read_support_format_mtree(mtree);
 | 
			
		||||
 | 
			
		||||
	if((r = _alpm_archive_read_open_file(mtree, mtfile, ALPM_BUFFER_SIZE))) {
 | 
			
		||||
		_alpm_log(pkg->handle, ALPM_LOG_ERROR, _("error while reading file %s: %s\n"),
 | 
			
		||||
					mtfile, archive_error_string(mtree));
 | 
			
		||||
		pkg->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
 | 
			
		||||
		_alpm_archive_read_free(mtree);
 | 
			
		||||
		goto error;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	free(mtfile);
 | 
			
		||||
	return mtree;
 | 
			
		||||
 | 
			
		||||
error:
 | 
			
		||||
	free(mtfile);
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Read next entry from a package mtree file.
 | 
			
		||||
 * @param pkg the package that the mtree file is being read from
 | 
			
		||||
 * @param archive the archive structure reading from the mtree file
 | 
			
		||||
 * @param entry an archive_entry to store the entry header information
 | 
			
		||||
 * @return 0 if end of archive is reached, non-zero otherwise.
 | 
			
		||||
 */
 | 
			
		||||
static int _cache_mtree_next(const alpm_pkg_t UNUSED *pkg,
 | 
			
		||||
		struct archive *mtree, struct archive_entry **entry)
 | 
			
		||||
{
 | 
			
		||||
	return archive_read_next_header(mtree, entry);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Close a package mtree file for reading.
 | 
			
		||||
 * @param pkg the package that the mtree file was read from
 | 
			
		||||
 * @param mtree the archive structure use for reading from the mtree file
 | 
			
		||||
 * @return whether closing the package changelog stream was successful
 | 
			
		||||
 */
 | 
			
		||||
static int _cache_mtree_close(const alpm_pkg_t UNUSED *pkg,
 | 
			
		||||
		struct archive *mtree)
 | 
			
		||||
{
 | 
			
		||||
	return _alpm_archive_read_free(mtree);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _cache_force_load(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	return local_db_read(pkg, INFRQ_ALL);
 | 
			
		||||
@@ -226,6 +302,7 @@ static struct pkg_operations local_pkg_ops = {
 | 
			
		||||
	.get_arch        = _cache_get_arch,
 | 
			
		||||
	.get_isize       = _cache_get_isize,
 | 
			
		||||
	.get_reason      = _cache_get_reason,
 | 
			
		||||
	.get_validation  = _cache_get_validation,
 | 
			
		||||
	.has_scriptlet   = _cache_has_scriptlet,
 | 
			
		||||
	.get_licenses    = _cache_get_licenses,
 | 
			
		||||
	.get_groups      = _cache_get_groups,
 | 
			
		||||
@@ -241,6 +318,10 @@ static struct pkg_operations local_pkg_ops = {
 | 
			
		||||
	.changelog_read  = _cache_changelog_read,
 | 
			
		||||
	.changelog_close = _cache_changelog_close,
 | 
			
		||||
 | 
			
		||||
	.mtree_open      = _cache_mtree_open,
 | 
			
		||||
	.mtree_next      = _cache_mtree_next,
 | 
			
		||||
	.mtree_close     = _cache_mtree_close,
 | 
			
		||||
 | 
			
		||||
	.force_load      = _cache_force_load,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -401,12 +482,11 @@ static int local_db_populate(alpm_db_t *db)
 | 
			
		||||
		rewinddir(dbdir);
 | 
			
		||||
	}
 | 
			
		||||
	if(est_count >= 2) {
 | 
			
		||||
		/* subtract the two extra pointers to get # of children */
 | 
			
		||||
		/* subtract the '.' and '..' pointers to get # of children */
 | 
			
		||||
		est_count -= 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* initialize hash at 50% full */
 | 
			
		||||
	db->pkgcache = _alpm_pkghash_create(est_count * 2);
 | 
			
		||||
	db->pkgcache = _alpm_pkghash_create(est_count);
 | 
			
		||||
	if(db->pkgcache == NULL){
 | 
			
		||||
		closedir(dbdir);
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
 | 
			
		||||
@@ -445,7 +525,7 @@ static int local_db_populate(alpm_db_t *db)
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		pkg->origin = PKG_FROM_LOCALDB;
 | 
			
		||||
		pkg->origin = ALPM_PKG_FROM_LOCALDB;
 | 
			
		||||
		pkg->origin_data.db = db;
 | 
			
		||||
		pkg->ops = &local_pkg_ops;
 | 
			
		||||
		pkg->handle = db->handle;
 | 
			
		||||
@@ -475,7 +555,8 @@ static int local_db_populate(alpm_db_t *db)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Note: the return value must be freed by the caller */
 | 
			
		||||
char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename)
 | 
			
		||||
char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
 | 
			
		||||
		const char *filename)
 | 
			
		||||
{
 | 
			
		||||
	size_t len;
 | 
			
		||||
	char *pkgpath;
 | 
			
		||||
@@ -492,7 +573,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filena
 | 
			
		||||
 | 
			
		||||
#define READ_NEXT() do { \
 | 
			
		||||
	if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \
 | 
			
		||||
	_alpm_strip_newline(line); \
 | 
			
		||||
	_alpm_strip_newline(line, 0); \
 | 
			
		||||
} while(0)
 | 
			
		||||
 | 
			
		||||
#define READ_AND_STORE(f) do { \
 | 
			
		||||
@@ -505,7 +586,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filena
 | 
			
		||||
	if(fgets(line, sizeof(line), fp) == NULL) {\
 | 
			
		||||
		if(!feof(fp)) goto error; else break; \
 | 
			
		||||
	} \
 | 
			
		||||
	if(_alpm_strip_newline(line) == 0) break; \
 | 
			
		||||
	if(_alpm_strip_newline(line, 0) == 0) break; \
 | 
			
		||||
	STRDUP(linedup, line, goto error); \
 | 
			
		||||
	f = alpm_list_add(f, linedup); \
 | 
			
		||||
} while(1) /* note the while(1) and not (0) */
 | 
			
		||||
@@ -514,7 +595,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filena
 | 
			
		||||
	if(fgets(line, sizeof(line), fp) == NULL) {\
 | 
			
		||||
		if(!feof(fp)) goto error; else break; \
 | 
			
		||||
	} \
 | 
			
		||||
	if(_alpm_strip_newline(line) == 0) break; \
 | 
			
		||||
	if(_alpm_strip_newline(line, 0) == 0) break; \
 | 
			
		||||
	f = alpm_list_add(f, _alpm_splitdep(line)); \
 | 
			
		||||
} while(1) /* note the while(1) and not (0) */
 | 
			
		||||
 | 
			
		||||
@@ -522,7 +603,6 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
{
 | 
			
		||||
	FILE *fp = NULL;
 | 
			
		||||
	char line[1024];
 | 
			
		||||
	char *pkgpath;
 | 
			
		||||
	alpm_db_t *db = info->origin_data.db;
 | 
			
		||||
 | 
			
		||||
	/* bitmask logic here:
 | 
			
		||||
@@ -541,18 +621,10 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_alpm_log(db->handle, ALPM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
 | 
			
		||||
	_alpm_log(db->handle, ALPM_LOG_FUNCTION,
 | 
			
		||||
			"loading package data for %s : level=0x%x\n",
 | 
			
		||||
			info->name, inforeq);
 | 
			
		||||
 | 
			
		||||
	pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
 | 
			
		||||
	if(!pkgpath || access(pkgpath, F_OK)) {
 | 
			
		||||
		/* directory doesn't exist or can't be opened */
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n",
 | 
			
		||||
				info->name, info->version, db->treename);
 | 
			
		||||
		goto error;
 | 
			
		||||
	}
 | 
			
		||||
	free(pkgpath);
 | 
			
		||||
 | 
			
		||||
	/* clear out 'line', to be certain - and to make valgrind happy */
 | 
			
		||||
	memset(line, 0, sizeof(line));
 | 
			
		||||
 | 
			
		||||
@@ -569,7 +641,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
			if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) {
 | 
			
		||||
				goto error;
 | 
			
		||||
			}
 | 
			
		||||
			if(_alpm_strip_newline(line) == 0) {
 | 
			
		||||
			if(_alpm_strip_newline(line, 0) == 0) {
 | 
			
		||||
				/* length of stripped line was zero */
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
@@ -606,6 +678,26 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
			} else if(strcmp(line, "%REASON%") == 0) {
 | 
			
		||||
				READ_NEXT();
 | 
			
		||||
				info->reason = (alpm_pkgreason_t)atoi(line);
 | 
			
		||||
			} else if(strcmp(line, "%VALIDATION%") == 0) {
 | 
			
		||||
				alpm_list_t *i, *v = NULL;
 | 
			
		||||
				READ_AND_STORE_ALL(v);
 | 
			
		||||
				for(i = v; i; i = alpm_list_next(i))
 | 
			
		||||
				{
 | 
			
		||||
					if(strcmp(i->data, "none") == 0) {
 | 
			
		||||
						info->validation |= ALPM_PKG_VALIDATION_NONE;
 | 
			
		||||
					} else if(strcmp(i->data, "md5") == 0) {
 | 
			
		||||
						info->validation |= ALPM_PKG_VALIDATION_MD5SUM;
 | 
			
		||||
					} else if(strcmp(i->data, "sha256") == 0) {
 | 
			
		||||
						info->validation |= ALPM_PKG_VALIDATION_SHA256SUM;
 | 
			
		||||
					} else if(strcmp(i->data, "pgp") == 0) {
 | 
			
		||||
						info->validation |= ALPM_PKG_VALIDATION_SIGNATURE;
 | 
			
		||||
					} else {
 | 
			
		||||
						_alpm_log(db->handle, ALPM_LOG_WARNING,
 | 
			
		||||
								_("unknown validation type for package %s: %s\n"),
 | 
			
		||||
								info->name, (const char *)i->data);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				FREELIST(v);
 | 
			
		||||
			} else if(strcmp(line, "%SIZE%") == 0) {
 | 
			
		||||
				READ_NEXT();
 | 
			
		||||
				info->isize = _alpm_strtoofft(line);
 | 
			
		||||
@@ -614,7 +706,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
			} else if(strcmp(line, "%DEPENDS%") == 0) {
 | 
			
		||||
				READ_AND_SPLITDEP(info->depends);
 | 
			
		||||
			} else if(strcmp(line, "%OPTDEPENDS%") == 0) {
 | 
			
		||||
				READ_AND_STORE_ALL(info->optdepends);
 | 
			
		||||
				READ_AND_SPLITDEP(info->optdepends);
 | 
			
		||||
			} else if(strcmp(line, "%CONFLICTS%") == 0) {
 | 
			
		||||
				READ_AND_SPLITDEP(info->conflicts);
 | 
			
		||||
			} else if(strcmp(line, "%PROVIDES%") == 0) {
 | 
			
		||||
@@ -636,12 +728,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
		}
 | 
			
		||||
		free(path);
 | 
			
		||||
		while(fgets(line, sizeof(line), fp)) {
 | 
			
		||||
			_alpm_strip_newline(line);
 | 
			
		||||
			_alpm_strip_newline(line, 0);
 | 
			
		||||
			if(strcmp(line, "%FILES%") == 0) {
 | 
			
		||||
				size_t files_count = 0, files_size = 0;
 | 
			
		||||
				size_t files_count = 0, files_size = 0, len;
 | 
			
		||||
				alpm_file_t *files = NULL;
 | 
			
		||||
 | 
			
		||||
				while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line)) {
 | 
			
		||||
				while(fgets(line, sizeof(line), fp) &&
 | 
			
		||||
						(len = _alpm_strip_newline(line, 0))) {
 | 
			
		||||
					if(files_count >= files_size) {
 | 
			
		||||
						size_t old_size = files_size;
 | 
			
		||||
						if(files_size == 0) {
 | 
			
		||||
@@ -651,7 +744,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
						}
 | 
			
		||||
						files = realloc(files, sizeof(alpm_file_t) * files_size);
 | 
			
		||||
						if(!files) {
 | 
			
		||||
							ALLOC_FAIL(sizeof(alpm_file_t) * files_size);
 | 
			
		||||
							_alpm_alloc_fail(sizeof(alpm_file_t) * files_size);
 | 
			
		||||
							goto error;
 | 
			
		||||
						}
 | 
			
		||||
						/* ensure all new memory is zeroed out, in both the initial
 | 
			
		||||
@@ -659,16 +752,25 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
						memset(files + old_size, 0,
 | 
			
		||||
								sizeof(alpm_file_t) * (files_size - old_size));
 | 
			
		||||
					}
 | 
			
		||||
					STRDUP(files[files_count].name, line, goto error);
 | 
			
		||||
					/* TODO: lstat file, get mode/size */
 | 
			
		||||
					/* since we know the length of the file string already,
 | 
			
		||||
					 * we can do malloc + memcpy rather than strdup */
 | 
			
		||||
					len += 1;
 | 
			
		||||
					files[files_count].name = malloc(len);
 | 
			
		||||
					if(files[files_count].name == NULL) {
 | 
			
		||||
						_alpm_alloc_fail(len);
 | 
			
		||||
						goto error;
 | 
			
		||||
					}
 | 
			
		||||
					memcpy(files[files_count].name, line, len);
 | 
			
		||||
					files_count++;
 | 
			
		||||
				}
 | 
			
		||||
				/* attempt to hand back any memory we don't need */
 | 
			
		||||
				files = realloc(files, sizeof(alpm_file_t) * files_count);
 | 
			
		||||
				/* make sure the list is sorted */
 | 
			
		||||
				qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
 | 
			
		||||
				info->files.count = files_count;
 | 
			
		||||
				info->files.files = files;
 | 
			
		||||
			} else if(strcmp(line, "%BACKUP%") == 0) {
 | 
			
		||||
				while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line)) {
 | 
			
		||||
				while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line, 0)) {
 | 
			
		||||
					alpm_backup_t *backup;
 | 
			
		||||
					CALLOC(backup, 1, sizeof(alpm_backup_t), goto error);
 | 
			
		||||
					if(_alpm_split_backup(line, &backup)) {
 | 
			
		||||
@@ -727,6 +829,23 @@ int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info)
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *lp;
 | 
			
		||||
	if(!deplist) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	fputs(header, fp);
 | 
			
		||||
	fputc('\n', fp);
 | 
			
		||||
	for(lp = deplist; lp; lp = lp->next) {
 | 
			
		||||
		char *depstring = alpm_dep_compute_string(lp->data);
 | 
			
		||||
		fputs(depstring, fp);
 | 
			
		||||
		fputc('\n', fp);
 | 
			
		||||
		free(depstring);
 | 
			
		||||
	}
 | 
			
		||||
	fputc('\n', fp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
 | 
			
		||||
{
 | 
			
		||||
	FILE *fp = NULL;
 | 
			
		||||
@@ -744,7 +863,8 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
 | 
			
		||||
	/* DESC */
 | 
			
		||||
	if(inforeq & INFRQ_DESC) {
 | 
			
		||||
		char *path;
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s DESC information back to db\n",
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG,
 | 
			
		||||
				"writing %s-%s DESC information back to db\n",
 | 
			
		||||
				info->name, info->version);
 | 
			
		||||
		path = _alpm_local_db_pkgpath(db, info, "desc");
 | 
			
		||||
		if(!path || (fp = fopen(path, "w")) == NULL) {
 | 
			
		||||
@@ -761,44 +881,21 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
 | 
			
		||||
			fprintf(fp, "%%DESC%%\n"
 | 
			
		||||
							"%s\n\n", info->desc);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->groups) {
 | 
			
		||||
			fputs("%GROUPS%\n", fp);
 | 
			
		||||
			for(lp = info->groups; lp; lp = lp->next) {
 | 
			
		||||
				fprintf(fp, "%s\n", (char *)lp->data);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if(info->replaces) {
 | 
			
		||||
			fputs("%REPLACES%\n", fp);
 | 
			
		||||
			for(lp = info->replaces; lp; lp = lp->next) {
 | 
			
		||||
				char *depstring = alpm_dep_compute_string(lp->data);
 | 
			
		||||
				fprintf(fp, "%s\n", depstring);
 | 
			
		||||
				free(depstring);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if(info->url) {
 | 
			
		||||
			fprintf(fp, "%%URL%%\n"
 | 
			
		||||
							"%s\n\n", info->url);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->licenses) {
 | 
			
		||||
			fputs("%LICENSE%\n", fp);
 | 
			
		||||
			for(lp = info->licenses; lp; lp = lp->next) {
 | 
			
		||||
				fprintf(fp, "%s\n", (char *)lp->data);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if(info->arch) {
 | 
			
		||||
			fprintf(fp, "%%ARCH%%\n"
 | 
			
		||||
							"%s\n\n", info->arch);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->builddate) {
 | 
			
		||||
			fprintf(fp, "%%BUILDDATE%%\n"
 | 
			
		||||
							"%ld\n\n", info->builddate);
 | 
			
		||||
							"%jd\n\n", (intmax_t)info->builddate);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->installdate) {
 | 
			
		||||
			fprintf(fp, "%%INSTALLDATE%%\n"
 | 
			
		||||
							"%ld\n\n", info->installdate);
 | 
			
		||||
							"%jd\n\n", (intmax_t)info->installdate);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->packager) {
 | 
			
		||||
			fprintf(fp, "%%PACKAGER%%\n"
 | 
			
		||||
@@ -813,41 +910,45 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
 | 
			
		||||
			fprintf(fp, "%%REASON%%\n"
 | 
			
		||||
							"%u\n\n", info->reason);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->depends) {
 | 
			
		||||
			fputs("%DEPENDS%\n", fp);
 | 
			
		||||
			for(lp = info->depends; lp; lp = lp->next) {
 | 
			
		||||
				char *depstring = alpm_dep_compute_string(lp->data);
 | 
			
		||||
				fprintf(fp, "%s\n", depstring);
 | 
			
		||||
				free(depstring);
 | 
			
		||||
		if(info->groups) {
 | 
			
		||||
			fputs("%GROUPS%\n", fp);
 | 
			
		||||
			for(lp = info->groups; lp; lp = lp->next) {
 | 
			
		||||
				fputs(lp->data, fp);
 | 
			
		||||
				fputc('\n', fp);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
			fputc('\n', fp);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->optdepends) {
 | 
			
		||||
			fputs("%OPTDEPENDS%\n", fp);
 | 
			
		||||
			for(lp = info->optdepends; lp; lp = lp->next) {
 | 
			
		||||
				fprintf(fp, "%s\n", (char *)lp->data);
 | 
			
		||||
		if(info->licenses) {
 | 
			
		||||
			fputs("%LICENSE%\n", fp);
 | 
			
		||||
			for(lp = info->licenses; lp; lp = lp->next) {
 | 
			
		||||
				fputs(lp->data, fp);
 | 
			
		||||
				fputc('\n', fp);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
			fputc('\n', fp);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->conflicts) {
 | 
			
		||||
			fputs("%CONFLICTS%\n", fp);
 | 
			
		||||
			for(lp = info->conflicts; lp; lp = lp->next) {
 | 
			
		||||
				char *depstring = alpm_dep_compute_string(lp->data);
 | 
			
		||||
				fprintf(fp, "%s\n", depstring);
 | 
			
		||||
				free(depstring);
 | 
			
		||||
		if(info->validation) {
 | 
			
		||||
			fputs("%VALIDATION%\n", fp);
 | 
			
		||||
			if(info->validation & ALPM_PKG_VALIDATION_NONE) {
 | 
			
		||||
				fputs("none\n", fp);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if(info->provides) {
 | 
			
		||||
			fputs("%PROVIDES%\n", fp);
 | 
			
		||||
			for(lp = info->provides; lp; lp = lp->next) {
 | 
			
		||||
				char *depstring = alpm_dep_compute_string(lp->data);
 | 
			
		||||
				fprintf(fp, "%s\n", depstring);
 | 
			
		||||
				free(depstring);
 | 
			
		||||
			if(info->validation & ALPM_PKG_VALIDATION_MD5SUM) {
 | 
			
		||||
				fputs("md5\n", fp);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
			if(info->validation & ALPM_PKG_VALIDATION_SHA256SUM) {
 | 
			
		||||
				fputs("sha256\n", fp);
 | 
			
		||||
			}
 | 
			
		||||
			if(info->validation & ALPM_PKG_VALIDATION_SIGNATURE) {
 | 
			
		||||
				fputs("pgp\n", fp);
 | 
			
		||||
			}
 | 
			
		||||
			fputc('\n', fp);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		write_deps(fp, "%REPLACES%", info->replaces);
 | 
			
		||||
		write_deps(fp, "%DEPENDS%", info->depends);
 | 
			
		||||
		write_deps(fp, "%OPTDEPENDS%", info->optdepends);
 | 
			
		||||
		write_deps(fp, "%CONFLICTS%", info->conflicts);
 | 
			
		||||
		write_deps(fp, "%PROVIDES%", info->provides);
 | 
			
		||||
 | 
			
		||||
		fclose(fp);
 | 
			
		||||
		fp = NULL;
 | 
			
		||||
	}
 | 
			
		||||
@@ -855,7 +956,8 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
 | 
			
		||||
	/* FILES */
 | 
			
		||||
	if(inforeq & INFRQ_FILES) {
 | 
			
		||||
		char *path;
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s FILES information back to db\n",
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG,
 | 
			
		||||
				"writing %s-%s FILES information back to db\n",
 | 
			
		||||
				info->name, info->version);
 | 
			
		||||
		path = _alpm_local_db_pkgpath(db, info, "files");
 | 
			
		||||
		if(!path || (fp = fopen(path, "w")) == NULL) {
 | 
			
		||||
@@ -868,20 +970,21 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
 | 
			
		||||
		free(path);
 | 
			
		||||
		if(info->files.count) {
 | 
			
		||||
			size_t i;
 | 
			
		||||
			fprintf(fp, "%%FILES%%\n");
 | 
			
		||||
			fputs("%FILES%\n", fp);
 | 
			
		||||
			for(i = 0; i < info->files.count; i++) {
 | 
			
		||||
				const alpm_file_t *file = info->files.files + i;
 | 
			
		||||
				fprintf(fp, "%s\n", file->name);
 | 
			
		||||
				fputs(file->name, fp);
 | 
			
		||||
				fputc('\n', fp);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
			fputc('\n', fp);
 | 
			
		||||
		}
 | 
			
		||||
		if(info->backup) {
 | 
			
		||||
			fprintf(fp, "%%BACKUP%%\n");
 | 
			
		||||
			fputs("%BACKUP%\n", fp);
 | 
			
		||||
			for(lp = info->backup; lp; lp = lp->next) {
 | 
			
		||||
				const alpm_backup_t *backup = lp->data;
 | 
			
		||||
				fprintf(fp, "%s\t%s\n", backup->name, backup->hash);
 | 
			
		||||
			}
 | 
			
		||||
			fprintf(fp, "\n");
 | 
			
		||||
			fputc('\n', fp);
 | 
			
		||||
		}
 | 
			
		||||
		fclose(fp);
 | 
			
		||||
		fp = NULL;
 | 
			
		||||
@@ -903,17 +1006,72 @@ cleanup:
 | 
			
		||||
int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info)
 | 
			
		||||
{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	char *pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
 | 
			
		||||
	DIR *dirp;
 | 
			
		||||
	struct dirent *dp;
 | 
			
		||||
	char *pkgpath;
 | 
			
		||||
	size_t pkgpath_len;
 | 
			
		||||
 | 
			
		||||
	/* TODO explicit file removes and then an rmdir? */
 | 
			
		||||
	ret = _alpm_rmrf(pkgpath);
 | 
			
		||||
	free(pkgpath);
 | 
			
		||||
	if(ret != 0) {
 | 
			
		||||
	pkgpath = _alpm_local_db_pkgpath(db, info, NULL);
 | 
			
		||||
	if(!pkgpath) {
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	pkgpath_len = strlen(pkgpath);
 | 
			
		||||
 | 
			
		||||
	dirp = opendir(pkgpath);
 | 
			
		||||
	if(!dirp) {
 | 
			
		||||
		free(pkgpath);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	/* go through the local DB entry, removing the files within, which we know
 | 
			
		||||
	 * are not nested directories of any kind. */
 | 
			
		||||
	for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
 | 
			
		||||
		if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) {
 | 
			
		||||
			char name[PATH_MAX];
 | 
			
		||||
			if(pkgpath_len + strlen(dp->d_name) + 2 > PATH_MAX) {
 | 
			
		||||
				/* file path is too long to remove, hmm. */
 | 
			
		||||
				ret = -1;
 | 
			
		||||
			} else {
 | 
			
		||||
				sprintf(name, "%s/%s", pkgpath, dp->d_name);
 | 
			
		||||
				if(unlink(name)) {
 | 
			
		||||
					ret = -1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	closedir(dirp);
 | 
			
		||||
 | 
			
		||||
	/* after removing all enclosed files, we can remove the directory itself. */
 | 
			
		||||
	if(rmdir(pkgpath)) {
 | 
			
		||||
		ret = -1;
 | 
			
		||||
	}
 | 
			
		||||
	free(pkgpath);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	ASSERT(pkg->origin == ALPM_PKG_FROM_LOCALDB,
 | 
			
		||||
			RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
	ASSERT(pkg->origin_data.db == pkg->handle->db_local,
 | 
			
		||||
			RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
 | 
			
		||||
	_alpm_log(pkg->handle, ALPM_LOG_DEBUG,
 | 
			
		||||
			"setting install reason %u for %s\n", reason, pkg->name);
 | 
			
		||||
	if(alpm_pkg_get_reason(pkg) == reason) {
 | 
			
		||||
		/* we are done */
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	/* set reason (in pkgcache) */
 | 
			
		||||
	pkg->reason = reason;
 | 
			
		||||
	/* write DESC */
 | 
			
		||||
	if(_alpm_local_db_write(pkg->handle->db_local, pkg, INFRQ_DESC)) {
 | 
			
		||||
		RET_ERR(pkg->handle, ALPM_ERR_DB_WRITE, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct db_operations local_db_ops = {
 | 
			
		||||
	.validate         = local_db_validate,
 | 
			
		||||
	.populate         = local_db_populate,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  be_package.c : backend for packages
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,11 +18,12 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
@@ -31,11 +32,18 @@
 | 
			
		||||
/* libalpm */
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "libarchive-compat.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "handle.h"
 | 
			
		||||
#include "package.h"
 | 
			
		||||
#include "deps.h" /* _alpm_splitdep */
 | 
			
		||||
#include "deps.h"
 | 
			
		||||
#include "filelist.h"
 | 
			
		||||
 | 
			
		||||
struct package_changelog {
 | 
			
		||||
	struct archive *archive;
 | 
			
		||||
	int fd;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Open a package changelog for reading. Similar to fopen in functionality,
 | 
			
		||||
@@ -47,31 +55,38 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
 | 
			
		||||
	struct archive *archive = NULL;
 | 
			
		||||
	struct package_changelog *changelog;
 | 
			
		||||
	struct archive *archive;
 | 
			
		||||
	struct archive_entry *entry;
 | 
			
		||||
	const char *pkgfile = pkg->origin_data.file;
 | 
			
		||||
	struct stat buf;
 | 
			
		||||
	int fd;
 | 
			
		||||
 | 
			
		||||
	if((archive = archive_read_new()) == NULL) {
 | 
			
		||||
		RET_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	archive_read_support_compression_all(archive);
 | 
			
		||||
	archive_read_support_format_all(archive);
 | 
			
		||||
 | 
			
		||||
	if(archive_read_open_filename(archive, pkgfile,
 | 
			
		||||
				ALPM_BUFFER_SIZE) != ARCHIVE_OK) {
 | 
			
		||||
		RET_ERR(pkg->handle, ALPM_ERR_PKG_OPEN, NULL);
 | 
			
		||||
	fd = _alpm_open_archive(pkg->handle, pkgfile, &buf,
 | 
			
		||||
			&archive, ALPM_ERR_PKG_OPEN);
 | 
			
		||||
	if(fd < 0) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
 | 
			
		||||
		const char *entry_name = archive_entry_pathname(entry);
 | 
			
		||||
 | 
			
		||||
		if(strcmp(entry_name, ".CHANGELOG") == 0) {
 | 
			
		||||
			return archive;
 | 
			
		||||
			changelog = malloc(sizeof(struct package_changelog));
 | 
			
		||||
			if(!changelog) {
 | 
			
		||||
				pkg->handle->pm_errno = ALPM_ERR_MEMORY;
 | 
			
		||||
				_alpm_archive_read_free(archive);
 | 
			
		||||
				CLOSE(fd);
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
			changelog->archive = archive;
 | 
			
		||||
			changelog->fd = fd;
 | 
			
		||||
			return changelog;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/* we didn't find a changelog */
 | 
			
		||||
	archive_read_finish(archive);
 | 
			
		||||
	_alpm_archive_read_free(archive);
 | 
			
		||||
	CLOSE(fd);
 | 
			
		||||
	errno = ENOENT;
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
@@ -89,7 +104,8 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
 | 
			
		||||
static size_t _package_changelog_read(void *ptr, size_t size,
 | 
			
		||||
		const alpm_pkg_t UNUSED *pkg, void *fp)
 | 
			
		||||
{
 | 
			
		||||
	ssize_t sret = archive_read_data((struct archive *)fp, ptr, size);
 | 
			
		||||
	struct package_changelog *changelog = fp;
 | 
			
		||||
	ssize_t sret = archive_read_data(changelog->archive, ptr, size);
 | 
			
		||||
	/* Report error (negative values) */
 | 
			
		||||
	if(sret < 0) {
 | 
			
		||||
		RET_ERR(pkg->handle, ALPM_ERR_LIBARCHIVE, 0);
 | 
			
		||||
@@ -107,7 +123,12 @@ static size_t _package_changelog_read(void *ptr, size_t size,
 | 
			
		||||
 */
 | 
			
		||||
static int _package_changelog_close(const alpm_pkg_t UNUSED *pkg, void *fp)
 | 
			
		||||
{
 | 
			
		||||
	return archive_read_finish((struct archive *)fp);
 | 
			
		||||
	int ret;
 | 
			
		||||
	struct package_changelog *changelog = fp;
 | 
			
		||||
	ret = _alpm_archive_read_free(changelog->archive);
 | 
			
		||||
	CLOSE(changelog->fd);
 | 
			
		||||
	free(changelog);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Package file operations struct accessor. We implement this as a method
 | 
			
		||||
@@ -149,21 +170,24 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
 | 
			
		||||
 | 
			
		||||
	/* loop until we reach EOF or other error */
 | 
			
		||||
	while((ret = _alpm_archive_fgets(a, &buf)) == ARCHIVE_OK) {
 | 
			
		||||
		size_t len = _alpm_strip_newline(buf.line);
 | 
			
		||||
		size_t len = _alpm_strip_newline(buf.line, buf.real_line_size);
 | 
			
		||||
 | 
			
		||||
		linenum++;
 | 
			
		||||
		if(len == 0 || buf.line[0] == '#') {
 | 
			
		||||
		key = buf.line;
 | 
			
		||||
		if(len == 0 || key[0] == '#') {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		ptr = buf.line;
 | 
			
		||||
		key = strsep(&ptr, "=");
 | 
			
		||||
		if(key == NULL || ptr == NULL) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "%s: syntax error in description file line %d\n",
 | 
			
		||||
								newpkg->name ? newpkg->name : "error", linenum);
 | 
			
		||||
		/* line is always in this format: "key = value"
 | 
			
		||||
		 * we can be sure the " = " exists, so look for that */
 | 
			
		||||
		ptr = memchr(key, ' ', len);
 | 
			
		||||
		if(!ptr || (size_t)(ptr - key + 2) > len || memcmp(ptr, " = ", 3) != 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"%s: syntax error in description file line %d\n",
 | 
			
		||||
					newpkg->name ? newpkg->name : "error", linenum);
 | 
			
		||||
		} else {
 | 
			
		||||
			key = _alpm_strtrim(key);
 | 
			
		||||
			while(*ptr == ' ') ptr++;
 | 
			
		||||
			ptr = _alpm_strtrim(ptr);
 | 
			
		||||
			/* NULL the end of the key portion, move ptr to start of value */
 | 
			
		||||
			*ptr = '\0';
 | 
			
		||||
			ptr += 3;
 | 
			
		||||
			if(strcmp(key, "pkgname") == 0) {
 | 
			
		||||
				STRDUP(newpkg->name, ptr, return -1);
 | 
			
		||||
				newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
 | 
			
		||||
@@ -192,7 +216,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
 | 
			
		||||
				alpm_depend_t *dep = _alpm_splitdep(ptr);
 | 
			
		||||
				newpkg->depends = alpm_list_add(newpkg->depends, dep);
 | 
			
		||||
			} else if(strcmp(key, "optdepend") == 0) {
 | 
			
		||||
				newpkg->optdepends = alpm_list_add(newpkg->optdepends, strdup(ptr));
 | 
			
		||||
				alpm_depend_t *optdep = _alpm_splitdep(ptr);
 | 
			
		||||
				newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep);
 | 
			
		||||
			} else if(strcmp(key, "conflict") == 0) {
 | 
			
		||||
				alpm_depend_t *conflict = _alpm_splitdep(ptr);
 | 
			
		||||
				newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict);
 | 
			
		||||
@@ -225,53 +250,6 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void files_merge(alpm_file_t a[], alpm_file_t b[], alpm_file_t c[],
 | 
			
		||||
		size_t m, size_t n)
 | 
			
		||||
{
 | 
			
		||||
	size_t i = 0, j = 0, k = 0;
 | 
			
		||||
	while(i < m && j < n) {
 | 
			
		||||
		if(strcmp(a[i].name, b[j].name) < 0) {
 | 
			
		||||
			c[k++] = a[i++];
 | 
			
		||||
		} else {
 | 
			
		||||
			c[k++] = b[j++];
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	while(i < m) {
 | 
			
		||||
		c[k++] = a[i++];
 | 
			
		||||
	}
 | 
			
		||||
	while(j < n) {
 | 
			
		||||
		c[k++] = b[j++];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_file_t *files_msort(alpm_file_t *files, size_t n)
 | 
			
		||||
{
 | 
			
		||||
	alpm_file_t *work;
 | 
			
		||||
	size_t blocksize = 1;
 | 
			
		||||
 | 
			
		||||
	CALLOC(work, n, sizeof(alpm_file_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	for(blocksize = 1; blocksize < n; blocksize *= 2) {
 | 
			
		||||
		size_t i, max_extent = 0;
 | 
			
		||||
		for(i = 0; i < n - blocksize; i += 2 * blocksize) {
 | 
			
		||||
			/* this limits our actual merge to the length of the array, since we will
 | 
			
		||||
			 * not likely be a perfect power of two. */
 | 
			
		||||
			size_t right_blocksize = blocksize;
 | 
			
		||||
			if(i + blocksize * 2 > n) {
 | 
			
		||||
				right_blocksize = n - i - blocksize;
 | 
			
		||||
			}
 | 
			
		||||
			files_merge(files + i, files + i + blocksize, work + i,
 | 
			
		||||
					blocksize, right_blocksize);
 | 
			
		||||
			max_extent = i + blocksize + right_blocksize;
 | 
			
		||||
		}
 | 
			
		||||
		/* ensure we only copy what we actually touched on this merge pass,
 | 
			
		||||
		 * no more, no less */
 | 
			
		||||
		memcpy(files, work, max_extent * sizeof(alpm_file_t));
 | 
			
		||||
	}
 | 
			
		||||
	free(work);
 | 
			
		||||
	return files;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Validate a package.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
@@ -280,11 +258,12 @@ static alpm_file_t *files_msort(alpm_file_t *files, size_t n)
 | 
			
		||||
 * sha256sum, and/or base64 signature)
 | 
			
		||||
 * @param level the required level of signature verification
 | 
			
		||||
 * @param sigdata signature data from the package to pass back
 | 
			
		||||
 * @param validation successful validations performed on the package file
 | 
			
		||||
 * @return 0 if package is fully valid, -1 and pm_errno otherwise
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
		const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
 | 
			
		||||
		alpm_siglist_t **sigdata)
 | 
			
		||||
		alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation)
 | 
			
		||||
{
 | 
			
		||||
	int has_sig;
 | 
			
		||||
	handle->pm_errno = 0;
 | 
			
		||||
@@ -294,8 +273,15 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* attempt to access the package file, ensure it exists */
 | 
			
		||||
	if(access(pkgfile, R_OK) != 0) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, -1);
 | 
			
		||||
	if(_alpm_access(handle, NULL, pkgfile, R_OK) != 0) {
 | 
			
		||||
		if(errno == ENOENT) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
 | 
			
		||||
		} else if(errno == EACCES) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_BADPERMS;
 | 
			
		||||
		} else {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_OPEN;
 | 
			
		||||
		}
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* can we get away with skipping checksums? */
 | 
			
		||||
@@ -316,17 +302,23 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
		if(syncpkg->md5sum && !syncpkg->sha256sum) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "md5sum: %s\n", syncpkg->md5sum);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile);
 | 
			
		||||
			if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, ALPM_CSUM_MD5) != 0) {
 | 
			
		||||
			if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM) != 0) {
 | 
			
		||||
				RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, -1);
 | 
			
		||||
			}
 | 
			
		||||
			if(validation) {
 | 
			
		||||
				*validation |= ALPM_PKG_VALIDATION_MD5SUM;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(syncpkg->sha256sum) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "sha256sum: %s\n", syncpkg->sha256sum);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "checking sha256sum for %s\n", pkgfile);
 | 
			
		||||
			if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, ALPM_CSUM_SHA256) != 0) {
 | 
			
		||||
			if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, ALPM_PKG_VALIDATION_SHA256SUM) != 0) {
 | 
			
		||||
				RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, -1);
 | 
			
		||||
			}
 | 
			
		||||
			if(validation) {
 | 
			
		||||
				*validation |= ALPM_PKG_VALIDATION_SHA256SUM;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -340,6 +332,13 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_INVALID_SIG;
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		if(validation && has_sig) {
 | 
			
		||||
			*validation |= ALPM_PKG_VALIDATION_SIGNATURE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(validation && !*validation) {
 | 
			
		||||
		*validation = ALPM_PKG_VALIDATION_NONE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
@@ -355,45 +354,37 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
 | 
			
		||||
		const char *pkgfile, int full)
 | 
			
		||||
{
 | 
			
		||||
	int ret, config = 0;
 | 
			
		||||
	int ret, fd, config = 0;
 | 
			
		||||
	struct archive *archive;
 | 
			
		||||
	struct archive_entry *entry;
 | 
			
		||||
	alpm_pkg_t *newpkg = NULL;
 | 
			
		||||
	alpm_pkg_t *newpkg;
 | 
			
		||||
	struct stat st;
 | 
			
		||||
	size_t files_count = 0, files_size = 0;
 | 
			
		||||
	alpm_file_t *files = NULL;
 | 
			
		||||
	size_t files_size = 0;
 | 
			
		||||
 | 
			
		||||
	if(pkgfile == NULL || strlen(pkgfile) == 0) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* attempt to stat the package file, ensure it exists */
 | 
			
		||||
	if(stat(pkgfile, &st) == 0) {
 | 
			
		||||
		newpkg = _alpm_pkg_new();
 | 
			
		||||
		if(newpkg == NULL) {
 | 
			
		||||
			RET_ERR(handle, ALPM_ERR_MEMORY, NULL);
 | 
			
		||||
	fd = _alpm_open_archive(handle, pkgfile, &st, &archive, ALPM_ERR_PKG_OPEN);
 | 
			
		||||
	if(fd < 0) {
 | 
			
		||||
		if(errno == ENOENT) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
 | 
			
		||||
		} else if(errno == EACCES) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_BADPERMS;
 | 
			
		||||
		} else {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_PKG_OPEN;
 | 
			
		||||
		}
 | 
			
		||||
		newpkg->filename = strdup(pkgfile);
 | 
			
		||||
		newpkg->size = st.st_size;
 | 
			
		||||
	} else {
 | 
			
		||||
		/* couldn't stat the pkgfile, return an error */
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, NULL);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* try to create an archive object to read in the package */
 | 
			
		||||
	if((archive = archive_read_new()) == NULL) {
 | 
			
		||||
		alpm_pkg_free(newpkg);
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_LIBARCHIVE, NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	archive_read_support_compression_all(archive);
 | 
			
		||||
	archive_read_support_format_all(archive);
 | 
			
		||||
 | 
			
		||||
	if(archive_read_open_filename(archive, pkgfile,
 | 
			
		||||
				ALPM_BUFFER_SIZE) != ARCHIVE_OK) {
 | 
			
		||||
		alpm_pkg_free(newpkg);
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL);
 | 
			
		||||
	newpkg = _alpm_pkg_new();
 | 
			
		||||
	if(newpkg == NULL) {
 | 
			
		||||
		handle->pm_errno = ALPM_ERR_MEMORY;
 | 
			
		||||
		goto error;
 | 
			
		||||
	}
 | 
			
		||||
	STRDUP(newpkg->filename, pkgfile,
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_MEMORY; goto error);
 | 
			
		||||
	newpkg->size = st.st_size;
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
 | 
			
		||||
 | 
			
		||||
@@ -426,28 +417,34 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
 | 
			
		||||
			/* for now, ignore all files starting with '.' that haven't
 | 
			
		||||
			 * already been handled (for future possibilities) */
 | 
			
		||||
		} else if(full) {
 | 
			
		||||
			const size_t files_count = newpkg->files.count;
 | 
			
		||||
			alpm_file_t *current_file;
 | 
			
		||||
			/* Keep track of all files for filelist generation */
 | 
			
		||||
			if(files_count >= files_size) {
 | 
			
		||||
				size_t old_size = files_size;
 | 
			
		||||
				alpm_file_t *newfiles;
 | 
			
		||||
				if(files_size == 0) {
 | 
			
		||||
					files_size = 4;
 | 
			
		||||
				} else {
 | 
			
		||||
					files_size *= 2;
 | 
			
		||||
				}
 | 
			
		||||
				files = realloc(files, sizeof(alpm_file_t) * files_size);
 | 
			
		||||
				if(!files) {
 | 
			
		||||
					ALLOC_FAIL(sizeof(alpm_file_t) * files_size);
 | 
			
		||||
				newfiles = realloc(newpkg->files.files,
 | 
			
		||||
						sizeof(alpm_file_t) * files_size);
 | 
			
		||||
				if(!newfiles) {
 | 
			
		||||
					_alpm_alloc_fail(sizeof(alpm_file_t) * files_size);
 | 
			
		||||
					goto error;
 | 
			
		||||
				}
 | 
			
		||||
				/* ensure all new memory is zeroed out, in both the initial
 | 
			
		||||
				 * allocation and later reallocs */
 | 
			
		||||
				memset(files + old_size, 0,
 | 
			
		||||
				memset(newfiles + old_size, 0,
 | 
			
		||||
						sizeof(alpm_file_t) * (files_size - old_size));
 | 
			
		||||
				newpkg->files.files = newfiles;
 | 
			
		||||
			}
 | 
			
		||||
			STRDUP(files[files_count].name, entry_name, goto error);
 | 
			
		||||
			files[files_count].size = archive_entry_size(entry);
 | 
			
		||||
			files[files_count].mode = archive_entry_mode(entry);
 | 
			
		||||
			files_count++;
 | 
			
		||||
			current_file = newpkg->files.files + files_count;
 | 
			
		||||
			STRDUP(current_file->name, entry_name, goto error);
 | 
			
		||||
			current_file->size = archive_entry_size(entry);
 | 
			
		||||
			current_file->mode = archive_entry_mode(entry);
 | 
			
		||||
			newpkg->files.count++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(archive_read_data_skip(archive)) {
 | 
			
		||||
@@ -475,25 +472,29 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
 | 
			
		||||
		goto pkg_invalid;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	archive_read_finish(archive);
 | 
			
		||||
	_alpm_archive_read_free(archive);
 | 
			
		||||
	CLOSE(fd);
 | 
			
		||||
 | 
			
		||||
	/* internal fields for package struct */
 | 
			
		||||
	newpkg->origin = PKG_FROM_FILE;
 | 
			
		||||
	newpkg->origin = ALPM_PKG_FROM_FILE;
 | 
			
		||||
	newpkg->origin_data.file = strdup(pkgfile);
 | 
			
		||||
	newpkg->ops = get_file_pkg_ops();
 | 
			
		||||
	newpkg->handle = handle;
 | 
			
		||||
	newpkg->infolevel = INFRQ_BASE | INFRQ_DESC | INFRQ_SCRIPTLET;
 | 
			
		||||
	newpkg->validation = ALPM_PKG_VALIDATION_NONE;
 | 
			
		||||
 | 
			
		||||
	if(full) {
 | 
			
		||||
		if(files) {
 | 
			
		||||
		if(newpkg->files.files) {
 | 
			
		||||
			/* attempt to hand back any memory we don't need */
 | 
			
		||||
			files = realloc(files, sizeof(alpm_file_t) * files_count);
 | 
			
		||||
			newpkg->files.files = realloc(newpkg->files.files,
 | 
			
		||||
					sizeof(alpm_file_t) * newpkg->files.count);
 | 
			
		||||
			/* "checking for conflicts" requires a sorted list, ensure that here */
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"sorting package filelist for %s\n", pkgfile);
 | 
			
		||||
			newpkg->files.files = files_msort(files, files_count);
 | 
			
		||||
 | 
			
		||||
			qsort(newpkg->files.files, newpkg->files.count,
 | 
			
		||||
					sizeof(alpm_file_t), _alpm_files_cmp);
 | 
			
		||||
		}
 | 
			
		||||
		newpkg->files.count = files_count;
 | 
			
		||||
		newpkg->infolevel |= INFRQ_FILES;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -503,18 +504,89 @@ pkg_invalid:
 | 
			
		||||
	handle->pm_errno = ALPM_ERR_PKG_INVALID;
 | 
			
		||||
error:
 | 
			
		||||
	_alpm_pkg_free(newpkg);
 | 
			
		||||
	archive_read_finish(archive);
 | 
			
		||||
	_alpm_archive_read_free(archive);
 | 
			
		||||
	if(fd >= 0) {
 | 
			
		||||
		CLOSE(fd);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int read_sigfile(const char *sigpath, unsigned char **sig)
 | 
			
		||||
{
 | 
			
		||||
	struct stat st;
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
 | 
			
		||||
	if(stat(sigpath, &st) != 0) {
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	MALLOC(*sig, st.st_size, return -1);
 | 
			
		||||
 | 
			
		||||
	if((fp = fopen(sigpath, "rb")) == NULL) {
 | 
			
		||||
		free(*sig);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(fread(*sig, st.st_size, 1, fp) != 1) {
 | 
			
		||||
		free(*sig);
 | 
			
		||||
		fclose(fp);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fclose(fp);
 | 
			
		||||
	return st.st_size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
 | 
			
		||||
		alpm_siglevel_t level, alpm_pkg_t **pkg)
 | 
			
		||||
{
 | 
			
		||||
	alpm_pkgvalidation_t validation = 0;
 | 
			
		||||
	char *sigpath;
 | 
			
		||||
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
 | 
			
		||||
	if(_alpm_pkg_validate_internal(handle, filename, NULL, level, NULL) == -1) {
 | 
			
		||||
	sigpath = _alpm_sigpath(handle, filename);
 | 
			
		||||
	if(sigpath && !_alpm_access(handle, NULL, sigpath, R_OK)) {
 | 
			
		||||
		if(level & ALPM_SIG_PACKAGE) {
 | 
			
		||||
			alpm_list_t *keys = NULL;
 | 
			
		||||
			int fail = 0;
 | 
			
		||||
			unsigned char *sig = NULL;
 | 
			
		||||
			int len = read_sigfile(sigpath, &sig);
 | 
			
		||||
 | 
			
		||||
			if(len == -1) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
					_("failed to read signature file: %s\n"), sigpath);
 | 
			
		||||
				free(sigpath);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(_alpm_extract_keyid(handle, filename, sig, len, &keys) == 0) {
 | 
			
		||||
				alpm_list_t *k;
 | 
			
		||||
				for(k = keys; k; k = k->next) {
 | 
			
		||||
					char *key = k->data;
 | 
			
		||||
					if(_alpm_key_in_keychain(handle, key) == 0) {
 | 
			
		||||
						if(_alpm_key_import(handle, key) == -1) {
 | 
			
		||||
							fail = 1;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				FREELIST(keys);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			free(sig);
 | 
			
		||||
 | 
			
		||||
			if(fail) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR, _("required key missing from keyring\n"));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	free(sigpath);
 | 
			
		||||
 | 
			
		||||
	if(_alpm_pkg_validate_internal(handle, filename, NULL, level, NULL,
 | 
			
		||||
				&validation) == -1) {
 | 
			
		||||
		/* pm_errno is set by pkg_validate */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
@@ -523,6 +595,7 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
 | 
			
		||||
		/* pm_errno is set by pkg_load */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	(*pkg)->validation = validation;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  be_sync.c : backend for sync databases
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,10 +18,10 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
@@ -31,6 +31,7 @@
 | 
			
		||||
/* libalpm */
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "libarchive-compat.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "package.h"
 | 
			
		||||
@@ -86,11 +87,10 @@ static int sync_db_validate(alpm_db_t *db)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* we can skip any validation if the database doesn't exist */
 | 
			
		||||
	if(access(dbpath, R_OK) != 0 && errno == ENOENT) {
 | 
			
		||||
	if(_alpm_access(db->handle, NULL, dbpath, R_OK) != 0 && errno == ENOENT) {
 | 
			
		||||
		db->status &= ~DB_STATUS_EXISTS;
 | 
			
		||||
		db->status |= DB_STATUS_MISSING;
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_WARNING,
 | 
			
		||||
				"database file for '%s' does not exist\n", db->treename);
 | 
			
		||||
		EVENT(db->handle, ALPM_EVENT_DATABASE_MISSING, db->treename, NULL);
 | 
			
		||||
		goto valid;
 | 
			
		||||
	}
 | 
			
		||||
	db->status |= DB_STATUS_EXISTS;
 | 
			
		||||
@@ -142,7 +142,7 @@ valid:
 | 
			
		||||
 *
 | 
			
		||||
 * Example:
 | 
			
		||||
 * @code
 | 
			
		||||
 * alpm_list_t *syncs = alpm_option_get_syncdbs();
 | 
			
		||||
 * alpm_list_t *syncs = alpm_get_syncdbs();
 | 
			
		||||
 * for(i = syncs; i; i = alpm_list_next(i)) {
 | 
			
		||||
 *     alpm_db_t *db = alpm_list_getdata(i);
 | 
			
		||||
 *     result = alpm_db_update(0, db);
 | 
			
		||||
@@ -212,13 +212,14 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 | 
			
		||||
 | 
			
		||||
		/* print server + filename into a buffer */
 | 
			
		||||
		len = strlen(server) + strlen(db->treename) + 5;
 | 
			
		||||
		/* TODO fix leak syncpath and umask unset */
 | 
			
		||||
		MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
 | 
			
		||||
		snprintf(payload.fileurl, len, "%s/%s.db", server, db->treename);
 | 
			
		||||
		payload.handle = handle;
 | 
			
		||||
		payload.force = force;
 | 
			
		||||
		payload.unlink_on_fail = 1;
 | 
			
		||||
 | 
			
		||||
		ret = _alpm_download(&payload, syncpath, NULL);
 | 
			
		||||
		ret = _alpm_download(&payload, syncpath, NULL, NULL);
 | 
			
		||||
		_alpm_dload_payload_reset(&payload);
 | 
			
		||||
 | 
			
		||||
		if(ret == 0 && (level & ALPM_SIG_DATABASE)) {
 | 
			
		||||
@@ -234,6 +235,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 | 
			
		||||
			/* if we downloaded a DB, we want the .sig from the same server */
 | 
			
		||||
			/* print server + filename into a buffer (leave space for .sig) */
 | 
			
		||||
			len = strlen(server) + strlen(db->treename) + 9;
 | 
			
		||||
			/* TODO fix leak syncpath and umask unset */
 | 
			
		||||
			MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
 | 
			
		||||
			snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
 | 
			
		||||
			payload.handle = handle;
 | 
			
		||||
@@ -243,7 +245,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 | 
			
		||||
			/* set hard upper limit of 16KiB */
 | 
			
		||||
			payload.max_size = 16 * 1024;
 | 
			
		||||
 | 
			
		||||
			sig_ret = _alpm_download(&payload, syncpath, NULL);
 | 
			
		||||
			sig_ret = _alpm_download(&payload, syncpath, NULL, NULL);
 | 
			
		||||
			/* errors_ok suppresses error messages, but not the return code */
 | 
			
		||||
			sig_ret = payload.errors_ok ? 0 : sig_ret;
 | 
			
		||||
			_alpm_dload_payload_reset(&payload);
 | 
			
		||||
@@ -294,6 +296,29 @@ cleanup:
 | 
			
		||||
static int sync_db_read(alpm_db_t *db, struct archive *archive,
 | 
			
		||||
		struct archive_entry *entry, alpm_pkg_t **likely_pkg);
 | 
			
		||||
 | 
			
		||||
static alpm_pkgvalidation_t _sync_get_validation(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	if(pkg->validation) {
 | 
			
		||||
		return pkg->validation;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(pkg->md5sum) {
 | 
			
		||||
		pkg->validation |= ALPM_PKG_VALIDATION_MD5SUM;
 | 
			
		||||
	}
 | 
			
		||||
	if(pkg->sha256sum) {
 | 
			
		||||
		pkg->validation |= ALPM_PKG_VALIDATION_SHA256SUM;
 | 
			
		||||
	}
 | 
			
		||||
	if(pkg->base64_sig) {
 | 
			
		||||
		pkg->validation |= ALPM_PKG_VALIDATION_SIGNATURE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(!pkg->validation) {
 | 
			
		||||
		pkg->validation |= ALPM_PKG_VALIDATION_NONE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return pkg->validation;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
 | 
			
		||||
		const char **entry_filename, alpm_pkg_t *likely_pkg)
 | 
			
		||||
{
 | 
			
		||||
@@ -316,7 +341,8 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(likely_pkg && strcmp(likely_pkg->name, pkgname) == 0) {
 | 
			
		||||
	if(likely_pkg && pkgname_hash == likely_pkg->name_hash
 | 
			
		||||
			&& strcmp(likely_pkg->name, pkgname) == 0) {
 | 
			
		||||
		pkg = likely_pkg;
 | 
			
		||||
	} else {
 | 
			
		||||
		pkg = _alpm_pkghash_find(db->pkgcache, pkgname);
 | 
			
		||||
@@ -331,9 +357,10 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
 | 
			
		||||
		pkg->version = pkgver;
 | 
			
		||||
		pkg->name_hash = pkgname_hash;
 | 
			
		||||
 | 
			
		||||
		pkg->origin = PKG_FROM_SYNCDB;
 | 
			
		||||
		pkg->origin = ALPM_PKG_FROM_SYNCDB;
 | 
			
		||||
		pkg->origin_data.db = db;
 | 
			
		||||
		pkg->ops = &default_pkg_ops;
 | 
			
		||||
		pkg->ops->get_validation = _sync_get_validation;
 | 
			
		||||
		pkg->handle = db->handle;
 | 
			
		||||
 | 
			
		||||
		/* add to the collection */
 | 
			
		||||
@@ -348,61 +375,38 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
 | 
			
		||||
	return pkg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This is the data table used to generate the estimating function below.
 | 
			
		||||
 * "Weighted Avg" means averaging the bottom table values; thus each repo, big
 | 
			
		||||
 * or small, will have equal influence.  "Unweighted Avg" means averaging the
 | 
			
		||||
 * sums of the top table columns, thus each package has equal influence.  The
 | 
			
		||||
 * final values are calculated by (surprise) averaging the averages, because
 | 
			
		||||
 * why the hell not.
 | 
			
		||||
 *
 | 
			
		||||
 * Database   Pkgs  tar      bz2     gz      xz
 | 
			
		||||
 * community  2096  5294080  256391  421227  301296
 | 
			
		||||
 * core        180   460800   25257   36850   29356
 | 
			
		||||
 * extra      2606  6635520  294647  470818  339392
 | 
			
		||||
 * multilib    126   327680   16120   23261   18732
 | 
			
		||||
 * testing      76   204800   10902   14348   12100
 | 
			
		||||
 *
 | 
			
		||||
 * Bytes Per Package
 | 
			
		||||
 * community  2096  2525.80  122.32  200.97  143.75
 | 
			
		||||
 * core        180  2560.00  140.32  204.72  163.09
 | 
			
		||||
 * extra      2606  2546.25  113.06  180.67  130.23
 | 
			
		||||
 * multilib    126  2600.63  127.94  184.61  148.67
 | 
			
		||||
 * testing      76  2694.74  143.45  188.79  159.21
 | 
			
		||||
 | 
			
		||||
 * Weighted Avg     2585.48  129.42  191.95  148.99
 | 
			
		||||
 * Unweighted Avg   2543.39  118.74  190.16  137.93
 | 
			
		||||
 * Average of Avgs  2564.44  124.08  191.06  143.46
 | 
			
		||||
 */
 | 
			
		||||
/* This function doesn't work as well as one might think, as size of database
 | 
			
		||||
 * entries varies considerably. Adding signatures nearly doubles the size of a
 | 
			
		||||
 * single entry; deltas also can make for large variations in size. These
 | 
			
		||||
 * current values are heavily influenced by Arch Linux; databases with no
 | 
			
		||||
 * deltas and a single signature per package. */
 | 
			
		||||
static size_t estimate_package_count(struct stat *st, struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
	unsigned int per_package;
 | 
			
		||||
	int per_package;
 | 
			
		||||
 | 
			
		||||
	switch(archive_compression(archive)) {
 | 
			
		||||
	switch(_alpm_archive_filter_code(archive)) {
 | 
			
		||||
		case ARCHIVE_COMPRESSION_NONE:
 | 
			
		||||
			per_package = 2564;
 | 
			
		||||
			per_package = 3015;
 | 
			
		||||
			break;
 | 
			
		||||
		case ARCHIVE_COMPRESSION_GZIP:
 | 
			
		||||
			per_package = 191;
 | 
			
		||||
		case ARCHIVE_COMPRESSION_COMPRESS:
 | 
			
		||||
			per_package = 464;
 | 
			
		||||
			break;
 | 
			
		||||
		case ARCHIVE_COMPRESSION_BZIP2:
 | 
			
		||||
			per_package = 124;
 | 
			
		||||
			break;
 | 
			
		||||
		case ARCHIVE_COMPRESSION_COMPRESS:
 | 
			
		||||
			per_package = 193;
 | 
			
		||||
			per_package = 394;
 | 
			
		||||
			break;
 | 
			
		||||
		case ARCHIVE_COMPRESSION_LZMA:
 | 
			
		||||
		case ARCHIVE_COMPRESSION_XZ:
 | 
			
		||||
			per_package = 143;
 | 
			
		||||
			per_package = 400;
 | 
			
		||||
			break;
 | 
			
		||||
#ifdef ARCHIVE_COMPRESSION_UU
 | 
			
		||||
		case ARCHIVE_COMPRESSION_UU:
 | 
			
		||||
			per_package = 3543;
 | 
			
		||||
			per_package = 3015 * 4 / 3;
 | 
			
		||||
			break;
 | 
			
		||||
#endif
 | 
			
		||||
		default:
 | 
			
		||||
			/* assume it is at least somewhat compressed */
 | 
			
		||||
			per_package = 200;
 | 
			
		||||
			per_package = 500;
 | 
			
		||||
	}
 | 
			
		||||
	return (size_t)((st->st_size / per_package) + 1);
 | 
			
		||||
}
 | 
			
		||||
@@ -411,7 +415,7 @@ static int sync_db_populate(alpm_db_t *db)
 | 
			
		||||
{
 | 
			
		||||
	const char *dbpath;
 | 
			
		||||
	size_t est_count;
 | 
			
		||||
	int count = 0;
 | 
			
		||||
	int count, fd;
 | 
			
		||||
	struct stat buf;
 | 
			
		||||
	struct archive *archive;
 | 
			
		||||
	struct archive_entry *entry;
 | 
			
		||||
@@ -423,38 +427,24 @@ static int sync_db_populate(alpm_db_t *db)
 | 
			
		||||
	if(db->status & DB_STATUS_MISSING) {
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_DB_NOT_FOUND, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if((archive = archive_read_new()) == NULL) {
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_LIBARCHIVE, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	archive_read_support_compression_all(archive);
 | 
			
		||||
	archive_read_support_format_all(archive);
 | 
			
		||||
 | 
			
		||||
	dbpath = _alpm_db_path(db);
 | 
			
		||||
	if(!dbpath) {
 | 
			
		||||
		/* pm_errno set in _alpm_db_path() */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_alpm_log(db->handle, ALPM_LOG_DEBUG, "opening database archive %s\n", dbpath);
 | 
			
		||||
 | 
			
		||||
	if(archive_read_open_filename(archive, dbpath,
 | 
			
		||||
				ALPM_BUFFER_SIZE) != ARCHIVE_OK) {
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), dbpath,
 | 
			
		||||
				archive_error_string(archive));
 | 
			
		||||
		archive_read_finish(archive);
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
 | 
			
		||||
	}
 | 
			
		||||
	if(stat(dbpath, &buf) != 0) {
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_DB_OPEN, -1);
 | 
			
		||||
	fd = _alpm_open_archive(db->handle, dbpath, &buf,
 | 
			
		||||
			&archive, ALPM_ERR_DB_OPEN);
 | 
			
		||||
	if(fd < 0) {
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	est_count = estimate_package_count(&buf, archive);
 | 
			
		||||
 | 
			
		||||
	/* initialize hash at 66% full */
 | 
			
		||||
	db->pkgcache = _alpm_pkghash_create(est_count * 3 / 2);
 | 
			
		||||
	db->pkgcache = _alpm_pkghash_create(est_count);
 | 
			
		||||
	if(db->pkgcache == NULL) {
 | 
			
		||||
		RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
 | 
			
		||||
		db->handle->pm_errno = ALPM_ERR_MEMORY;
 | 
			
		||||
		count = -1;
 | 
			
		||||
		goto cleanup;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
 | 
			
		||||
@@ -473,21 +463,26 @@ static int sync_db_populate(alpm_db_t *db)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	count = alpm_list_count(db->pkgcache->list);
 | 
			
		||||
 | 
			
		||||
	if(count > 0) {
 | 
			
		||||
		db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
 | 
			
		||||
		db->pkgcache->list = alpm_list_msort(db->pkgcache->list,
 | 
			
		||||
				(size_t)count, _alpm_pkg_cmp);
 | 
			
		||||
	}
 | 
			
		||||
	archive_read_finish(archive);
 | 
			
		||||
	_alpm_log(db->handle, ALPM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
 | 
			
		||||
	_alpm_log(db->handle, ALPM_LOG_DEBUG,
 | 
			
		||||
			"added %d packages to package cache for db '%s'\n",
 | 
			
		||||
			count, db->treename);
 | 
			
		||||
 | 
			
		||||
cleanup:
 | 
			
		||||
	_alpm_archive_read_free(archive);
 | 
			
		||||
	if(fd >= 0) {
 | 
			
		||||
		CLOSE(fd);
 | 
			
		||||
	}
 | 
			
		||||
	return count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define READ_NEXT() do { \
 | 
			
		||||
	if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \
 | 
			
		||||
	line = buf.line; \
 | 
			
		||||
	_alpm_strip_newline(line); \
 | 
			
		||||
	_alpm_strip_newline(line, buf.real_line_size); \
 | 
			
		||||
} while(0)
 | 
			
		||||
 | 
			
		||||
#define READ_AND_STORE(f) do { \
 | 
			
		||||
@@ -498,14 +493,14 @@ static int sync_db_populate(alpm_db_t *db)
 | 
			
		||||
#define READ_AND_STORE_ALL(f) do { \
 | 
			
		||||
	char *linedup; \
 | 
			
		||||
	if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \
 | 
			
		||||
	if(_alpm_strip_newline(buf.line) == 0) break; \
 | 
			
		||||
	if(_alpm_strip_newline(buf.line, buf.real_line_size) == 0) break; \
 | 
			
		||||
	STRDUP(linedup, buf.line, goto error); \
 | 
			
		||||
	f = alpm_list_add(f, linedup); \
 | 
			
		||||
} while(1) /* note the while(1) and not (0) */
 | 
			
		||||
 | 
			
		||||
#define READ_AND_SPLITDEP(f) do { \
 | 
			
		||||
	if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \
 | 
			
		||||
	if(_alpm_strip_newline(buf.line) == 0) break; \
 | 
			
		||||
	if(_alpm_strip_newline(buf.line, buf.real_line_size) == 0) break; \
 | 
			
		||||
	f = alpm_list_add(f, _alpm_splitdep(line)); \
 | 
			
		||||
} while(1) /* note the while(1) and not (0) */
 | 
			
		||||
 | 
			
		||||
@@ -540,11 +535,11 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(strcmp(filename, "desc") == 0 || strcmp(filename, "depends") == 0
 | 
			
		||||
			|| strcmp(filename, "deltas") == 0) {
 | 
			
		||||
			|| (strcmp(filename, "deltas") == 0 && db->handle->deltaratio > 0.0) ) {
 | 
			
		||||
		int ret;
 | 
			
		||||
		while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) {
 | 
			
		||||
			char *line = buf.line;
 | 
			
		||||
			if(_alpm_strip_newline(line) == 0) {
 | 
			
		||||
			if(_alpm_strip_newline(line, buf.real_line_size) == 0) {
 | 
			
		||||
				/* length of stripped line was zero */
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
@@ -595,7 +590,19 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
 | 
			
		||||
			} else if(strcmp(line, "%DEPENDS%") == 0) {
 | 
			
		||||
				READ_AND_SPLITDEP(pkg->depends);
 | 
			
		||||
			} else if(strcmp(line, "%OPTDEPENDS%") == 0) {
 | 
			
		||||
				READ_AND_STORE_ALL(pkg->optdepends);
 | 
			
		||||
				READ_AND_SPLITDEP(pkg->optdepends);
 | 
			
		||||
			} else if(strcmp(line, "%MAKEDEPENDS%") == 0) {
 | 
			
		||||
				/* currently unused */
 | 
			
		||||
				while(1) {
 | 
			
		||||
					READ_NEXT();
 | 
			
		||||
					if(strlen(line) == 0) break;
 | 
			
		||||
				}
 | 
			
		||||
			} else if(strcmp(line, "%CHECKDEPENDS%") == 0) {
 | 
			
		||||
				/* currently unused */
 | 
			
		||||
				while(1) {
 | 
			
		||||
					READ_NEXT();
 | 
			
		||||
					if(strlen(line) == 0) break;
 | 
			
		||||
				}
 | 
			
		||||
			} else if(strcmp(line, "%CONFLICTS%") == 0) {
 | 
			
		||||
				READ_AND_SPLITDEP(pkg->conflicts);
 | 
			
		||||
			} else if(strcmp(line, "%PROVIDES%") == 0) {
 | 
			
		||||
@@ -605,7 +612,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
 | 
			
		||||
				while(1) {
 | 
			
		||||
					READ_NEXT();
 | 
			
		||||
					if(strlen(line) == 0) break;
 | 
			
		||||
					pkg->deltas = alpm_list_add(pkg->deltas, _alpm_delta_parse(line));
 | 
			
		||||
					pkg->deltas = alpm_list_add(pkg->deltas,
 | 
			
		||||
							_alpm_delta_parse(db->handle, line));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -613,6 +621,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
 | 
			
		||||
			goto error;
 | 
			
		||||
		}
 | 
			
		||||
		*likely_pkg = pkg;
 | 
			
		||||
	} else if(strcmp(filename, "deltas") == 0) {
 | 
			
		||||
		/* skip reading delta files if UseDelta is unset */
 | 
			
		||||
	} else if(strcmp(filename, "files") == 0) {
 | 
			
		||||
		/* currently do nothing with this file */
 | 
			
		||||
	} else {
 | 
			
		||||
@@ -641,7 +651,7 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
 | 
			
		||||
 | 
			
		||||
#ifndef HAVE_LIBGPGME
 | 
			
		||||
	if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
 | 
			
		||||
	if((level &= ~ALPM_SIG_PACKAGE_SET) != 0 && level != ALPM_SIG_USE_DEFAULT) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  conflict.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
 | 
			
		||||
@@ -22,8 +22,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@@ -40,7 +38,11 @@
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "deps.h"
 | 
			
		||||
#include "filelist.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Creates a new conflict.
 | 
			
		||||
 */
 | 
			
		||||
static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
 | 
			
		||||
		alpm_depend_t *reason)
 | 
			
		||||
{
 | 
			
		||||
@@ -57,6 +59,9 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
 | 
			
		||||
	return conflict;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Free a conflict and its members.
 | 
			
		||||
 */
 | 
			
		||||
void _alpm_conflict_free(alpm_conflict_t *conflict)
 | 
			
		||||
{
 | 
			
		||||
	FREE(conflict->package2);
 | 
			
		||||
@@ -64,6 +69,9 @@ void _alpm_conflict_free(alpm_conflict_t *conflict)
 | 
			
		||||
	FREE(conflict);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Creates a copy of a conflict.
 | 
			
		||||
 */
 | 
			
		||||
alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
 | 
			
		||||
{
 | 
			
		||||
	alpm_conflict_t *newconflict;
 | 
			
		||||
@@ -78,6 +86,14 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
 | 
			
		||||
	return newconflict;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Searches for a conflict in a list.
 | 
			
		||||
 *
 | 
			
		||||
 * @param needle conflict to search for
 | 
			
		||||
 * @param haystack list of conflicts to search
 | 
			
		||||
 *
 | 
			
		||||
 * @return 1 if needle is in haystack, 0 otherwise
 | 
			
		||||
 */
 | 
			
		||||
static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
@@ -94,12 +110,16 @@ static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Adds the pkg1/pkg2 conflict to the baddeps list.
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Adds the pkg1/pkg2 conflict to the baddeps list.
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param baddeps list to add conflict to
 | 
			
		||||
 * @param pkg1 first package
 | 
			
		||||
 * @param pkg2 package causing conflict
 | 
			
		||||
 * @param reason reason for this conflict
 | 
			
		||||
 *
 | 
			
		||||
 * @return 0 on success, -1 on error
 | 
			
		||||
 */
 | 
			
		||||
static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
 | 
			
		||||
		alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, alpm_depend_t *reason)
 | 
			
		||||
@@ -120,11 +140,13 @@ static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Check if packages from list1 conflict with packages from list2.
 | 
			
		||||
 * This looks at the conflicts fields of all packages from list1, and sees
 | 
			
		||||
 * if they match packages from list2.
 | 
			
		||||
 * If a conflict (pkg1, pkg2) is found, it is added to the baddeps list
 | 
			
		||||
 * in this order if order >= 0, or reverse order (pkg2,pkg1) otherwise.
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Check if packages from list1 conflict with packages from list2.
 | 
			
		||||
 *
 | 
			
		||||
 * @details This looks at the conflicts fields of all packages from list1, and
 | 
			
		||||
 * sees if they match packages from list2. If a conflict (pkg1, pkg2) is found,
 | 
			
		||||
 * it is added to the baddeps list in this order if order >= 0, or reverse
 | 
			
		||||
 * order (pkg2,pkg1) otherwise.
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param list1 first list of packages
 | 
			
		||||
@@ -134,7 +156,8 @@ static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
 | 
			
		||||
 */
 | 
			
		||||
static void check_conflict(alpm_handle_t *handle,
 | 
			
		||||
		alpm_list_t *list1, alpm_list_t *list2,
 | 
			
		||||
		alpm_list_t **baddeps, int order) {
 | 
			
		||||
		alpm_list_t **baddeps, int order)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
 | 
			
		||||
	if(!baddeps) {
 | 
			
		||||
@@ -169,7 +192,14 @@ static void check_conflict(alpm_handle_t *handle,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Check for inter-conflicts */
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Check for inter-conflicts in a list of packages.
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param packages list of packages to check
 | 
			
		||||
 *
 | 
			
		||||
 * @return list of conflicts
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *baddeps = NULL;
 | 
			
		||||
@@ -180,7 +210,9 @@ alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages)
 | 
			
		||||
	return baddeps;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Check for target vs (db - target) conflicts */
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Returns a list of conflicts between a db and a list of packages.
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *baddeps = NULL;
 | 
			
		||||
@@ -202,10 +234,12 @@ alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages)
 | 
			
		||||
	return baddeps;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Check the package conflicts in a database
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Check the package conflicts in a database
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param pkglist the list of packages to check
 | 
			
		||||
 *
 | 
			
		||||
 * @return an alpm_list_t of alpm_conflict_t
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_handle_t *handle,
 | 
			
		||||
@@ -215,69 +249,16 @@ alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_handle_t *handle,
 | 
			
		||||
	return _alpm_innerconflicts(handle, pkglist);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const int DIFFERENCE = 0;
 | 
			
		||||
static const int INTERSECT = 1;
 | 
			
		||||
/* Returns a set operation on the provided two lists of files.
 | 
			
		||||
 * Pre-condition: both lists are sorted!
 | 
			
		||||
 * When done, free the list but NOT the contained data.
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Creates and adds a file conflict to a conflict list.
 | 
			
		||||
 *
 | 
			
		||||
 * Operations:
 | 
			
		||||
 *   DIFFERENCE - a difference operation is performed. filesA - filesB.
 | 
			
		||||
 *   INTERSECT - an intersection operation is performed. filesA & filesB.
 | 
			
		||||
 */
 | 
			
		||||
static alpm_list_t *filelist_operation(alpm_filelist_t *filesA,
 | 
			
		||||
		alpm_filelist_t *filesB, int operation)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *ret = NULL;
 | 
			
		||||
	size_t ctrA = 0, ctrB = 0;
 | 
			
		||||
 | 
			
		||||
	while(ctrA < filesA->count && ctrB < filesB->count) {
 | 
			
		||||
		alpm_file_t *fileA = filesA->files + ctrA;
 | 
			
		||||
		alpm_file_t *fileB = filesB->files + ctrB;
 | 
			
		||||
		const char *strA = fileA->name;
 | 
			
		||||
		const char *strB = fileB->name;
 | 
			
		||||
		/* skip directories, we don't care about them */
 | 
			
		||||
		if(strA[strlen(strA)-1] == '/') {
 | 
			
		||||
			ctrA++;
 | 
			
		||||
		} else if(strB[strlen(strB)-1] == '/') {
 | 
			
		||||
			ctrB++;
 | 
			
		||||
		} else {
 | 
			
		||||
			int cmp = strcmp(strA, strB);
 | 
			
		||||
			if(cmp < 0) {
 | 
			
		||||
				if(operation == DIFFERENCE) {
 | 
			
		||||
					/* item only in filesA, qualifies as a difference */
 | 
			
		||||
					ret = alpm_list_add(ret, fileA);
 | 
			
		||||
				}
 | 
			
		||||
				ctrA++;
 | 
			
		||||
			} else if(cmp > 0) {
 | 
			
		||||
				ctrB++;
 | 
			
		||||
			} else {
 | 
			
		||||
				if(operation == INTERSECT) {
 | 
			
		||||
					/* item in both, qualifies as an intersect */
 | 
			
		||||
					ret = alpm_list_add(ret, fileA);
 | 
			
		||||
				}
 | 
			
		||||
				ctrA++;
 | 
			
		||||
				ctrB++;
 | 
			
		||||
			}
 | 
			
		||||
	  }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* if doing a difference, ensure we have completely emptied pA */
 | 
			
		||||
	while(operation == DIFFERENCE && ctrA < filesA->count) {
 | 
			
		||||
		alpm_file_t *fileA = filesA->files + ctrA;
 | 
			
		||||
		const char *strA = fileA->name;
 | 
			
		||||
		/* skip directories */
 | 
			
		||||
		if(strA[strlen(strA)-1] != '/') {
 | 
			
		||||
			ret = alpm_list_add(ret, fileA);
 | 
			
		||||
		}
 | 
			
		||||
		ctrA++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Adds alpm_fileconflict_t to a conflicts list. Pass the conflicts list, the
 | 
			
		||||
 * conflicting file path, and either two packages or one package and NULL.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param conflicts the list of conflicts to append to
 | 
			
		||||
 * @param filestr the conflicting file path
 | 
			
		||||
 * @param pkg1 package that wishes to install the file
 | 
			
		||||
 * @param pkg2 package that currently owns the file, or NULL if unowned
 | 
			
		||||
 *
 | 
			
		||||
 * @return the updated conflict list
 | 
			
		||||
 */
 | 
			
		||||
static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
 | 
			
		||||
		alpm_list_t *conflicts, const char *filestr,
 | 
			
		||||
@@ -306,6 +287,9 @@ error:
 | 
			
		||||
	RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Frees a conflict and its members.
 | 
			
		||||
 */
 | 
			
		||||
void _alpm_fileconflict_free(alpm_fileconflict_t *conflict)
 | 
			
		||||
{
 | 
			
		||||
	FREE(conflict->ctarget);
 | 
			
		||||
@@ -314,29 +298,58 @@ void _alpm_fileconflict_free(alpm_fileconflict_t *conflict)
 | 
			
		||||
	FREE(conflict);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const alpm_file_t *_alpm_filelist_contains(alpm_filelist_t *filelist,
 | 
			
		||||
		const char *name)
 | 
			
		||||
{
 | 
			
		||||
	size_t i;
 | 
			
		||||
	const alpm_file_t *file = filelist->files;
 | 
			
		||||
	for(i = 0; i < filelist->count; i++) {
 | 
			
		||||
		if(strcmp(file->name, name) == 0) {
 | 
			
		||||
			return file;
 | 
			
		||||
		}
 | 
			
		||||
		file++;
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dir_belongsto_pkg(const char *root, const char *dirpath,
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Recursively checks if a package owns all subdirectories and files in
 | 
			
		||||
 * a directory.
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param dirpath path of the directory to check
 | 
			
		||||
 * @param pkg package being checked against
 | 
			
		||||
 *
 | 
			
		||||
 * @return 1 if a package owns all subdirectories and files or a directory
 | 
			
		||||
 * cannot be opened, 0 otherwise
 | 
			
		||||
 */
 | 
			
		||||
static int dir_belongsto_pkg(alpm_handle_t *handle, const char *dirpath,
 | 
			
		||||
		alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
	struct stat sbuf;
 | 
			
		||||
	char path[PATH_MAX];
 | 
			
		||||
	char abspath[PATH_MAX];
 | 
			
		||||
	struct dirent *ent = NULL;
 | 
			
		||||
	DIR *dir;
 | 
			
		||||
	struct dirent *ent = NULL;
 | 
			
		||||
	const char *root = handle->root;
 | 
			
		||||
 | 
			
		||||
	/* check directory is actually in package - used for subdirectory checks */
 | 
			
		||||
	_alpm_filelist_resolve(handle, alpm_pkg_get_files(pkg));
 | 
			
		||||
	if(!alpm_filelist_contains(alpm_pkg_get_files(pkg), dirpath)) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
				"directory %s not in package %s\n", dirpath, pkg->name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* TODO: this is an overly strict check but currently pacman will not
 | 
			
		||||
	 * overwrite a directory with a file (case 10/11 in add.c). Adjusting that
 | 
			
		||||
	 * is not simple as even if the directory is being unowned by a conflicting
 | 
			
		||||
	 * package, pacman does not sort this to ensure all required directory
 | 
			
		||||
	 * "removals" happen before installation of file/symlink */
 | 
			
		||||
 | 
			
		||||
	/* check that no other _installed_ package owns the directory */
 | 
			
		||||
	for(i = _alpm_db_get_pkgcache(handle->db_local); i; i = i->next) {
 | 
			
		||||
		if(pkg == i->data) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		_alpm_filelist_resolve(handle, alpm_pkg_get_files(i->data));
 | 
			
		||||
		if(alpm_filelist_contains(alpm_pkg_get_files(i->data), dirpath)) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"file %s also in package %s\n", dirpath,
 | 
			
		||||
					((alpm_pkg_t*)i->data)->name);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* check all files in directory are owned by the package */
 | 
			
		||||
	snprintf(abspath, PATH_MAX, "%s%s", root, dirpath);
 | 
			
		||||
	dir = opendir(abspath);
 | 
			
		||||
	if(dir == NULL) {
 | 
			
		||||
@@ -349,23 +362,26 @@ static int dir_belongsto_pkg(const char *root, const char *dirpath,
 | 
			
		||||
		if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		snprintf(path, PATH_MAX, "%s/%s", dirpath, name);
 | 
			
		||||
		snprintf(path, PATH_MAX, "%s%s", dirpath, name);
 | 
			
		||||
		snprintf(abspath, PATH_MAX, "%s%s", root, path);
 | 
			
		||||
		if(stat(abspath, &sbuf) != 0) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		if(S_ISDIR(sbuf.st_mode)) {
 | 
			
		||||
			if(dir_belongsto_pkg(root, path, pkg)) {
 | 
			
		||||
			if(dir_belongsto_pkg(handle, path, pkg)) {
 | 
			
		||||
				continue;
 | 
			
		||||
			} else {
 | 
			
		||||
				closedir(dir);
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if(_alpm_filelist_contains(alpm_pkg_get_files(pkg), path)) {
 | 
			
		||||
			_alpm_filelist_resolve(handle, alpm_pkg_get_files(pkg));
 | 
			
		||||
			if(alpm_filelist_contains(alpm_pkg_get_files(pkg), path)) {
 | 
			
		||||
				continue;
 | 
			
		||||
			} else {
 | 
			
		||||
				closedir(dir);
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
						"unowned file %s found in directory\n", path);
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -374,20 +390,38 @@ static int dir_belongsto_pkg(const char *root, const char *dirpath,
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Find file conflicts that may occur during the transaction with two checks:
 | 
			
		||||
 * 1: check every target against every target
 | 
			
		||||
 * 2: check every target against the filesystem */
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Find file conflicts that may occur during the transaction.
 | 
			
		||||
 *
 | 
			
		||||
 * @details Performs two checks:
 | 
			
		||||
 *   1. check every target against every target
 | 
			
		||||
 *   2. check every target against the filesystem
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param upgrade list of packages being installed
 | 
			
		||||
 * @param rem list of packages being removed
 | 
			
		||||
 *
 | 
			
		||||
 * @return list of file conflicts
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
		alpm_list_t *upgrade, alpm_list_t *remove)
 | 
			
		||||
		alpm_list_t *upgrade, alpm_list_t *rem)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i, *conflicts = NULL;
 | 
			
		||||
	size_t numtargs = alpm_list_count(upgrade);
 | 
			
		||||
	size_t current;
 | 
			
		||||
	size_t rootlen;
 | 
			
		||||
 | 
			
		||||
	if(!upgrade) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rootlen = strlen(handle->root);
 | 
			
		||||
 | 
			
		||||
	/* make sure all files to be installed have been resolved */
 | 
			
		||||
	for(i = upgrade; i; i = i->next) {
 | 
			
		||||
		_alpm_filelist_resolve(handle, alpm_pkg_get_files(i->data));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* TODO this whole function needs a huge change, which hopefully will
 | 
			
		||||
	 * be possible with real transactions. Right now we only do half as much
 | 
			
		||||
	 * here as we do when we actually extract files in add.c with our 12
 | 
			
		||||
@@ -395,32 +429,49 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
	for(current = 0, i = upgrade; i; i = i->next, current++) {
 | 
			
		||||
		alpm_pkg_t *p1 = i->data;
 | 
			
		||||
		alpm_list_t *j;
 | 
			
		||||
		alpm_filelist_t tmpfiles;
 | 
			
		||||
		alpm_list_t *tmpfiles = NULL;
 | 
			
		||||
		alpm_pkg_t *dbpkg;
 | 
			
		||||
		size_t filenum;
 | 
			
		||||
 | 
			
		||||
		int percent = (current * 100) / numtargs;
 | 
			
		||||
		PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", percent,
 | 
			
		||||
		         numtargs, current);
 | 
			
		||||
 | 
			
		||||
		/* CHECK 1: check every target against every target */
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "searching for file conflicts: %s\n",
 | 
			
		||||
				p1->name);
 | 
			
		||||
		for(j = i->next; j; j = j->next) {
 | 
			
		||||
			alpm_list_t *common_files;
 | 
			
		||||
			alpm_pkg_t *p2 = j->data;
 | 
			
		||||
			common_files = filelist_operation(alpm_pkg_get_files(p1),
 | 
			
		||||
					alpm_pkg_get_files(p2), INTERSECT);
 | 
			
		||||
 | 
			
		||||
			alpm_filelist_t *p1_files = alpm_pkg_get_files(p1);
 | 
			
		||||
			alpm_filelist_t *p2_files = alpm_pkg_get_files(p2);
 | 
			
		||||
 | 
			
		||||
			common_files = _alpm_filelist_intersection(p1_files, p2_files);
 | 
			
		||||
 | 
			
		||||
			if(common_files) {
 | 
			
		||||
				alpm_list_t *k;
 | 
			
		||||
				char path[PATH_MAX];
 | 
			
		||||
				for(k = common_files; k; k = k->next) {
 | 
			
		||||
					alpm_file_t *file = k->data;
 | 
			
		||||
					snprintf(path, PATH_MAX, "%s%s", handle->root, file->name);
 | 
			
		||||
					char *filename = k->data;
 | 
			
		||||
					snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
 | 
			
		||||
 | 
			
		||||
					/* can skip file-file conflicts when forced *
 | 
			
		||||
					 * checking presence in p2_files detects dir-file or file-dir
 | 
			
		||||
					 * conflicts as the path from p1 is returned */
 | 
			
		||||
					if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
 | 
			
		||||
							alpm_filelist_contains(p2_files, filename)) {
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
							"%s exists in both '%s' and '%s'\n", filename,
 | 
			
		||||
							p1->name, p2->name);
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
							"file-file conflict being forced\n");
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					conflicts = add_fileconflict(handle, conflicts, path, p1, p2);
 | 
			
		||||
					if(handle->pm_errno == ALPM_ERR_MEMORY) {
 | 
			
		||||
						FREELIST(conflicts);
 | 
			
		||||
						FREELIST(common_files);
 | 
			
		||||
						alpm_list_free(common_files);
 | 
			
		||||
						return NULL;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
@@ -439,30 +490,30 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
		 * that the former list needs to be freed while the latter list should NOT
 | 
			
		||||
		 * be freed. */
 | 
			
		||||
		if(dbpkg) {
 | 
			
		||||
			alpm_list_t *difference;
 | 
			
		||||
			/* older ver of package currently installed */
 | 
			
		||||
			difference = filelist_operation(alpm_pkg_get_files(p1),
 | 
			
		||||
					alpm_pkg_get_files(dbpkg), DIFFERENCE);
 | 
			
		||||
			tmpfiles.count = alpm_list_count(difference);
 | 
			
		||||
			tmpfiles.files = alpm_list_to_array(difference, tmpfiles.count,
 | 
			
		||||
					sizeof(alpm_file_t));
 | 
			
		||||
			alpm_list_free(difference);
 | 
			
		||||
			_alpm_filelist_resolve(handle, alpm_pkg_get_files(dbpkg));
 | 
			
		||||
			tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
 | 
			
		||||
					alpm_pkg_get_files(dbpkg));
 | 
			
		||||
		} else {
 | 
			
		||||
			/* no version of package currently installed */
 | 
			
		||||
			tmpfiles = *alpm_pkg_get_files(p1);
 | 
			
		||||
			alpm_filelist_t *fl = alpm_pkg_get_files(p1);
 | 
			
		||||
			size_t filenum;
 | 
			
		||||
			for(filenum = 0; filenum < fl->count; filenum++) {
 | 
			
		||||
				tmpfiles = alpm_list_add(tmpfiles, fl->resolved_path[filenum]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for(filenum = 0; filenum < tmpfiles.count; filenum++) {
 | 
			
		||||
			alpm_file_t *file = tmpfiles.files + filenum;
 | 
			
		||||
			const char *filestr = file->name;
 | 
			
		||||
		for(j = tmpfiles; j; j = j->next) {
 | 
			
		||||
			const char *filestr = j->data;
 | 
			
		||||
			const char *relative_path;
 | 
			
		||||
			alpm_list_t *k;
 | 
			
		||||
			/* have we acted on this conflict? */
 | 
			
		||||
			int resolved_conflict = 0;
 | 
			
		||||
			struct stat lsbuf;
 | 
			
		||||
			char path[PATH_MAX];
 | 
			
		||||
			size_t pathlen;
 | 
			
		||||
 | 
			
		||||
			snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
 | 
			
		||||
			pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
 | 
			
		||||
 | 
			
		||||
			/* stat the file - if it exists, do some checks */
 | 
			
		||||
			if(_alpm_lstat(path, &lsbuf) != 0) {
 | 
			
		||||
@@ -471,7 +522,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
 | 
			
		||||
 | 
			
		||||
			if(S_ISDIR(file->mode)) {
 | 
			
		||||
			if(filestr[strlen(filestr) - 1] == '/') {
 | 
			
		||||
				struct stat sbuf;
 | 
			
		||||
				if(S_ISDIR(lsbuf.st_mode)) {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
 | 
			
		||||
@@ -486,15 +537,16 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
				/* if we made it to here, we want all subsequent path comparisons to
 | 
			
		||||
				 * not include the trailing slash. This allows things like file ->
 | 
			
		||||
				 * directory replacements. */
 | 
			
		||||
				path[strlen(path) - 1] = '\0';
 | 
			
		||||
				path[pathlen - 1] = '\0';
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			relative_path = path + strlen(handle->root);
 | 
			
		||||
			relative_path = path + rootlen;
 | 
			
		||||
 | 
			
		||||
			/* Check remove list (will we remove the conflicting local file?) */
 | 
			
		||||
			for(k = remove; k && !resolved_conflict; k = k->next) {
 | 
			
		||||
			for(k = rem; k && !resolved_conflict; k = k->next) {
 | 
			
		||||
				alpm_pkg_t *rempkg = k->data;
 | 
			
		||||
				if(rempkg && _alpm_filelist_contains(alpm_pkg_get_files(rempkg),
 | 
			
		||||
				_alpm_filelist_resolve(handle, alpm_pkg_get_files(rempkg));
 | 
			
		||||
				if(rempkg && alpm_filelist_contains(alpm_pkg_get_files(rempkg),
 | 
			
		||||
							relative_path)) {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
							"local file will be removed, not a conflict\n");
 | 
			
		||||
@@ -511,7 +563,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
				alpm_pkg_t *localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name);
 | 
			
		||||
 | 
			
		||||
				/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
 | 
			
		||||
				if(localp2 && _alpm_filelist_contains(alpm_pkg_get_files(localp2), filestr)) {
 | 
			
		||||
				_alpm_filelist_resolve(handle, alpm_pkg_get_files(localp2));
 | 
			
		||||
				if(localp2 && alpm_filelist_contains(alpm_pkg_get_files(localp2), filestr)) {
 | 
			
		||||
					/* skip removal of file, but not add. this will prevent a second
 | 
			
		||||
					 * package from removing the file when it was already installed
 | 
			
		||||
					 * by its new owner (whether the file is in backup array or not */
 | 
			
		||||
@@ -527,11 +580,11 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
			if(!resolved_conflict && S_ISDIR(lsbuf.st_mode) && dbpkg) {
 | 
			
		||||
				char *dir = malloc(strlen(filestr) + 2);
 | 
			
		||||
				sprintf(dir, "%s/", filestr);
 | 
			
		||||
				if(_alpm_filelist_contains(alpm_pkg_get_files(dbpkg), dir)) {
 | 
			
		||||
				if(alpm_filelist_contains(alpm_pkg_get_files(dbpkg), dir)) {
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
							"check if all files in %s belongs to %s\n",
 | 
			
		||||
							"checking if all files in %s belong to %s\n",
 | 
			
		||||
							dir, dbpkg->name);
 | 
			
		||||
					resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
 | 
			
		||||
					resolved_conflict = dir_belongsto_pkg(handle, dir, dbpkg);
 | 
			
		||||
				}
 | 
			
		||||
				free(dir);
 | 
			
		||||
			}
 | 
			
		||||
@@ -541,17 +594,15 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
			 * consideration cannot itself be a link, as it might be unowned- path
 | 
			
		||||
			 * components can be safely checked as all directories are "unowned". */
 | 
			
		||||
			if(!resolved_conflict && dbpkg && !S_ISLNK(lsbuf.st_mode)) {
 | 
			
		||||
				char *rpath = calloc(PATH_MAX, sizeof(char));
 | 
			
		||||
				const char *relative_rpath;
 | 
			
		||||
				char rpath[PATH_MAX];
 | 
			
		||||
				if(realpath(path, rpath)) {
 | 
			
		||||
					relative_rpath = rpath + strlen(handle->root);
 | 
			
		||||
					if(_alpm_filelist_contains(alpm_pkg_get_files(dbpkg), relative_rpath)) {
 | 
			
		||||
					const char *relative_rpath = rpath + rootlen;
 | 
			
		||||
					if(alpm_filelist_contains(alpm_pkg_get_files(dbpkg), relative_rpath)) {
 | 
			
		||||
						_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
								"package contained the resolved realpath\n");
 | 
			
		||||
						resolved_conflict = 1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				free(rpath);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			/* is the file unowned and in the backup list of the new package? */
 | 
			
		||||
@@ -559,7 +610,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
				alpm_list_t *local_pkgs = _alpm_db_get_pkgcache(handle->db_local);
 | 
			
		||||
				int found = 0;
 | 
			
		||||
				for(k = local_pkgs; k && !found; k = k->next) {
 | 
			
		||||
					if(_alpm_filelist_contains(alpm_pkg_get_files(k->data), filestr)) {
 | 
			
		||||
					_alpm_filelist_resolve(handle, alpm_pkg_get_files(k->data));
 | 
			
		||||
					if(alpm_filelist_contains(alpm_pkg_get_files(k->data), filestr)) {
 | 
			
		||||
							found = 1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
@@ -570,22 +622,24 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			/* skip file-file conflicts when being forced */
 | 
			
		||||
			if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
 | 
			
		||||
					!S_ISDIR(lsbuf.st_mode)) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
							"conflict with file on filesystem being forced\n");
 | 
			
		||||
				resolved_conflict = 1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(!resolved_conflict) {
 | 
			
		||||
				conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
 | 
			
		||||
				if(handle->pm_errno == ALPM_ERR_MEMORY) {
 | 
			
		||||
					FREELIST(conflicts);
 | 
			
		||||
					if(dbpkg) {
 | 
			
		||||
						/* only freed if it was generated from filelist_operation() */
 | 
			
		||||
						free(tmpfiles.files);
 | 
			
		||||
					}
 | 
			
		||||
					alpm_list_free(tmpfiles);
 | 
			
		||||
					return NULL;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if(dbpkg) {
 | 
			
		||||
			/* only freed if it was generated from filelist_operation() */
 | 
			
		||||
			free(tmpfiles.files);
 | 
			
		||||
		}
 | 
			
		||||
		alpm_list_free(tmpfiles);
 | 
			
		||||
	}
 | 
			
		||||
	PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
 | 
			
		||||
			numtargs, current);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  conflict.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -33,9 +33,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 | 
			
		||||
 | 
			
		||||
void _alpm_fileconflict_free(alpm_fileconflict_t *conflict);
 | 
			
		||||
 | 
			
		||||
const alpm_file_t *_alpm_filelist_contains(alpm_filelist_t *filelist,
 | 
			
		||||
		const char *name);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_CONFLICT_H */
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  db.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
 | 
			
		||||
@@ -22,8 +22,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@@ -45,7 +43,7 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Register a sync database of packages. */
 | 
			
		||||
alpm_db_t SYMEXPORT *alpm_db_register_sync(alpm_handle_t *handle,
 | 
			
		||||
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
 | 
			
		||||
		const char *treename, alpm_siglevel_t level)
 | 
			
		||||
{
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
@@ -70,7 +68,7 @@ void _alpm_db_unregister(alpm_db_t *db)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Unregister all package databases. */
 | 
			
		||||
int SYMEXPORT alpm_db_unregister_all(alpm_handle_t *handle)
 | 
			
		||||
int SYMEXPORT alpm_unregister_all_syncdbs(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
	alpm_db_t *db;
 | 
			
		||||
@@ -109,7 +107,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
 | 
			
		||||
	} else {
 | 
			
		||||
		/* Warning : this function shouldn't be used to unregister all sync
 | 
			
		||||
		 * databases by walking through the list returned by
 | 
			
		||||
		 * alpm_option_get_syncdbs, because the db is removed from that list here.
 | 
			
		||||
		 * alpm_get_syncdbs, because the db is removed from that list here.
 | 
			
		||||
		 */
 | 
			
		||||
		void *data;
 | 
			
		||||
		handle->dbs_sync = alpm_list_remove(handle->dbs_sync,
 | 
			
		||||
@@ -138,7 +136,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db)
 | 
			
		||||
int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(db != NULL, return -1);
 | 
			
		||||
	if(db->servers) FREELIST(db->servers);
 | 
			
		||||
	FREELIST(db->servers);
 | 
			
		||||
	db->servers = servers;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -190,6 +188,7 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
 | 
			
		||||
int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
 | 
			
		||||
{
 | 
			
		||||
	char *newurl, *vdata = NULL;
 | 
			
		||||
	int ret = 1;
 | 
			
		||||
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
	ASSERT(db != NULL, return -1);
 | 
			
		||||
@@ -200,16 +199,18 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
 | 
			
		||||
	if(!newurl) {
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	db->servers = alpm_list_remove_str(db->servers, newurl, &vdata);
 | 
			
		||||
	free(newurl);
 | 
			
		||||
 | 
			
		||||
	if(vdata) {
 | 
			
		||||
		_alpm_log(db->handle, ALPM_LOG_DEBUG, "removed server URL from database '%s': %s\n",
 | 
			
		||||
				db->treename, newurl);
 | 
			
		||||
		free(vdata);
 | 
			
		||||
		return 0;
 | 
			
		||||
		ret = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
	free(newurl);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Get the name of a package database. */
 | 
			
		||||
@@ -263,7 +264,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Get a group entry from a package database. */
 | 
			
		||||
alpm_group_t SYMEXPORT *alpm_db_readgroup(alpm_db_t *db, const char *name)
 | 
			
		||||
alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(db != NULL, return NULL);
 | 
			
		||||
	db->handle->pm_errno = 0;
 | 
			
		||||
@@ -283,7 +284,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Searches a database. */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t* needles)
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(db != NULL, return NULL);
 | 
			
		||||
	db->handle->pm_errno = 0;
 | 
			
		||||
@@ -291,32 +292,6 @@ alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t* needles)
 | 
			
		||||
	return _alpm_db_search(db, needles);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Set install reason for a package in db. */
 | 
			
		||||
int SYMEXPORT alpm_db_set_pkgreason(alpm_handle_t *handle, alpm_pkg_t *pkg,
 | 
			
		||||
		alpm_pkgreason_t reason)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
	ASSERT(pkg->origin == PKG_FROM_LOCALDB,
 | 
			
		||||
			RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
	ASSERT(pkg->origin_data.db == handle->db_local,
 | 
			
		||||
			RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
			"setting install reason %u for %s\n", reason, pkg->name);
 | 
			
		||||
	if(alpm_pkg_get_reason(pkg) == reason) {
 | 
			
		||||
		/* we are done */
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	/* set reason (in pkgcache) */
 | 
			
		||||
	pkg->reason = reason;
 | 
			
		||||
	/* write DESC */
 | 
			
		||||
	if(_alpm_local_db_write(handle->db_local, pkg, INFRQ_DESC)) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_DB_WRITE, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
@@ -429,7 +404,7 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
 | 
			
		||||
				for(k = alpm_pkg_get_provides(pkg); k; k = k->next) {
 | 
			
		||||
					alpm_depend_t *provide = k->data;
 | 
			
		||||
					if(regexec(®, provide->name, 0, 0, 0) == 0) {
 | 
			
		||||
						matched = k->data;
 | 
			
		||||
						matched = provide->name;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
@@ -445,8 +420,8 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(matched != NULL) {
 | 
			
		||||
				_alpm_log(db->handle, ALPM_LOG_DEBUG, "    search target '%s' matched '%s'\n",
 | 
			
		||||
				          targ, matched);
 | 
			
		||||
				_alpm_log(db->handle, ALPM_LOG_DEBUG,
 | 
			
		||||
						"search target '%s' matched '%s'\n", targ, matched);
 | 
			
		||||
				ret = alpm_list_add(ret, pkg);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  db.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
 | 
			
		||||
@@ -22,8 +22,6 @@
 | 
			
		||||
#ifndef _ALPM_DB_H
 | 
			
		||||
#define _ALPM_DB_H
 | 
			
		||||
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
#include <archive_entry.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  delta.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,8 +18,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdint.h> /* intmax_t */
 | 
			
		||||
@@ -266,64 +264,71 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
	return find_unused(pkg->deltas, pkg->filename, pkg->size * MAX_DELTA_RATIO);
 | 
			
		||||
	return find_unused(pkg->deltas, pkg->filename,
 | 
			
		||||
			pkg->size * pkg->handle->deltaratio);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
#define NUM_MATCHES 6
 | 
			
		||||
 | 
			
		||||
/** Parses the string representation of a alpm_delta_t object.
 | 
			
		||||
 * This function assumes that the string is in the correct format.
 | 
			
		||||
 * This format is as follows:
 | 
			
		||||
 * $deltafile $deltamd5 $deltasize $oldfile $newfile
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param line the string to parse
 | 
			
		||||
 * @return A pointer to the new alpm_delta_t object
 | 
			
		||||
 */
 | 
			
		||||
/* TODO this does not really belong here, but in a parsing lib */
 | 
			
		||||
alpm_delta_t *_alpm_delta_parse(char *line)
 | 
			
		||||
alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
 | 
			
		||||
{
 | 
			
		||||
	alpm_delta_t *delta;
 | 
			
		||||
	char *tmp = line, *tmp2;
 | 
			
		||||
	regex_t reg;
 | 
			
		||||
	size_t len;
 | 
			
		||||
	regmatch_t pmatch[NUM_MATCHES];
 | 
			
		||||
	char filesize[32];
 | 
			
		||||
 | 
			
		||||
	regcomp(®,
 | 
			
		||||
			"^[^[:space:]]* [[:xdigit:]]{32} [[:digit:]]*"
 | 
			
		||||
			" [^[:space:]]* [^[:space:]]*$",
 | 
			
		||||
			REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
 | 
			
		||||
	if(regexec(®, line, 0, 0, 0) != 0) {
 | 
			
		||||
	/* this is so we only have to compile the pattern once */
 | 
			
		||||
	if(!handle->delta_regex_compiled) {
 | 
			
		||||
		/* $deltafile $deltamd5 $deltasize $oldfile $newfile*/
 | 
			
		||||
		regcomp(&handle->delta_regex,
 | 
			
		||||
				"^([^[:space:]]+) ([[:xdigit:]]{32}) ([[:digit:]]+)"
 | 
			
		||||
				" ([^[:space:]]+) ([^[:space:]]+)$",
 | 
			
		||||
				REG_EXTENDED | REG_NEWLINE);
 | 
			
		||||
		handle->delta_regex_compiled = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(regexec(&handle->delta_regex, line, NUM_MATCHES, pmatch, 0) != 0) {
 | 
			
		||||
		/* delta line is invalid, return NULL */
 | 
			
		||||
		regfree(®);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	regfree(®);
 | 
			
		||||
 | 
			
		||||
	CALLOC(delta, 1, sizeof(alpm_delta_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	tmp2 = tmp;
 | 
			
		||||
	tmp = strchr(tmp, ' ');
 | 
			
		||||
	*(tmp++) = '\0';
 | 
			
		||||
	STRDUP(delta->delta, tmp2, return NULL);
 | 
			
		||||
	/* start at index 1 -- match 0 is the entire match */
 | 
			
		||||
	len = pmatch[1].rm_eo - pmatch[1].rm_so;
 | 
			
		||||
	STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, return NULL);
 | 
			
		||||
 | 
			
		||||
	tmp2 = tmp;
 | 
			
		||||
	tmp = strchr(tmp, ' ');
 | 
			
		||||
	*(tmp++) = '\0';
 | 
			
		||||
	STRDUP(delta->delta_md5, tmp2, return NULL);
 | 
			
		||||
	len = pmatch[2].rm_eo - pmatch[2].rm_so;
 | 
			
		||||
	STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, return NULL);
 | 
			
		||||
 | 
			
		||||
	tmp2 = tmp;
 | 
			
		||||
	tmp = strchr(tmp, ' ');
 | 
			
		||||
	*(tmp++) = '\0';
 | 
			
		||||
	delta->delta_size = _alpm_strtoofft(tmp2);
 | 
			
		||||
	len = pmatch[3].rm_eo - pmatch[3].rm_so;
 | 
			
		||||
	if(len < sizeof(filesize)) {
 | 
			
		||||
		strncpy(filesize, &line[pmatch[3].rm_so], len);
 | 
			
		||||
		filesize[len] = '\0';
 | 
			
		||||
		delta->delta_size = _alpm_strtoofft(filesize);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tmp2 = tmp;
 | 
			
		||||
	tmp = strchr(tmp, ' ');
 | 
			
		||||
	*(tmp++) = '\0';
 | 
			
		||||
	STRDUP(delta->from, tmp2, return NULL);
 | 
			
		||||
	len = pmatch[4].rm_eo - pmatch[4].rm_so;
 | 
			
		||||
	STRNDUP(delta->from, &line[pmatch[4].rm_so], len, return NULL);
 | 
			
		||||
 | 
			
		||||
	tmp2 = tmp;
 | 
			
		||||
	STRDUP(delta->to, tmp2, return NULL);
 | 
			
		||||
	len = pmatch[5].rm_eo - pmatch[5].rm_so;
 | 
			
		||||
	STRNDUP(delta->to, &line[pmatch[5].rm_so], len, return NULL);
 | 
			
		||||
 | 
			
		||||
	return delta;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#undef NUM_MATCHES
 | 
			
		||||
 | 
			
		||||
void _alpm_delta_free(alpm_delta_t *delta)
 | 
			
		||||
{
 | 
			
		||||
	FREE(delta->delta);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  delta.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -20,21 +20,16 @@
 | 
			
		||||
#ifndef _ALPM_DELTA_H
 | 
			
		||||
#define _ALPM_DELTA_H
 | 
			
		||||
 | 
			
		||||
#include "config.h" /* ensure off_t is correct length */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h> /* off_t */
 | 
			
		||||
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
 | 
			
		||||
alpm_delta_t *_alpm_delta_parse(char *line);
 | 
			
		||||
alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line);
 | 
			
		||||
void _alpm_delta_free(alpm_delta_t *delta);
 | 
			
		||||
alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta);
 | 
			
		||||
off_t _alpm_shortest_delta_path(alpm_handle_t *handle, alpm_list_t *deltas,
 | 
			
		||||
		const char *to, alpm_list_t **path);
 | 
			
		||||
 | 
			
		||||
/* max percent of package size to download deltas */
 | 
			
		||||
#define MAX_DELTA_RATIO 0.7
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_DELTA_H */
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  deps.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
 | 
			
		||||
@@ -20,8 +20,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@@ -41,6 +39,7 @@ void _alpm_dep_free(alpm_depend_t *dep)
 | 
			
		||||
{
 | 
			
		||||
	FREE(dep->name);
 | 
			
		||||
	FREE(dep->version);
 | 
			
		||||
	FREE(dep->desc);
 | 
			
		||||
	FREE(dep);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -159,15 +158,17 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
 | 
			
		||||
			else if(nextchild->state == -1) {
 | 
			
		||||
				alpm_pkg_t *vertexpkg = vertex->data;
 | 
			
		||||
				alpm_pkg_t *childpkg = nextchild->data;
 | 
			
		||||
				const char *message;
 | 
			
		||||
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
 | 
			
		||||
				if(reverse) {
 | 
			
		||||
					message =_("%s will be removed after its %s dependency\n");
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
							_("%s will be removed after its %s dependency\n"),
 | 
			
		||||
							vertexpkg->name, childpkg->name);
 | 
			
		||||
				} else {
 | 
			
		||||
					message =_("%s will be installed before its %s dependency\n");
 | 
			
		||||
					_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
							_("%s will be installed before its %s dependency\n"),
 | 
			
		||||
							vertexpkg->name, childpkg->name);
 | 
			
		||||
				}
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_WARNING, message, vertexpkg->name, childpkg->name);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if(!found) {
 | 
			
		||||
@@ -204,8 +205,10 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
 | 
			
		||||
 | 
			
		||||
static int no_dep_version(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	int flags = alpm_trans_get_flags(handle);
 | 
			
		||||
	return flags != -1 && (flags & ALPM_TRANS_FLAG_NODEPVERSION);
 | 
			
		||||
	if(!handle->trans) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	return (handle->trans->flags & ALPM_TRANS_FLAG_NODEPVERSION);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion)
 | 
			
		||||
@@ -266,7 +269,7 @@ alpm_pkg_t SYMEXPORT *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstri
 | 
			
		||||
 * @return an alpm_list_t* of alpm_depmissing_t pointers.
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
 | 
			
		||||
		alpm_list_t *pkglist, alpm_list_t *remove, alpm_list_t *upgrade,
 | 
			
		||||
		alpm_list_t *pkglist, alpm_list_t *rem, alpm_list_t *upgrade,
 | 
			
		||||
		int reversedeps)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i, *j;
 | 
			
		||||
@@ -278,7 +281,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
 | 
			
		||||
 | 
			
		||||
	for(i = pkglist; i; i = i->next) {
 | 
			
		||||
		alpm_pkg_t *pkg = i->data;
 | 
			
		||||
		if(_alpm_pkg_find(remove, pkg->name) || _alpm_pkg_find(upgrade, pkg->name)) {
 | 
			
		||||
		if(alpm_pkg_find(rem, pkg->name) || alpm_pkg_find(upgrade, pkg->name)) {
 | 
			
		||||
			modified = alpm_list_add(modified, pkg);
 | 
			
		||||
		} else {
 | 
			
		||||
			dblist = alpm_list_add(dblist, pkg);
 | 
			
		||||
@@ -395,7 +398,7 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
 | 
			
		||||
			/* any version will satisfy the requirement */
 | 
			
		||||
			satisfy = (provision->name_hash == dep->name_hash
 | 
			
		||||
					&& strcmp(provision->name, dep->name) == 0);
 | 
			
		||||
		} else if (provision->mod == ALPM_DEP_MOD_EQ) {
 | 
			
		||||
		} else if(provision->mod == ALPM_DEP_MOD_EQ) {
 | 
			
		||||
			/* provision specifies a version, so try it out */
 | 
			
		||||
			satisfy = (provision->name_hash == dep->name_hash
 | 
			
		||||
					&& strcmp(provision->name, dep->name) == 0
 | 
			
		||||
@@ -409,7 +412,7 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
 | 
			
		||||
alpm_depend_t *_alpm_splitdep(const char *depstring)
 | 
			
		||||
{
 | 
			
		||||
	alpm_depend_t *depend;
 | 
			
		||||
	const char *ptr, *version;
 | 
			
		||||
	const char *ptr, *version, *desc;
 | 
			
		||||
	size_t deplen;
 | 
			
		||||
 | 
			
		||||
	if(depstring == NULL) {
 | 
			
		||||
@@ -417,7 +420,17 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	MALLOC(depend, sizeof(alpm_depend_t), return NULL);
 | 
			
		||||
	deplen = strlen(depstring);
 | 
			
		||||
 | 
			
		||||
	/* Note the extra space in ": " to avoid matching the epoch */
 | 
			
		||||
	if((desc = strstr(depstring, ": ")) != NULL) {
 | 
			
		||||
		STRDUP(depend->desc, desc + 2, return NULL);
 | 
			
		||||
		deplen = desc - depstring;
 | 
			
		||||
	} else {
 | 
			
		||||
		/* no description- point desc at NULL at end of string for later use */
 | 
			
		||||
		depend->desc = NULL;
 | 
			
		||||
		deplen = strlen(depstring);
 | 
			
		||||
		desc = depstring + deplen;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Find a version comparator if one exists. If it does, set the type and
 | 
			
		||||
	 * increment the ptr accordingly so we can copy the right strings. */
 | 
			
		||||
@@ -442,21 +455,18 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
 | 
			
		||||
		depend->mod = ALPM_DEP_MOD_EQ;
 | 
			
		||||
		version = ptr + 1;
 | 
			
		||||
	} else {
 | 
			
		||||
		/* no version specified, leave ptr NULL and set version to NULL */
 | 
			
		||||
		/* no version specified, set ptr to end of string and version to NULL */
 | 
			
		||||
		ptr = depstring + deplen;
 | 
			
		||||
		depend->mod = ALPM_DEP_MOD_ANY;
 | 
			
		||||
		depend->version = NULL;
 | 
			
		||||
		version = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* copy the right parts to the right places */
 | 
			
		||||
	if(ptr) {
 | 
			
		||||
		STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
 | 
			
		||||
	} else {
 | 
			
		||||
		STRDUP(depend->name, depstring, return NULL);
 | 
			
		||||
	}
 | 
			
		||||
	STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
 | 
			
		||||
	depend->name_hash = _alpm_hash_sdbm(depend->name);
 | 
			
		||||
	if(version) {
 | 
			
		||||
		STRDUP(depend->version, version, return NULL);
 | 
			
		||||
		STRNDUP(depend->version, version, desc - version, return NULL);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return depend;
 | 
			
		||||
@@ -468,8 +478,9 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
 | 
			
		||||
	CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	STRDUP(newdep->name, dep->name, return NULL);
 | 
			
		||||
	newdep->name_hash = dep->name_hash;
 | 
			
		||||
	STRDUP(newdep->version, dep->version, return NULL);
 | 
			
		||||
	STRDUP(newdep->desc, dep->desc, return NULL);
 | 
			
		||||
	newdep->name_hash = dep->name_hash;
 | 
			
		||||
	newdep->mod = dep->mod;
 | 
			
		||||
 | 
			
		||||
	return newdep;
 | 
			
		||||
@@ -484,7 +495,7 @@ static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg,
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
 | 
			
		||||
	if(_alpm_pkg_find(targets, pkg->name)) {
 | 
			
		||||
	if(alpm_pkg_find(targets, pkg->name)) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -506,7 +517,7 @@ static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg,
 | 
			
		||||
	/* see if other packages need it */
 | 
			
		||||
	for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
 | 
			
		||||
		alpm_pkg_t *lpkg = i->data;
 | 
			
		||||
		if(_alpm_dep_edge(lpkg, pkg) && !_alpm_pkg_find(targets, lpkg->name)) {
 | 
			
		||||
		if(_alpm_dep_edge(lpkg, pkg) && !alpm_pkg_find(targets, lpkg->name)) {
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -580,7 +591,7 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
 | 
			
		||||
	for(i = dbs; i; i = i->next) {
 | 
			
		||||
		alpm_pkg_t *pkg = _alpm_db_get_pkgfromcache(i->data, dep->name);
 | 
			
		||||
		if(pkg && _alpm_depcmp_literal(pkg, dep)
 | 
			
		||||
				&& !_alpm_pkg_find(excluding, pkg->name)) {
 | 
			
		||||
				&& !alpm_pkg_find(excluding, pkg->name)) {
 | 
			
		||||
			if(_alpm_pkg_should_ignore(handle, pkg)) {
 | 
			
		||||
				int install = 0;
 | 
			
		||||
				if(prompt) {
 | 
			
		||||
@@ -605,7 +616,7 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
 | 
			
		||||
			/* with hash != hash, we can even skip the strcmp() as we know they can't
 | 
			
		||||
			 * possibly be the same string */
 | 
			
		||||
			if(pkg->name_hash != dep->name_hash && _alpm_depcmp(pkg, dep)
 | 
			
		||||
					&& !_alpm_pkg_find(excluding, pkg->name)) {
 | 
			
		||||
					&& !alpm_pkg_find(excluding, pkg->name)) {
 | 
			
		||||
				if(_alpm_pkg_should_ignore(handle, pkg)) {
 | 
			
		||||
					int install = 0;
 | 
			
		||||
					if(prompt) {
 | 
			
		||||
@@ -639,14 +650,14 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
 | 
			
		||||
	count = alpm_list_count(providers);
 | 
			
		||||
	if(count >= 1) {
 | 
			
		||||
		/* default to first provider if there is no QUESTION callback */
 | 
			
		||||
		int index = 0;
 | 
			
		||||
		int idx = 0;
 | 
			
		||||
		if(count > 1) {
 | 
			
		||||
			/* if there is more than one provider, we ask the user */
 | 
			
		||||
			QUESTION(handle, ALPM_QUESTION_SELECT_PROVIDER,
 | 
			
		||||
					providers, dep, NULL, &index);
 | 
			
		||||
					providers, dep, NULL, &idx);
 | 
			
		||||
		}
 | 
			
		||||
		if(index >= 0 && index < count) {
 | 
			
		||||
			alpm_list_t *nth = alpm_list_nth(providers, index);
 | 
			
		||||
		if(idx >= 0 && idx < count) {
 | 
			
		||||
			alpm_list_t *nth = alpm_list_nth(providers, idx);
 | 
			
		||||
			alpm_pkg_t *pkg = nth->data;
 | 
			
		||||
			alpm_list_free(providers);
 | 
			
		||||
			return pkg;
 | 
			
		||||
@@ -711,24 +722,18 @@ alpm_pkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_handle_t *handle,
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
 | 
			
		||||
		alpm_pkg_t *pkg, alpm_list_t *preferred, alpm_list_t **packages,
 | 
			
		||||
		alpm_list_t *remove, alpm_list_t **data)
 | 
			
		||||
		alpm_list_t *rem, alpm_list_t **data)
 | 
			
		||||
{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	alpm_list_t *i, *j;
 | 
			
		||||
	alpm_list_t *j;
 | 
			
		||||
	alpm_list_t *targ;
 | 
			
		||||
	alpm_list_t *deps = NULL;
 | 
			
		||||
	alpm_list_t *packages_copy;
 | 
			
		||||
 | 
			
		||||
	if(_alpm_pkg_find(*packages, pkg->name) != NULL) {
 | 
			
		||||
	if(alpm_pkg_find(*packages, pkg->name) != NULL) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(handle->trans->flags & ALPM_TRANS_FLAG_RECURSE) {
 | 
			
		||||
		/* removing local packages from the equation causes the entire dep chain to
 | 
			
		||||
		 * get pulled for each target- e.g., pactree -u output */
 | 
			
		||||
		localpkgs = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Create a copy of the packages list, so that it can be restored
 | 
			
		||||
	   on error */
 | 
			
		||||
	packages_copy = alpm_list_copy(*packages);
 | 
			
		||||
@@ -737,72 +742,49 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
 | 
			
		||||
	*packages = alpm_list_add(*packages, pkg);
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "started resolving dependencies\n");
 | 
			
		||||
	for(i = alpm_list_last(*packages); i; i = i->next) {
 | 
			
		||||
		alpm_pkg_t *tpkg = i->data;
 | 
			
		||||
		targ = alpm_list_add(NULL, tpkg);
 | 
			
		||||
		deps = alpm_checkdeps(handle, localpkgs, remove, targ, 0);
 | 
			
		||||
		alpm_list_free(targ);
 | 
			
		||||
	targ = alpm_list_add(NULL, pkg);
 | 
			
		||||
	deps = alpm_checkdeps(handle, localpkgs, rem, targ, 0);
 | 
			
		||||
	alpm_list_free(targ);
 | 
			
		||||
	targ = NULL;
 | 
			
		||||
 | 
			
		||||
		for(j = deps; j; j = j->next) {
 | 
			
		||||
			alpm_depmissing_t *miss = j->data;
 | 
			
		||||
			alpm_depend_t *missdep = miss->depend;
 | 
			
		||||
			/* check if one of the packages in the [*packages] list already satisfies
 | 
			
		||||
			 * this dependency */
 | 
			
		||||
			if(find_dep_satisfier(*packages, missdep)) {
 | 
			
		||||
				_alpm_depmiss_free(miss);
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
			/* check if one of the packages in the [preferred] list already satisfies
 | 
			
		||||
			 * this dependency */
 | 
			
		||||
			alpm_pkg_t *spkg = find_dep_satisfier(preferred, missdep);
 | 
			
		||||
			if(!spkg) {
 | 
			
		||||
				/* find a satisfier package in the given repositories */
 | 
			
		||||
				spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0);
 | 
			
		||||
			}
 | 
			
		||||
			if(!spkg) {
 | 
			
		||||
				handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
 | 
			
		||||
				char *missdepstring = alpm_dep_compute_string(missdep);
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
						_("cannot resolve \"%s\", a dependency of \"%s\"\n"),
 | 
			
		||||
						missdepstring, tpkg->name);
 | 
			
		||||
				free(missdepstring);
 | 
			
		||||
				if(data) {
 | 
			
		||||
					*data = alpm_list_add(*data, miss);
 | 
			
		||||
				}
 | 
			
		||||
				ret = -1;
 | 
			
		||||
			} else {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
						"pulling dependency %s (needed by %s)\n",
 | 
			
		||||
						spkg->name, tpkg->name);
 | 
			
		||||
				*packages = alpm_list_add(*packages, spkg);
 | 
			
		||||
				_alpm_depmiss_free(miss);
 | 
			
		||||
			}
 | 
			
		||||
	for(j = deps; j; j = j->next) {
 | 
			
		||||
		alpm_depmissing_t *miss = j->data;
 | 
			
		||||
		alpm_depend_t *missdep = miss->depend;
 | 
			
		||||
		/* check if one of the packages in the [*packages] list already satisfies
 | 
			
		||||
		 * this dependency */
 | 
			
		||||
		if(find_dep_satisfier(*packages, missdep)) {
 | 
			
		||||
			_alpm_depmiss_free(miss);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		alpm_list_free(deps);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(handle->trans->flags & ALPM_TRANS_FLAG_NEEDED) {
 | 
			
		||||
		/* remove any deps that were pulled that match installed version */
 | 
			
		||||
		/* odd loop syntax so we can modify the list as we iterate */
 | 
			
		||||
		i = *packages;
 | 
			
		||||
		while(i) {
 | 
			
		||||
			alpm_pkg_t *tpkg = i->data;
 | 
			
		||||
			alpm_pkg_t *local = _alpm_db_get_pkgfromcache(
 | 
			
		||||
					handle->db_local, tpkg->name);
 | 
			
		||||
			if(local && _alpm_pkg_compare_versions(tpkg, local) == 0) {
 | 
			
		||||
				/* with the NEEDED flag, packages up to date are not reinstalled */
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
						"not adding dep %s-%s as it is not needed, same version\n",
 | 
			
		||||
						local->name, local->version);
 | 
			
		||||
				j = i;
 | 
			
		||||
				i = i->next;
 | 
			
		||||
				*packages = alpm_list_remove_item(*packages, j);
 | 
			
		||||
				free(j);
 | 
			
		||||
			} else {
 | 
			
		||||
				i = i->next;
 | 
			
		||||
		/* check if one of the packages in the [preferred] list already satisfies
 | 
			
		||||
		 * this dependency */
 | 
			
		||||
		alpm_pkg_t *spkg = find_dep_satisfier(preferred, missdep);
 | 
			
		||||
		if(!spkg) {
 | 
			
		||||
			/* find a satisfier package in the given repositories */
 | 
			
		||||
			spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0);
 | 
			
		||||
		}
 | 
			
		||||
		if(spkg && _alpm_resolvedeps(handle, localpkgs, spkg, preferred, packages, rem, data) == 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"pulling dependency %s (needed by %s)\n",
 | 
			
		||||
					spkg->name, pkg->name);
 | 
			
		||||
			_alpm_depmiss_free(miss);
 | 
			
		||||
		} else if(resolvedep(handle, missdep, (targ = alpm_list_add(NULL, handle->db_local)), rem, 0)) {
 | 
			
		||||
			_alpm_depmiss_free(miss);
 | 
			
		||||
		} else {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
 | 
			
		||||
			char *missdepstring = alpm_dep_compute_string(missdep);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
					_("cannot resolve \"%s\", a dependency of \"%s\"\n"),
 | 
			
		||||
					missdepstring, pkg->name);
 | 
			
		||||
			free(missdepstring);
 | 
			
		||||
			if(data) {
 | 
			
		||||
				*data = alpm_list_add(*data, miss);
 | 
			
		||||
			}
 | 
			
		||||
			ret = -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	alpm_list_free(targ);
 | 
			
		||||
	alpm_list_free(deps);
 | 
			
		||||
 | 
			
		||||
	if(ret != 0) {
 | 
			
		||||
		alpm_list_free(*packages);
 | 
			
		||||
@@ -821,7 +803,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
 | 
			
		||||
 */
 | 
			
		||||
char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
 | 
			
		||||
{
 | 
			
		||||
	const char *name, *opr, *ver;
 | 
			
		||||
	const char *name, *opr, *ver, *desc_delim, *desc;
 | 
			
		||||
	char *str;
 | 
			
		||||
	size_t len;
 | 
			
		||||
 | 
			
		||||
@@ -863,12 +845,21 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
 | 
			
		||||
		ver = "";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(dep->desc) {
 | 
			
		||||
		desc_delim = ": ";
 | 
			
		||||
		desc = dep->desc;
 | 
			
		||||
	} else {
 | 
			
		||||
		desc_delim = "";
 | 
			
		||||
		desc = "";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* we can always compute len and print the string like this because opr
 | 
			
		||||
	 * and ver will be empty when ALPM_DEP_MOD_ANY is the depend type. the
 | 
			
		||||
	 * reassignments above also ensure we do not do a strlen(NULL). */
 | 
			
		||||
	len = strlen(name) + strlen(opr) + strlen(ver) + 1;
 | 
			
		||||
	len = strlen(name) + strlen(opr) + strlen(ver)
 | 
			
		||||
		+ strlen(desc_delim) + strlen(desc) + 1;
 | 
			
		||||
	MALLOC(str, len, return NULL);
 | 
			
		||||
	snprintf(str, len, "%s%s%s", name, opr, ver);
 | 
			
		||||
	snprintf(str, len, "%s%s%s%s%s", name, opr, ver, desc_delim, desc);
 | 
			
		||||
 | 
			
		||||
	return str;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  deps.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  diskspace.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2010-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -17,12 +17,15 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
#if defined(HAVE_MNTENT_H)
 | 
			
		||||
#include <mntent.h>
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(HAVE_SYS_MNTTAB_H)
 | 
			
		||||
#include <sys/mnttab.h>
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(HAVE_SYS_STATVFS_H)
 | 
			
		||||
#include <sys/statvfs.h>
 | 
			
		||||
#endif
 | 
			
		||||
@@ -55,51 +58,102 @@ static int mount_point_cmp(const void *p1, const void *p2)
 | 
			
		||||
	return -strcmp(mp1->mount_dir, mp2->mount_dir);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void mount_point_list_free(alpm_list_t *mount_points)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
 | 
			
		||||
	for(i = mount_points; i; i = i->next) {
 | 
			
		||||
		alpm_mountpoint_t *data = i->data;
 | 
			
		||||
		FREE(data->mount_dir);
 | 
			
		||||
	}
 | 
			
		||||
	FREELIST(mount_points);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int mount_point_load_fsinfo(alpm_handle_t *handle, alpm_mountpoint_t *mountpoint)
 | 
			
		||||
{
 | 
			
		||||
#if defined(HAVE_GETMNTENT)
 | 
			
		||||
	/* grab the filesystem usage */
 | 
			
		||||
	if(statvfs(mountpoint->mount_dir, &(mountpoint->fsp)) != 0) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
				_("could not get filesystem information for %s: %s\n"),
 | 
			
		||||
				mountpoint->mount_dir, strerror(errno));
 | 
			
		||||
		mountpoint->fsinfo_loaded = MOUNT_FSINFO_FAIL;
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "loading fsinfo for %s\n", mountpoint->mount_dir);
 | 
			
		||||
	mountpoint->read_only = mountpoint->fsp.f_flag & ST_RDONLY;
 | 
			
		||||
	mountpoint->fsinfo_loaded = MOUNT_FSINFO_LOADED;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_list_t *mount_point_list(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *mount_points = NULL, *ptr;
 | 
			
		||||
	alpm_mountpoint_t *mp;
 | 
			
		||||
 | 
			
		||||
#if defined HAVE_GETMNTENT
 | 
			
		||||
#if defined(HAVE_GETMNTENT) && defined(HAVE_MNTENT_H)
 | 
			
		||||
	/* Linux */
 | 
			
		||||
	struct mntent *mnt;
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
	struct statvfs fsp;
 | 
			
		||||
 | 
			
		||||
	fp = setmntent(MOUNTED, "r");
 | 
			
		||||
 | 
			
		||||
	if(fp == NULL) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not open file: %s: %s\n"),
 | 
			
		||||
				MOUNTED, strerror(errno));
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while((mnt = getmntent(fp))) {
 | 
			
		||||
		if(!mnt) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING, _("could not get filesystem information\n"));
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		if(statvfs(mnt->mnt_dir, &fsp) != 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
					_("could not get filesystem information for %s: %s\n"),
 | 
			
		||||
					mnt->mnt_dir, strerror(errno));
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
		mp->mount_dir = strdup(mnt->mnt_dir);
 | 
			
		||||
		mp->mount_dir_len = strlen(mp->mount_dir);
 | 
			
		||||
		memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs));
 | 
			
		||||
		mp->read_only = fsp.f_flag & ST_RDONLY;
 | 
			
		||||
 | 
			
		||||
		mount_points = alpm_list_add(mount_points, mp);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	endmntent(fp);
 | 
			
		||||
#elif defined HAVE_GETMNTINFO
 | 
			
		||||
#elif defined(HAVE_GETMNTENT) && defined(HAVE_MNTTAB_H)
 | 
			
		||||
	/* Solaris, Illumos */
 | 
			
		||||
	struct mnttab mnt;
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	fp = fopen("/etc/mnttab", "r");
 | 
			
		||||
 | 
			
		||||
	if(fp == NULL) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"),
 | 
			
		||||
				"/etc/mnttab", strerror(errno));
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while((ret = getmntent(fp, &mnt)) == 0) {
 | 
			
		||||
		CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
		mp->mount_dir = strdup(mnt->mnt_mountp);
 | 
			
		||||
		mp->mount_dir_len = strlen(mp->mount_dir);
 | 
			
		||||
 | 
			
		||||
		mount_points = alpm_list_add(mount_points, mp);
 | 
			
		||||
	}
 | 
			
		||||
	/* -1 == EOF */
 | 
			
		||||
	if(ret != -1) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
				_("could not get filesystem information\n"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fclose(fp);
 | 
			
		||||
#elif defined(HAVE_GETMNTINFO)
 | 
			
		||||
	/* FreeBSD (statfs), NetBSD (statvfs), OpenBSD (statfs), OS X (statfs) */
 | 
			
		||||
	int entries;
 | 
			
		||||
	FSSTATSTYPE *fsp;
 | 
			
		||||
 | 
			
		||||
	entries = getmntinfo(&fsp, MNT_NOWAIT);
 | 
			
		||||
 | 
			
		||||
	if(entries < 0) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
				_("could not get filesystem information\n"));
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -114,6 +168,9 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
 | 
			
		||||
		mp->read_only = fsp->f_flags & MNT_RDONLY;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		/* we don't support lazy loading on this platform */
 | 
			
		||||
		mp->fsinfo_loaded = MOUNT_FSINFO_LOADED;
 | 
			
		||||
 | 
			
		||||
		mount_points = alpm_list_add(mount_points, mp);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
@@ -122,7 +179,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
 | 
			
		||||
			mount_point_cmp);
 | 
			
		||||
	for(ptr = mount_points; ptr != NULL; ptr = ptr->next) {
 | 
			
		||||
		mp = ptr->data;
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir);
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "discovered mountpoint: %s\n", mp->mount_dir);
 | 
			
		||||
	}
 | 
			
		||||
	return mount_points;
 | 
			
		||||
}
 | 
			
		||||
@@ -135,8 +192,20 @@ static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points,
 | 
			
		||||
	for(mp = mount_points; mp != NULL; mp = mp->next) {
 | 
			
		||||
		alpm_mountpoint_t *data = mp->data;
 | 
			
		||||
 | 
			
		||||
		/* first, check if the prefix matches */
 | 
			
		||||
		if(strncmp(data->mount_dir, real_path, data->mount_dir_len) == 0) {
 | 
			
		||||
			return data;
 | 
			
		||||
			/* now, the hard work- a file like '/etc/myconfig' shouldn't map to a
 | 
			
		||||
			 * mountpoint '/e', but only '/etc'. If the mountpoint ends in a trailing
 | 
			
		||||
			 * slash, we know we didn't have a mismatch, otherwise we have to do some
 | 
			
		||||
			 * more sanity checks. */
 | 
			
		||||
			if(data->mount_dir[data->mount_dir_len - 1] == '/') {
 | 
			
		||||
				return data;
 | 
			
		||||
			} else if(strlen(real_path) >= data->mount_dir_len) {
 | 
			
		||||
				const char next = real_path[data->mount_dir_len];
 | 
			
		||||
				if(next == '/' || next == '\0') {
 | 
			
		||||
					return data;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -159,6 +228,7 @@ static int calculate_removed_size(alpm_handle_t *handle,
 | 
			
		||||
		alpm_mountpoint_t *mp;
 | 
			
		||||
		struct stat st;
 | 
			
		||||
		char path[PATH_MAX];
 | 
			
		||||
		blkcnt_t remove_size;
 | 
			
		||||
		const char *filename = file->name;
 | 
			
		||||
 | 
			
		||||
		snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
 | 
			
		||||
@@ -177,9 +247,21 @@ static int calculate_removed_size(alpm_handle_t *handle,
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* don't check a mount that we know we can't stat */
 | 
			
		||||
		if(mp && mp->fsinfo_loaded == MOUNT_FSINFO_FAIL) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* lazy load filesystem info */
 | 
			
		||||
		if(mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
 | 
			
		||||
			if(mount_point_load_fsinfo(handle, mp) < 0) {
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* the addition of (divisor - 1) performs ceil() with integer division */
 | 
			
		||||
		mp->blocks_needed -=
 | 
			
		||||
			(st.st_size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
 | 
			
		||||
		remove_size = (st.st_size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
 | 
			
		||||
		mp->blocks_needed -= remove_size;
 | 
			
		||||
		mp->used |= USED_REMOVE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -200,6 +282,7 @@ static int calculate_installed_size(alpm_handle_t *handle,
 | 
			
		||||
		const alpm_file_t *file = filelist->files + i;
 | 
			
		||||
		alpm_mountpoint_t *mp;
 | 
			
		||||
		char path[PATH_MAX];
 | 
			
		||||
		blkcnt_t install_size;
 | 
			
		||||
		const char *filename = file->name;
 | 
			
		||||
 | 
			
		||||
		/* libarchive reports these as zero size anyways */
 | 
			
		||||
@@ -223,15 +306,108 @@ static int calculate_installed_size(alpm_handle_t *handle,
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* don't check a mount that we know we can't stat */
 | 
			
		||||
		if(mp && mp->fsinfo_loaded == MOUNT_FSINFO_FAIL) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* lazy load filesystem info */
 | 
			
		||||
		if(mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
 | 
			
		||||
			if(mount_point_load_fsinfo(handle, mp) < 0) {
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* the addition of (divisor - 1) performs ceil() with integer division */
 | 
			
		||||
		mp->blocks_needed +=
 | 
			
		||||
			(file->size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
 | 
			
		||||
		install_size = (file->size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
 | 
			
		||||
		mp->blocks_needed += install_size;
 | 
			
		||||
		mp->used |= USED_INSTALL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp)
 | 
			
		||||
{
 | 
			
		||||
	/* cushion is roughly min(5% capacity, 20MiB) */
 | 
			
		||||
	fsblkcnt_t fivepc = (mp->fsp.f_blocks / 20) + 1;
 | 
			
		||||
	fsblkcnt_t twentymb = (20 * 1024 * 1024 / mp->fsp.f_bsize) + 1;
 | 
			
		||||
	fsblkcnt_t cushion = fivepc < twentymb ? fivepc : twentymb;
 | 
			
		||||
	blkcnt_t needed = mp->max_blocks_needed + cushion;
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
			"partition %s, needed %jd, cushion %ju, free %ju\n",
 | 
			
		||||
			mp->mount_dir, (intmax_t)mp->max_blocks_needed,
 | 
			
		||||
			(uintmax_t)cushion, (uintmax_t)mp->fsp.f_bfree);
 | 
			
		||||
	if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bfree) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
				_("Partition %s too full: %jd blocks needed, %jd blocks free\n"),
 | 
			
		||||
				mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bfree);
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
 | 
			
		||||
		size_t num_files, off_t *file_sizes)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *mount_points;
 | 
			
		||||
	alpm_mountpoint_t *cachedir_mp;
 | 
			
		||||
	char resolved_cachedir[PATH_MAX];
 | 
			
		||||
	size_t j;
 | 
			
		||||
	int error = 0;
 | 
			
		||||
 | 
			
		||||
	/* resolve the cachedir path to ensure we check the right mountpoint.  We
 | 
			
		||||
	 * handle failures silently, and continue to use the possibly unresolved
 | 
			
		||||
	 * path. */
 | 
			
		||||
	if(realpath(cachedir, resolved_cachedir) != NULL) {
 | 
			
		||||
		cachedir = resolved_cachedir;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mount_points = mount_point_list(handle);
 | 
			
		||||
	if(mount_points == NULL) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not determine filesystem mount points\n"));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cachedir_mp = match_mount_point(mount_points, cachedir);
 | 
			
		||||
	if(cachedir_mp == NULL) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not determine cachedir mount point %s\n"),
 | 
			
		||||
				cachedir);
 | 
			
		||||
		error = 1;
 | 
			
		||||
		goto finish;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(cachedir_mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
 | 
			
		||||
		if(mount_point_load_fsinfo(handle, cachedir_mp)) {
 | 
			
		||||
			error = 1;
 | 
			
		||||
			goto finish;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* there's no need to check for a R/O mounted filesystem here, as
 | 
			
		||||
	 * _alpm_filecache_setup will never give us a non-writable directory */
 | 
			
		||||
 | 
			
		||||
	/* round up the size of each file to the nearest block and accumulate */
 | 
			
		||||
	for(j = 0; j < num_files; j++) {
 | 
			
		||||
		cachedir_mp->max_blocks_needed += (file_sizes[j] + cachedir_mp->fsp.f_bsize + 1) /
 | 
			
		||||
			cachedir_mp->fsp.f_bsize;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(check_mountpoint(handle, cachedir_mp)) {
 | 
			
		||||
		error = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
finish:
 | 
			
		||||
	mount_point_list_free(mount_points);
 | 
			
		||||
 | 
			
		||||
	if(error) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int _alpm_check_diskspace(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *mount_points, *i;
 | 
			
		||||
@@ -300,32 +476,13 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_ERROR, _("Partition %s is mounted read only\n"),
 | 
			
		||||
					data->mount_dir);
 | 
			
		||||
			error = 1;
 | 
			
		||||
		} else if(data->used & USED_INSTALL) {
 | 
			
		||||
			/* cushion is roughly min(5% capacity, 20MiB) */
 | 
			
		||||
			fsblkcnt_t fivepc = (data->fsp.f_blocks / 20) + 1;
 | 
			
		||||
			fsblkcnt_t twentymb = (20 * 1024 * 1024 / data->fsp.f_bsize) + 1;
 | 
			
		||||
			fsblkcnt_t cushion = fivepc < twentymb ? fivepc : twentymb;
 | 
			
		||||
			blkcnt_t needed = data->max_blocks_needed + cushion;
 | 
			
		||||
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"partition %s, needed %jd, cushion %ju, free %ju\n",
 | 
			
		||||
					data->mount_dir, (intmax_t)data->max_blocks_needed,
 | 
			
		||||
					(uintmax_t)cushion, (uintmax_t)data->fsp.f_bfree);
 | 
			
		||||
			if(needed >= 0 && (fsblkcnt_t)needed > data->fsp.f_bfree) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
						_("Partition %s too full: %jd blocks needed, %jd blocks free\n"),
 | 
			
		||||
						data->mount_dir, (intmax_t)needed, (uintmax_t)data->fsp.f_bfree);
 | 
			
		||||
				error = 1;
 | 
			
		||||
			}
 | 
			
		||||
		} else if(data->used & USED_INSTALL && check_mountpoint(handle, data)) {
 | 
			
		||||
			error = 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
finish:
 | 
			
		||||
	for(i = mount_points; i; i = i->next) {
 | 
			
		||||
		alpm_mountpoint_t *data = i->data;
 | 
			
		||||
		FREE(data->mount_dir);
 | 
			
		||||
	}
 | 
			
		||||
	FREELIST(mount_points);
 | 
			
		||||
	mount_point_list_free(mount_points);
 | 
			
		||||
 | 
			
		||||
	if(error) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  diskspace.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2010-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -37,6 +37,12 @@ enum mount_used_level {
 | 
			
		||||
	USED_INSTALL = (1 << 1),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum mount_fsinfo {
 | 
			
		||||
	MOUNT_FSINFO_UNLOADED = 0,
 | 
			
		||||
	MOUNT_FSINFO_LOADED,
 | 
			
		||||
	MOUNT_FSINFO_FAIL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct __alpm_mountpoint_t {
 | 
			
		||||
	/* mount point information */
 | 
			
		||||
	char *mount_dir;
 | 
			
		||||
@@ -46,10 +52,13 @@ typedef struct __alpm_mountpoint_t {
 | 
			
		||||
	blkcnt_t max_blocks_needed;
 | 
			
		||||
	enum mount_used_level used;
 | 
			
		||||
	int read_only;
 | 
			
		||||
	enum mount_fsinfo fsinfo_loaded;
 | 
			
		||||
	FSSTATSTYPE fsp;
 | 
			
		||||
} alpm_mountpoint_t;
 | 
			
		||||
 | 
			
		||||
int _alpm_check_diskspace(alpm_handle_t *handle);
 | 
			
		||||
int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
 | 
			
		||||
		size_t num_files, off_t *file_sizes);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_DISKSPACE_H */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  download.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,18 +18,24 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <sys/socket.h> /* setsockopt, SO_KEEPALIVE */
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_NETINET_IN_H
 | 
			
		||||
#include <netinet/in.h> /* IPPROTO_TCP */
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef HAVE_NETINET_TCP_H
 | 
			
		||||
#include <netinet/tcp.h> /* TCP_KEEPINTVL, TCP_KEEPIDLE */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_LIBCURL
 | 
			
		||||
#include <curl/curl.h>
 | 
			
		||||
#endif
 | 
			
		||||
@@ -84,12 +90,17 @@ static void inthandler(int UNUSED signum)
 | 
			
		||||
	dload_interrupted = ABORT_SIGINT;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int curl_progress(void *file, double dltotal, double dlnow,
 | 
			
		||||
static int dload_progress_cb(void *file, double dltotal, double dlnow,
 | 
			
		||||
		double UNUSED ultotal, double UNUSED ulnow)
 | 
			
		||||
{
 | 
			
		||||
	struct dload_payload *payload = (struct dload_payload *)file;
 | 
			
		||||
	off_t current_size, total_size;
 | 
			
		||||
 | 
			
		||||
	/* avoid displaying progress bar for redirects with a body */
 | 
			
		||||
	if(payload->respcode >= 300) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* SIGINT sent, abort by alerting curl */
 | 
			
		||||
	if(dload_interrupted) {
 | 
			
		||||
		return 1;
 | 
			
		||||
@@ -186,13 +197,14 @@ static mode_t _getumask(void)
 | 
			
		||||
	return mask;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t parse_headers(void *ptr, size_t size, size_t nmemb, void *user)
 | 
			
		||||
static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *user)
 | 
			
		||||
{
 | 
			
		||||
	size_t realsize = size * nmemb;
 | 
			
		||||
	const char *fptr, *endptr = NULL;
 | 
			
		||||
	const char * const cd_header = "Content-Disposition:";
 | 
			
		||||
	const char * const fn_key = "filename=";
 | 
			
		||||
	struct dload_payload *payload = (struct dload_payload *)user;
 | 
			
		||||
	long respcode;
 | 
			
		||||
 | 
			
		||||
	if(_alpm_raw_ncmp(cd_header, ptr, strlen(cd_header)) == 0) {
 | 
			
		||||
		if((fptr = strstr(ptr, fn_key))) {
 | 
			
		||||
@@ -214,9 +226,55 @@ static size_t parse_headers(void *ptr, size_t size, size_t nmemb, void *user)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	curl_easy_getinfo(payload->handle->curl, CURLINFO_RESPONSE_CODE, &respcode);
 | 
			
		||||
	if(payload->respcode != respcode) {
 | 
			
		||||
		payload->respcode = respcode;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return realsize;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dload_sockopt_cb(void *userdata, curl_socket_t curlfd,
 | 
			
		||||
		curlsocktype purpose)
 | 
			
		||||
{
 | 
			
		||||
	alpm_handle_t *handle = userdata;
 | 
			
		||||
	int optval = 1;
 | 
			
		||||
 | 
			
		||||
	/* this whole method is to prevent FTP control connections from going sour
 | 
			
		||||
	 * during a long data transfer; crappy firewalls love to drop otherwise idle
 | 
			
		||||
	 * connections if there is no traffic. */
 | 
			
		||||
	if(purpose != CURLSOCKTYPE_IPCXN) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* don't abort operation if any setsockopt fails, just log to debug */
 | 
			
		||||
	if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval,
 | 
			
		||||
				sizeof(optval)) < 0) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
				"Failed to set SO_KEEPALIVE on fd %d\n", curlfd);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
#ifdef TCP_KEEPIDLE
 | 
			
		||||
		optval = 60;
 | 
			
		||||
		if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval,
 | 
			
		||||
					sizeof(optval)) < 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"Failed to set TCP_KEEPIDLE on fd %d\n", curlfd);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef TCP_KEEPINTVL
 | 
			
		||||
		optval = 60;
 | 
			
		||||
		if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&optval,
 | 
			
		||||
					sizeof(optval)) < 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"Failed to set TCP_KEEPINTVL on fd %d\n", curlfd);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void curl_set_handle_opts(struct dload_payload *payload,
 | 
			
		||||
		CURL *curl, char *error_buffer)
 | 
			
		||||
{
 | 
			
		||||
@@ -234,13 +292,15 @@ static void curl_set_handle_opts(struct dload_payload *payload,
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, parse_headers);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, dload_sockopt_cb);
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, (void *)handle);
 | 
			
		||||
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);
 | 
			
		||||
 | 
			
		||||
@@ -273,7 +333,7 @@ static void curl_set_handle_opts(struct dload_payload *payload,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void mask_signal(int signal, void (*handler)(int),
 | 
			
		||||
static void mask_signal(int signum, void (*handler)(int),
 | 
			
		||||
		struct sigaction *origaction)
 | 
			
		||||
{
 | 
			
		||||
	struct sigaction newaction;
 | 
			
		||||
@@ -282,13 +342,13 @@ static void mask_signal(int signal, void (*handler)(int),
 | 
			
		||||
	sigemptyset(&newaction.sa_mask);
 | 
			
		||||
	newaction.sa_flags = 0;
 | 
			
		||||
 | 
			
		||||
	sigaction(signal, NULL, origaction);
 | 
			
		||||
	sigaction(signal, &newaction, NULL);
 | 
			
		||||
	sigaction(signum, NULL, origaction);
 | 
			
		||||
	sigaction(signum, &newaction, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void unmask_signal(int signal, struct sigaction sa)
 | 
			
		||||
static void unmask_signal(int signum, struct sigaction *sa)
 | 
			
		||||
{
 | 
			
		||||
	sigaction(signal, &sa, NULL);
 | 
			
		||||
	sigaction(signum, sa, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static FILE *create_tempfile(struct dload_payload *payload, const char *localpath)
 | 
			
		||||
@@ -306,11 +366,10 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
 | 
			
		||||
			fchmod(fd, ~(_getumask()) & 0666) ||
 | 
			
		||||
			!(fp = fdopen(fd, payload->tempfile_openmode))) {
 | 
			
		||||
		unlink(randpath);
 | 
			
		||||
		if(fd >= 0) {
 | 
			
		||||
			close(fd);
 | 
			
		||||
		}
 | 
			
		||||
		CLOSE(fd);
 | 
			
		||||
		_alpm_log(payload->handle, ALPM_LOG_ERROR,
 | 
			
		||||
				_("failed to create temporary file for download\n"));
 | 
			
		||||
		free(randpath);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	/* fp now points to our alpmtmp.XXXXXX */
 | 
			
		||||
@@ -327,7 +386,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
 | 
			
		||||
#define HOSTNAME_SIZE 256
 | 
			
		||||
 | 
			
		||||
static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
		const char *localpath, char **final_file)
 | 
			
		||||
		const char *localpath, char **final_file, char **final_url)
 | 
			
		||||
{
 | 
			
		||||
	int ret = -1;
 | 
			
		||||
	FILE *localf = NULL;
 | 
			
		||||
@@ -335,7 +394,7 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
	char hostname[HOSTNAME_SIZE];
 | 
			
		||||
	char error_buffer[CURL_ERROR_SIZE] = {0};
 | 
			
		||||
	struct stat st;
 | 
			
		||||
	long timecond, respcode = 0, remote_time = -1;
 | 
			
		||||
	long timecond, remote_time = -1;
 | 
			
		||||
	double remote_size, bytes_dl;
 | 
			
		||||
	struct sigaction orig_sig_pipe, orig_sig_int;
 | 
			
		||||
	/* shortcut to our handle within the payload */
 | 
			
		||||
@@ -343,6 +402,11 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
	CURL *curl = get_libcurl_handle(handle);
 | 
			
		||||
	handle->pm_errno = 0;
 | 
			
		||||
 | 
			
		||||
	/* make sure these are NULL */
 | 
			
		||||
	FREE(payload->tempfile_name);
 | 
			
		||||
	FREE(payload->destfile_name);
 | 
			
		||||
	FREE(payload->content_disp_name);
 | 
			
		||||
 | 
			
		||||
	payload->tempfile_openmode = "wb";
 | 
			
		||||
	if(!payload->remote_name) {
 | 
			
		||||
		STRDUP(payload->remote_name, get_filename(payload->fileurl),
 | 
			
		||||
@@ -353,7 +417,8 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_SERVER_BAD_URL, -1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(strlen(payload->remote_name) > 0 && strcmp(payload->remote_name, ".sig") != 0) {
 | 
			
		||||
	if(payload->remote_name && strlen(payload->remote_name) > 0 &&
 | 
			
		||||
			strcmp(payload->remote_name, ".sig") != 0) {
 | 
			
		||||
		payload->destfile_name = get_fullpath(localpath, payload->remote_name, "");
 | 
			
		||||
		payload->tempfile_name = get_fullpath(localpath, payload->remote_name, ".part");
 | 
			
		||||
		if(!payload->destfile_name || !payload->tempfile_name) {
 | 
			
		||||
@@ -375,6 +440,10 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
	if(localf == NULL) {
 | 
			
		||||
		localf = fopen(payload->tempfile_name, payload->tempfile_openmode);
 | 
			
		||||
		if(localf == NULL) {
 | 
			
		||||
			handle->pm_errno = ALPM_ERR_RETRIEVE;
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
					_("could not open file %s: %s\n"),
 | 
			
		||||
					payload->tempfile_name, strerror(errno));
 | 
			
		||||
			goto cleanup;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -385,13 +454,15 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
 | 
			
		||||
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, localf);
 | 
			
		||||
 | 
			
		||||
	/* ignore any SIGPIPE signals- these may occur if our FTP socket dies or
 | 
			
		||||
	 * something along those lines. Store the old signal handler first. */
 | 
			
		||||
	/* Ignore any SIGPIPE signals. With libcurl, these shouldn't be happening,
 | 
			
		||||
	 * but better safe than sorry. Store the old signal handler first. */
 | 
			
		||||
	mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe);
 | 
			
		||||
	mask_signal(SIGINT, &inthandler, &orig_sig_int);
 | 
			
		||||
 | 
			
		||||
	/* perform transfer */
 | 
			
		||||
	payload->curlerr = curl_easy_perform(curl);
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "curl returned error %d from transfer\n",
 | 
			
		||||
			payload->curlerr);
 | 
			
		||||
 | 
			
		||||
	/* disconnect relationships from the curl handle for things that might go out
 | 
			
		||||
	 * of scope, but could still be touched on connection teardown.  This really
 | 
			
		||||
@@ -403,13 +474,12 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
	switch(payload->curlerr) {
 | 
			
		||||
		case CURLE_OK:
 | 
			
		||||
			/* get http/ftp response code */
 | 
			
		||||
			curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respcode);
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "response code: %ld\n", respcode);
 | 
			
		||||
			if(respcode >= 400) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG, "response code: %ld\n", payload->respcode);
 | 
			
		||||
			if(payload->respcode >= 400) {
 | 
			
		||||
				payload->unlink_on_fail = 1;
 | 
			
		||||
				/* non-translated message is same as libcurl */
 | 
			
		||||
				snprintf(error_buffer, sizeof(error_buffer),
 | 
			
		||||
						"The requested URL returned error: %ld", respcode);
 | 
			
		||||
						"The requested URL returned error: %ld", payload->respcode);
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_ERROR,
 | 
			
		||||
						_("failed retrieving file '%s' from %s : %s\n"),
 | 
			
		||||
						payload->remote_name, hostname, error_buffer);
 | 
			
		||||
@@ -453,6 +523,10 @@ static int curl_download_internal(struct dload_payload *payload,
 | 
			
		||||
	curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &timecond);
 | 
			
		||||
	curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
 | 
			
		||||
 | 
			
		||||
	if(final_url != NULL) {
 | 
			
		||||
		*final_url = effective_url;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* time condition was met and we didn't download anything. we need to
 | 
			
		||||
	 * clean up the 0 byte .part file that's left behind. */
 | 
			
		||||
	if(timecond == 1 && DOUBLE_EQ(bytes_dl, 0)) {
 | 
			
		||||
@@ -524,8 +598,8 @@ cleanup:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* restore the old signal handlers */
 | 
			
		||||
	unmask_signal(SIGINT, orig_sig_int);
 | 
			
		||||
	unmask_signal(SIGPIPE, orig_sig_pipe);
 | 
			
		||||
	unmask_signal(SIGINT, &orig_sig_int);
 | 
			
		||||
	unmask_signal(SIGPIPE, &orig_sig_pipe);
 | 
			
		||||
	/* if we were interrupted, trip the old handler */
 | 
			
		||||
	if(dload_interrupted) {
 | 
			
		||||
		raise(SIGINT);
 | 
			
		||||
@@ -543,13 +617,13 @@ cleanup:
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly if errors_ok == 0)
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_download(struct dload_payload *payload, const char *localpath,
 | 
			
		||||
		char **final_file)
 | 
			
		||||
		char **final_file, char **final_url)
 | 
			
		||||
{
 | 
			
		||||
	alpm_handle_t *handle = payload->handle;
 | 
			
		||||
 | 
			
		||||
	if(handle->fetchcb == NULL) {
 | 
			
		||||
#ifdef HAVE_LIBCURL
 | 
			
		||||
		return curl_download_internal(payload, localpath, final_file);
 | 
			
		||||
		return curl_download_internal(payload, localpath, final_file, final_url);
 | 
			
		||||
#else
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -562,14 +636,30 @@ int _alpm_download(struct dload_payload *payload, const char *localpath,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char *filecache_find_url(alpm_handle_t *handle, const char *url)
 | 
			
		||||
{
 | 
			
		||||
	const char *filebase = strrchr(url, '/');
 | 
			
		||||
 | 
			
		||||
	if(filebase == NULL) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	filebase++;
 | 
			
		||||
	if(filebase == '\0') {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return _alpm_filecache_find(handle, filebase);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Fetch a remote pkg. */
 | 
			
		||||
char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
 | 
			
		||||
{
 | 
			
		||||
	char *filepath;
 | 
			
		||||
	const char *cachedir;
 | 
			
		||||
	char *final_file = NULL;
 | 
			
		||||
	char *final_file = NULL, *final_pkg_url = NULL;
 | 
			
		||||
	struct dload_payload payload;
 | 
			
		||||
	int ret;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	CHECK_HANDLE(handle, return NULL);
 | 
			
		||||
	ASSERT(url, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL));
 | 
			
		||||
@@ -578,48 +668,63 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
 | 
			
		||||
	cachedir = _alpm_filecache_setup(handle);
 | 
			
		||||
 | 
			
		||||
	memset(&payload, 0, sizeof(struct dload_payload));
 | 
			
		||||
	payload.handle = handle;
 | 
			
		||||
	STRDUP(payload.fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
	payload.allow_resume = 1;
 | 
			
		||||
 | 
			
		||||
	/* download the file */
 | 
			
		||||
	ret = _alpm_download(&payload, cachedir, &final_file);
 | 
			
		||||
	_alpm_dload_payload_reset(&payload);
 | 
			
		||||
	if(ret == -1) {
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url);
 | 
			
		||||
		free(final_file);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	/* attempt to find the file in our pkgcache */
 | 
			
		||||
	filepath = filecache_find_url(handle, url);
 | 
			
		||||
	if(filepath == NULL) {
 | 
			
		||||
		STRDUP(payload.fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
		payload.allow_resume = 1;
 | 
			
		||||
		payload.handle = handle;
 | 
			
		||||
 | 
			
		||||
		/* download the file */
 | 
			
		||||
		ret = _alpm_download(&payload, cachedir, &final_file, &final_pkg_url);
 | 
			
		||||
		_alpm_dload_payload_reset(&payload);
 | 
			
		||||
		if(ret == -1) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url);
 | 
			
		||||
			free(final_file);
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		_alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", url);
 | 
			
		||||
	}
 | 
			
		||||
	_alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", url);
 | 
			
		||||
 | 
			
		||||
	/* attempt to download the signature */
 | 
			
		||||
	if(ret == 0 && (handle->siglevel & ALPM_SIG_PACKAGE)) {
 | 
			
		||||
		char *sig_final_file = NULL;
 | 
			
		||||
	if(ret == 0 && final_pkg_url && (handle->siglevel & ALPM_SIG_PACKAGE)) {
 | 
			
		||||
		char *sig_filepath, *sig_final_file = NULL;
 | 
			
		||||
		size_t len;
 | 
			
		||||
 | 
			
		||||
		len = strlen(url) + 5;
 | 
			
		||||
		len = strlen(final_pkg_url) + 5;
 | 
			
		||||
		MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
		snprintf(payload.fileurl, len, "%s.sig", url);
 | 
			
		||||
		payload.handle = handle;
 | 
			
		||||
		payload.force = 1;
 | 
			
		||||
		payload.errors_ok = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL);
 | 
			
		||||
		snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
 | 
			
		||||
 | 
			
		||||
		ret = _alpm_download(&payload, cachedir, &sig_final_file);
 | 
			
		||||
		if(ret == -1 && !payload.errors_ok) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
					_("failed to download %s\n"), payload.fileurl);
 | 
			
		||||
			/* Warn now, but don't return NULL. We will fail later during package
 | 
			
		||||
			 * load time. */
 | 
			
		||||
		} else if(ret == 0) {
 | 
			
		||||
			_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
					"successfully downloaded %s\n", payload.fileurl);
 | 
			
		||||
		sig_filepath = filecache_find_url(handle, payload.fileurl);
 | 
			
		||||
		if(sig_filepath == NULL) {
 | 
			
		||||
			payload.handle = handle;
 | 
			
		||||
			payload.force = 1;
 | 
			
		||||
			payload.errors_ok = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL);
 | 
			
		||||
 | 
			
		||||
			/* set hard upper limit of 16KiB */
 | 
			
		||||
			payload.max_size = 16 * 1024;
 | 
			
		||||
 | 
			
		||||
			ret = _alpm_download(&payload, cachedir, &sig_final_file, NULL);
 | 
			
		||||
			if(ret == -1 && !payload.errors_ok) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_WARNING,
 | 
			
		||||
						_("failed to download %s\n"), payload.fileurl);
 | 
			
		||||
				/* Warn now, but don't return NULL. We will fail later during package
 | 
			
		||||
				 * load time. */
 | 
			
		||||
			} else if(ret == 0) {
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG,
 | 
			
		||||
						"successfully downloaded %s\n", payload.fileurl);
 | 
			
		||||
			}
 | 
			
		||||
			FREE(sig_final_file);
 | 
			
		||||
		}
 | 
			
		||||
		FREE(sig_final_file);
 | 
			
		||||
		free(sig_filepath);
 | 
			
		||||
		_alpm_dload_payload_reset(&payload);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* we should be able to find the file the second time around */
 | 
			
		||||
	filepath = _alpm_filecache_find(handle, final_file);
 | 
			
		||||
	if(filepath == NULL) {
 | 
			
		||||
		filepath = _alpm_filecache_find(handle, final_file);
 | 
			
		||||
	}
 | 
			
		||||
	free(final_file);
 | 
			
		||||
 | 
			
		||||
	return filepath;
 | 
			
		||||
@@ -634,6 +739,7 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
 | 
			
		||||
	FREE(payload->destfile_name);
 | 
			
		||||
	FREE(payload->content_disp_name);
 | 
			
		||||
	FREE(payload->fileurl);
 | 
			
		||||
	memset(payload, '\0', sizeof(*payload));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  dload.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -23,8 +23,6 @@
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
struct dload_payload {
 | 
			
		||||
	alpm_handle_t *handle;
 | 
			
		||||
	const char *tempfile_openmode;
 | 
			
		||||
@@ -40,15 +38,17 @@ struct dload_payload {
 | 
			
		||||
	int allow_resume;
 | 
			
		||||
	int errors_ok;
 | 
			
		||||
	int unlink_on_fail;
 | 
			
		||||
	alpm_list_t *servers;
 | 
			
		||||
#ifdef HAVE_LIBCURL
 | 
			
		||||
	CURLcode curlerr;       /* last error produced by curl */
 | 
			
		||||
#endif
 | 
			
		||||
	long respcode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void _alpm_dload_payload_reset(struct dload_payload *payload);
 | 
			
		||||
 | 
			
		||||
int _alpm_download(struct dload_payload *payload, const char *localpath,
 | 
			
		||||
		char **final_file);
 | 
			
		||||
		char **final_file, char **final_url);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_DLOAD_H */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  error.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,8 +18,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_LIBCURL
 | 
			
		||||
#include <curl/curl.h>
 | 
			
		||||
#endif
 | 
			
		||||
@@ -29,12 +27,12 @@
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "handle.h"
 | 
			
		||||
 | 
			
		||||
enum _alpm_errno_t SYMEXPORT alpm_errno(alpm_handle_t *handle)
 | 
			
		||||
alpm_errno_t SYMEXPORT alpm_errno(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	return handle->pm_errno;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char SYMEXPORT *alpm_strerror(enum _alpm_errno_t err)
 | 
			
		||||
const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
 | 
			
		||||
{
 | 
			
		||||
	switch(err) {
 | 
			
		||||
		/* System */
 | 
			
		||||
@@ -43,7 +41,7 @@ const char SYMEXPORT *alpm_strerror(enum _alpm_errno_t err)
 | 
			
		||||
		case ALPM_ERR_SYSTEM:
 | 
			
		||||
			return _("unexpected system error");
 | 
			
		||||
		case ALPM_ERR_BADPERMS:
 | 
			
		||||
			return _("insufficient privileges");
 | 
			
		||||
			return _("permission denied");
 | 
			
		||||
		case ALPM_ERR_NOT_A_FILE:
 | 
			
		||||
			return _("could not find or read file");
 | 
			
		||||
		case ALPM_ERR_NOT_A_DIR:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										351
									
								
								lib/libalpm/filelist.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										351
									
								
								lib/libalpm/filelist.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,351 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  filelist.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2012-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
 | 
			
		||||
/* libalpm */
 | 
			
		||||
#include "filelist.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
 | 
			
		||||
/** Helper function for comparing strings when sorting */
 | 
			
		||||
static int _alpm_filelist_strcmp(const void *s1, const void *s2)
 | 
			
		||||
{
 | 
			
		||||
	return strcmp(*(char **)s1, *(char **)s2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* TODO make sure callers check the return value so we can bail on errors.
 | 
			
		||||
 * For now we soldier on as best we can, skipping paths that are too long to
 | 
			
		||||
 * resolve and using the original filenames on memory errors.  */
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Resolves a symlink and its children.
 | 
			
		||||
 *
 | 
			
		||||
 * @attention Pre-condition: files must be sorted!
 | 
			
		||||
 *
 | 
			
		||||
 * @param files filelist to resolve
 | 
			
		||||
 * @param i pointer to the index in files to start processing, will point to
 | 
			
		||||
 * the last file processed on return
 | 
			
		||||
 * @param path absolute path for the symlink being resolved
 | 
			
		||||
 * @param root_len length of the root portion of path
 | 
			
		||||
 * @param resolving is file \i in \files a symlink that needs to be resolved
 | 
			
		||||
 *
 | 
			
		||||
 * @return 0 on success, -1 on error
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_filelist_resolve_link(alpm_filelist_t *files, size_t *i,
 | 
			
		||||
		char *path, size_t root_len, int resolving)
 | 
			
		||||
{
 | 
			
		||||
	char *causal_dir = NULL; /* symlink being resolved */
 | 
			
		||||
	char *filename_r = NULL; /* resolved filename */
 | 
			
		||||
	size_t causal_dir_len = 0, causal_dir_r_len = 0;
 | 
			
		||||
 | 
			
		||||
	if(resolving) {
 | 
			
		||||
		/* deal with the symlink being resolved */
 | 
			
		||||
		MALLOC(filename_r, PATH_MAX, goto error);
 | 
			
		||||
		causal_dir = files->files[*i].name;
 | 
			
		||||
		causal_dir_len = strlen(causal_dir);
 | 
			
		||||
		if(realpath(path, filename_r) == NULL) {
 | 
			
		||||
			files->resolved_path[*i] = causal_dir;
 | 
			
		||||
			FREE(filename_r);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		causal_dir_r_len = strlen(filename_r + root_len) + 1;
 | 
			
		||||
		if(causal_dir_r_len >= PATH_MAX) {
 | 
			
		||||
			files->resolved_path[*i] = causal_dir;
 | 
			
		||||
			FREE(filename_r);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		/* remove root_r from filename_r */
 | 
			
		||||
		memmove(filename_r, filename_r + root_len, causal_dir_r_len);
 | 
			
		||||
		filename_r[causal_dir_r_len - 1] = '/';
 | 
			
		||||
		filename_r[causal_dir_r_len] = '\0';
 | 
			
		||||
		STRDUP(files->resolved_path[*i], filename_r, goto error);
 | 
			
		||||
		(*i)++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for(; *i < files->count; (*i)++) {
 | 
			
		||||
		char *filename = files->files[*i].name;
 | 
			
		||||
		size_t filename_len = strlen(filename);
 | 
			
		||||
		size_t filename_r_len = filename_len;
 | 
			
		||||
		struct stat sbuf;
 | 
			
		||||
		int exists;
 | 
			
		||||
 | 
			
		||||
		if(resolving) {
 | 
			
		||||
			if(filename_len < causal_dir_len || strncmp(filename, causal_dir, causal_dir_len) != 0) {
 | 
			
		||||
				/* not inside causal_dir anymore */
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			filename_r_len = filename_len + causal_dir_r_len - causal_dir_len;
 | 
			
		||||
			if(filename_r_len >= PATH_MAX) {
 | 
			
		||||
				/* resolved path is too long */
 | 
			
		||||
				files->resolved_path[*i] = filename;
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			strcpy(filename_r + causal_dir_r_len, filename + causal_dir_len);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* deal with files and paths too long to resolve*/
 | 
			
		||||
		if(filename[filename_len - 1] != '/' || root_len + filename_r_len >= PATH_MAX) {
 | 
			
		||||
			if(resolving) {
 | 
			
		||||
				STRDUP(files->resolved_path[*i], filename_r, goto error);
 | 
			
		||||
			} else {
 | 
			
		||||
				files->resolved_path[*i] = filename;
 | 
			
		||||
			}
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* construct absolute path and stat() */
 | 
			
		||||
		strcpy(path + root_len, resolving ? filename_r : filename);
 | 
			
		||||
		exists = !_alpm_lstat(path, &sbuf);
 | 
			
		||||
 | 
			
		||||
		/* deal with symlinks */
 | 
			
		||||
		if(exists && S_ISLNK(sbuf.st_mode)) {
 | 
			
		||||
			_alpm_filelist_resolve_link(files, i, path, root_len, 1);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* deal with normal directories */
 | 
			
		||||
		if(resolving) {
 | 
			
		||||
			STRDUP(files->resolved_path[*i], filename_r, goto error);
 | 
			
		||||
		} else {
 | 
			
		||||
			files->resolved_path[*i] = filename;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* deal with children of non-existent directories to reduce lstat() calls */
 | 
			
		||||
		if(!exists) {
 | 
			
		||||
			for((*i)++; *i < files->count; (*i)++) {
 | 
			
		||||
				char *f = files->files[*i].name;
 | 
			
		||||
				size_t f_len = strlen(f);
 | 
			
		||||
				size_t f_r_len;
 | 
			
		||||
 | 
			
		||||
				if(f_len < filename_len || strncmp(f, filename, filename_len) != 0) {
 | 
			
		||||
					/* not inside the non-existent dir anymore */
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				f_r_len = f_len + causal_dir_r_len - causal_dir_len;
 | 
			
		||||
				if(resolving && f_r_len <= PATH_MAX) {
 | 
			
		||||
					strcpy(filename_r + causal_dir_r_len, f + causal_dir_len);
 | 
			
		||||
					STRDUP(files->resolved_path[*i], filename_r, goto error);
 | 
			
		||||
				} else {
 | 
			
		||||
					files->resolved_path[*i] = f;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			(*i)--;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	(*i)--;
 | 
			
		||||
 | 
			
		||||
	FREE(filename_r);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
error:
 | 
			
		||||
	FREE(filename_r);
 | 
			
		||||
	/* out of memory, set remaining files to their original names */
 | 
			
		||||
	for(; *i < files->count; (*i)++) {
 | 
			
		||||
		files->resolved_path[*i] = files->files[*i].name;
 | 
			
		||||
	}
 | 
			
		||||
	(*i)--;
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Takes a file list and resolves all directory paths according to the
 | 
			
		||||
 * filesystem
 | 
			
		||||
 *
 | 
			
		||||
 * @attention Pre-condition: files must be sorted!
 | 
			
		||||
 *
 | 
			
		||||
 * @note A symlink and directory at the same path in two difference packages
 | 
			
		||||
 * causes a conflict so the filepath can not change as packages get installed
 | 
			
		||||
 *
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param files list of files to resolve
 | 
			
		||||
 *
 | 
			
		||||
 * @return 0 on success, -1 on error
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_filelist_resolve(alpm_handle_t *handle, alpm_filelist_t *files)
 | 
			
		||||
{
 | 
			
		||||
	char path[PATH_MAX];
 | 
			
		||||
	size_t root_len, i = 0;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	if(!files || files->resolved_path) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	CALLOC(files->resolved_path, files->count, sizeof(char *), return -1);
 | 
			
		||||
 | 
			
		||||
	/* not much point in going on if we can't even resolve root */
 | 
			
		||||
	if(realpath(handle->root, path) == NULL){
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	root_len = strlen(path);
 | 
			
		||||
	if(root_len + 1 >= PATH_MAX) {
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	/* append '/' if root is not "/" */
 | 
			
		||||
	if(path[root_len - 1] != '/') {
 | 
			
		||||
		path[root_len] = '/';
 | 
			
		||||
		root_len++;
 | 
			
		||||
		path[root_len] = '\0';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ret = _alpm_filelist_resolve_link(files, &i, path, root_len, 0);
 | 
			
		||||
 | 
			
		||||
	qsort(files->resolved_path, files->count, sizeof(char *),
 | 
			
		||||
			_alpm_filelist_strcmp);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Returns the difference of the provided two lists of files.
 | 
			
		||||
 * Pre-condition: both lists are sorted!
 | 
			
		||||
 * When done, free the list but NOT the contained data.
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
 | 
			
		||||
		alpm_filelist_t *filesB)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *ret = NULL;
 | 
			
		||||
	size_t ctrA = 0, ctrB = 0;
 | 
			
		||||
 | 
			
		||||
	while(ctrA < filesA->count && ctrB < filesB->count) {
 | 
			
		||||
		char *strA = filesA->resolved_path[ctrA];
 | 
			
		||||
		char *strB = filesB->resolved_path[ctrB];
 | 
			
		||||
 | 
			
		||||
		int cmp = strcmp(strA, strB);
 | 
			
		||||
		if(cmp < 0) {
 | 
			
		||||
			/* item only in filesA, qualifies as a difference */
 | 
			
		||||
			ret = alpm_list_add(ret, strA);
 | 
			
		||||
			ctrA++;
 | 
			
		||||
		} else if(cmp > 0) {
 | 
			
		||||
			ctrB++;
 | 
			
		||||
		} else {
 | 
			
		||||
			ctrA++;
 | 
			
		||||
			ctrB++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* ensure we have completely emptied pA */
 | 
			
		||||
	while(ctrA < filesA->count) {
 | 
			
		||||
		ret = alpm_list_add(ret, filesA->resolved_path[ctrA]);
 | 
			
		||||
		ctrA++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Returns the intersection of the provided two lists of files.
 | 
			
		||||
 * Pre-condition: both lists are sorted!
 | 
			
		||||
 * When done, free the list but NOT the contained data.
 | 
			
		||||
 */
 | 
			
		||||
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
 | 
			
		||||
		alpm_filelist_t *filesB)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *ret = NULL;
 | 
			
		||||
	size_t ctrA = 0, ctrB = 0;
 | 
			
		||||
 | 
			
		||||
	while(ctrA < filesA->count && ctrB < filesB->count) {
 | 
			
		||||
		int cmp, isdirA, isdirB;
 | 
			
		||||
		char *strA, *strB;
 | 
			
		||||
 | 
			
		||||
		isdirA = 0;
 | 
			
		||||
		strA = filesA->resolved_path[ctrA];
 | 
			
		||||
		if(strA[strlen(strA)-1] == '/') {
 | 
			
		||||
			isdirA = 1;
 | 
			
		||||
			strA = strndup(filesA->resolved_path[ctrA], strlen(strA)-1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		isdirB = 0;
 | 
			
		||||
		strB = filesB->resolved_path[ctrB];
 | 
			
		||||
		if(strB[strlen(strB)-1] == '/') {
 | 
			
		||||
			isdirB = 1;
 | 
			
		||||
			strB = strndup(filesB->resolved_path[ctrB], strlen(strB)-1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cmp = strcmp(strA, strB);
 | 
			
		||||
		if(cmp < 0) {
 | 
			
		||||
			ctrA++;
 | 
			
		||||
		} else if(cmp > 0) {
 | 
			
		||||
			ctrB++;
 | 
			
		||||
		} else {
 | 
			
		||||
			/* TODO: this creates conflicts between a symlink to a directory in
 | 
			
		||||
			 * one package and a real directory in the other. For example,
 | 
			
		||||
			 * lib -> /usr/lib in pkg1 and /lib in pkg2.  This would be allowed
 | 
			
		||||
			 * when installing one package at a time _provided_ pkg1 is installed
 | 
			
		||||
			 * first. This will need adjusted if the order of package install can
 | 
			
		||||
			 * be guaranteed to install the symlink first */
 | 
			
		||||
 | 
			
		||||
			/* when not directories, item in both qualifies as an intersect */
 | 
			
		||||
			if(! (isdirA && isdirB)) {
 | 
			
		||||
				ret = alpm_list_add(ret, filesA->resolved_path[ctrA]);
 | 
			
		||||
			}
 | 
			
		||||
			ctrA++;
 | 
			
		||||
			ctrB++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(isdirA) {
 | 
			
		||||
			free(strA);
 | 
			
		||||
		}
 | 
			
		||||
		if(isdirB) {
 | 
			
		||||
			free(strB);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Helper function for comparing files list entries
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_files_cmp(const void *f1, const void *f2)
 | 
			
		||||
{
 | 
			
		||||
	const alpm_file_t *file1 = f1;
 | 
			
		||||
	const alpm_file_t *file2 = f2;
 | 
			
		||||
	return strcmp(file1->name, file2->name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
 | 
			
		||||
		const char *path)
 | 
			
		||||
{
 | 
			
		||||
	alpm_file_t key, *match;
 | 
			
		||||
 | 
			
		||||
	if(!filelist) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	key.name = (char *)path;
 | 
			
		||||
 | 
			
		||||
	match = bsearch(&key, filelist->files, filelist->count,
 | 
			
		||||
			sizeof(alpm_file_t), _alpm_files_cmp);
 | 
			
		||||
 | 
			
		||||
	if(match) {
 | 
			
		||||
		return match->name;
 | 
			
		||||
	} else if(filelist->resolved_path) {
 | 
			
		||||
		return bsearch(&path, filelist->resolved_path, filelist->count,
 | 
			
		||||
				sizeof(char *), _alpm_filelist_strcmp);
 | 
			
		||||
	} else {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
							
								
								
									
										38
									
								
								lib/libalpm/filelist.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								lib/libalpm/filelist.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  filelist.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2012-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef _ALPM_FILELIST_H
 | 
			
		||||
#define _ALPM_FILELIST_H
 | 
			
		||||
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
 | 
			
		||||
int _alpm_filelist_resolve_link(alpm_filelist_t *files, size_t *i,
 | 
			
		||||
		char *path, size_t root_len, int resolving);
 | 
			
		||||
int _alpm_filelist_resolve(alpm_handle_t *handle, alpm_filelist_t *files);
 | 
			
		||||
 | 
			
		||||
alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
 | 
			
		||||
		alpm_filelist_t *filesB);
 | 
			
		||||
 | 
			
		||||
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
 | 
			
		||||
		alpm_filelist_t *filesB);
 | 
			
		||||
 | 
			
		||||
int _alpm_files_cmp(const void *f1, const void *f2);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_FILELIST_H */
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  graph.c - helpful graph structure and setup/teardown methods
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2007-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2007-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -17,8 +17,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include "graph.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  graph.h - helpful graph structure and setup/teardown methods
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2007-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2007-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -19,8 +19,6 @@
 | 
			
		||||
#ifndef _ALPM_GRAPH_H
 | 
			
		||||
#define _ALPM_GRAPH_H
 | 
			
		||||
 | 
			
		||||
#include "config.h" /* ensure off_t is correct length */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h> /* off_t */
 | 
			
		||||
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  group.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,8 +18,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
@@ -32,7 +30,7 @@
 | 
			
		||||
 | 
			
		||||
alpm_group_t *_alpm_group_new(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	alpm_group_t* grp;
 | 
			
		||||
	alpm_group_t *grp;
 | 
			
		||||
 | 
			
		||||
	CALLOC(grp, 1, sizeof(alpm_group_t), return NULL);
 | 
			
		||||
	STRDUP(grp->name, name, free(grp); return NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  group.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  handle.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
 | 
			
		||||
@@ -20,8 +20,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@@ -36,6 +34,7 @@
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "delta.h"
 | 
			
		||||
#include "trans.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
 | 
			
		||||
@@ -44,6 +43,7 @@ alpm_handle_t *_alpm_handle_new(void)
 | 
			
		||||
	alpm_handle_t *handle;
 | 
			
		||||
 | 
			
		||||
	CALLOC(handle, 1, sizeof(alpm_handle_t), return NULL);
 | 
			
		||||
	handle->deltaratio = 0.0;
 | 
			
		||||
 | 
			
		||||
	return handle;
 | 
			
		||||
}
 | 
			
		||||
@@ -57,7 +57,7 @@ void _alpm_handle_free(alpm_handle_t *handle)
 | 
			
		||||
	/* close logfile */
 | 
			
		||||
	if(handle->logstream) {
 | 
			
		||||
		fclose(handle->logstream);
 | 
			
		||||
		handle->logstream= NULL;
 | 
			
		||||
		handle->logstream = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if(handle->usesyslog) {
 | 
			
		||||
		handle->usesyslog = 0;
 | 
			
		||||
@@ -69,6 +69,8 @@ void _alpm_handle_free(alpm_handle_t *handle)
 | 
			
		||||
	curl_easy_cleanup(handle->curl);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	regfree(&handle->delta_regex);
 | 
			
		||||
 | 
			
		||||
	/* free memory */
 | 
			
		||||
	_alpm_trans_free(handle->trans);
 | 
			
		||||
	FREE(handle->root);
 | 
			
		||||
@@ -251,10 +253,10 @@ const char SYMEXPORT *alpm_option_get_arch(alpm_handle_t *handle)
 | 
			
		||||
	return handle->arch;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_get_usedelta(alpm_handle_t *handle)
 | 
			
		||||
double SYMEXPORT alpm_option_get_deltaratio(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	return handle->usedelta;
 | 
			
		||||
	return handle->deltaratio;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle)
 | 
			
		||||
@@ -263,18 +265,6 @@ int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle)
 | 
			
		||||
	return handle->checkspace;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_db_t SYMEXPORT *alpm_option_get_localdb(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return NULL);
 | 
			
		||||
	return handle->db_local;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_option_get_syncdbs(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return NULL);
 | 
			
		||||
	return handle->dbs_sync;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
@@ -324,7 +314,8 @@ int SYMEXPORT alpm_option_set_progresscb(alpm_handle_t *handle, alpm_cb_progress
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char *canonicalize_path(const char *path) {
 | 
			
		||||
static char *canonicalize_path(const char *path)
 | 
			
		||||
{
 | 
			
		||||
	char *new_path;
 | 
			
		||||
	size_t len;
 | 
			
		||||
 | 
			
		||||
@@ -339,11 +330,11 @@ static char *canonicalize_path(const char *path) {
 | 
			
		||||
	return new_path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum _alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
		char **storage, int must_exist)
 | 
			
		||||
 {
 | 
			
		||||
{
 | 
			
		||||
	struct stat st;
 | 
			
		||||
	char *real = NULL;
 | 
			
		||||
	char real[PATH_MAX];
 | 
			
		||||
	const char *path;
 | 
			
		||||
 | 
			
		||||
	path = value;
 | 
			
		||||
@@ -354,9 +345,7 @@ enum _alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
		if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
 | 
			
		||||
			return ALPM_ERR_NOT_A_DIR;
 | 
			
		||||
		}
 | 
			
		||||
		CALLOC(real, PATH_MAX, sizeof(char), return ALPM_ERR_MEMORY);
 | 
			
		||||
		if(!realpath(path, real)) {
 | 
			
		||||
			free(real);
 | 
			
		||||
			return ALPM_ERR_NOT_A_DIR;
 | 
			
		||||
		}
 | 
			
		||||
		path = real;
 | 
			
		||||
@@ -369,7 +358,6 @@ enum _alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
	if(!*storage) {
 | 
			
		||||
		return ALPM_ERR_MEMORY;
 | 
			
		||||
	}
 | 
			
		||||
	free(real);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -596,13 +584,28 @@ int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_set_usedelta(alpm_handle_t *handle, int usedelta)
 | 
			
		||||
int SYMEXPORT alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	handle->usedelta = usedelta;
 | 
			
		||||
	if(ratio < 0.0 || ratio > 2.0) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
 | 
			
		||||
	}
 | 
			
		||||
	handle->deltaratio = ratio;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_db_t SYMEXPORT *alpm_get_localdb(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return NULL);
 | 
			
		||||
	return handle->db_local;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_get_syncdbs(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return NULL);
 | 
			
		||||
	return handle->dbs_sync;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
@@ -630,4 +633,44 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle
 | 
			
		||||
	return handle->siglevel;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
 | 
			
		||||
		alpm_siglevel_t level)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
#ifdef HAVE_LIBGPGME
 | 
			
		||||
	handle->localfilesiglevel = level;
 | 
			
		||||
#else
 | 
			
		||||
	if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	return handle->localfilesiglevel;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
 | 
			
		||||
		alpm_siglevel_t level)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
#ifdef HAVE_LIBGPGME
 | 
			
		||||
	handle->remotefilesiglevel = level;
 | 
			
		||||
#else
 | 
			
		||||
	if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
 | 
			
		||||
		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_HANDLE(handle, return -1);
 | 
			
		||||
	return handle->remotefilesiglevel;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  handle.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -22,6 +22,7 @@
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <regex.h>
 | 
			
		||||
 | 
			
		||||
#include "alpm_list.h"
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
@@ -86,14 +87,22 @@ struct __alpm_handle_t {
 | 
			
		||||
	alpm_list_t *ignoregroup; /* List of groups to ignore */
 | 
			
		||||
 | 
			
		||||
	/* options */
 | 
			
		||||
	int usesyslog;           /* Use syslog instead of logfile? */ /* TODO move to frontend */
 | 
			
		||||
	char *arch;              /* Architecture of packages we should allow */
 | 
			
		||||
	int usedelta;            /* Download deltas if possible */
 | 
			
		||||
	double deltaratio;       /* Download deltas if possible; a ratio value */
 | 
			
		||||
	int usesyslog;           /* Use syslog instead of logfile? */ /* TODO move to frontend */
 | 
			
		||||
	int checkspace;          /* Check disk space before installing */
 | 
			
		||||
	alpm_siglevel_t siglevel;   /* Default signature verification level */
 | 
			
		||||
	alpm_siglevel_t localfilesiglevel;  /* Signature verification level for local file
 | 
			
		||||
	                                       upgrade operations */
 | 
			
		||||
	alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file
 | 
			
		||||
	                                       upgrade operations */
 | 
			
		||||
 | 
			
		||||
	/* error code */
 | 
			
		||||
	enum _alpm_errno_t pm_errno;
 | 
			
		||||
	alpm_errno_t pm_errno;
 | 
			
		||||
 | 
			
		||||
	/* for delta parsing efficiency */
 | 
			
		||||
	int delta_regex_compiled;
 | 
			
		||||
	regex_t delta_regex;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
alpm_handle_t *_alpm_handle_new(void);
 | 
			
		||||
@@ -102,7 +111,7 @@ void _alpm_handle_free(alpm_handle_t *handle);
 | 
			
		||||
int _alpm_handle_lock(alpm_handle_t *handle);
 | 
			
		||||
int _alpm_handle_unlock(alpm_handle_t *handle);
 | 
			
		||||
 | 
			
		||||
enum _alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
alpm_errno_t _alpm_set_directory_option(const char *value,
 | 
			
		||||
		char **storage, int must_exist);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_HANDLE_H */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								lib/libalpm/libalpm.pc.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								lib/libalpm/libalpm.pc.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
prefix=@prefix@
 | 
			
		||||
exec_prefix=@exec_prefix@
 | 
			
		||||
libdir=@libdir@
 | 
			
		||||
includedir=@includedir@
 | 
			
		||||
 | 
			
		||||
Name: libalpm
 | 
			
		||||
Description: Arch Linux package management library
 | 
			
		||||
URL: http://www.archlinux.org/pacman/
 | 
			
		||||
Version: @VERSION@
 | 
			
		||||
Cflags: -I${includedir}
 | 
			
		||||
Libs: -L${libdir} -lalpm
 | 
			
		||||
Libs.private: @LIBS@ @LIBARCHIVE_LIBS@ @LIBSSL_LIBS@ @LIBCURL_LIBS@ @GPGME_LIBS@
 | 
			
		||||
							
								
								
									
										73
									
								
								lib/libalpm/libarchive-compat.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								lib/libalpm/libarchive-compat.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
#ifndef _LIBARCHIVE_COMPAT_H
 | 
			
		||||
#define _LIBARCHIVE_COMPAT_H
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * libarchive-compat.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
static inline int _alpm_archive_read_free(struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
 | 
			
		||||
	return archive_read_free(archive);
 | 
			
		||||
#else
 | 
			
		||||
	return archive_read_finish(archive);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int64_t _alpm_archive_compressed_ftell(struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
 | 
			
		||||
	return archive_filter_bytes(archive, -1);
 | 
			
		||||
#else
 | 
			
		||||
	return archive_position_compressed(archive);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int _alpm_archive_read_open_file(struct archive *archive,
 | 
			
		||||
		const char *filename, size_t block_size)
 | 
			
		||||
{
 | 
			
		||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
 | 
			
		||||
	return archive_read_open_filename(archive, filename, block_size);
 | 
			
		||||
#else
 | 
			
		||||
	return archive_read_open_file(archive, filename, block_size);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int _alpm_archive_filter_code(struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
 | 
			
		||||
	return archive_filter_code(archive, 0);
 | 
			
		||||
#else
 | 
			
		||||
	return archive_compression(archive);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int _alpm_archive_read_support_filter_all(struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
 | 
			
		||||
	return archive_read_support_filter_all(archive);
 | 
			
		||||
#else
 | 
			
		||||
	return archive_read_support_compression_all(archive);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _LIBARCHIVE_COMPAT_H */
 | 
			
		||||
 | 
			
		||||
/* vim: set ts=2 sw=2 noet: */
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  log.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -18,8 +18,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
@@ -37,10 +35,12 @@
 | 
			
		||||
 | 
			
		||||
/** A printf-like function for logging.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param prefix caller-specific prefix for the log
 | 
			
		||||
 * @param fmt output format
 | 
			
		||||
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 | 
			
		||||
 */
 | 
			
		||||
int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *fmt, ...)
 | 
			
		||||
int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix,
 | 
			
		||||
		const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	va_list args;
 | 
			
		||||
@@ -64,20 +64,9 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *fmt, ...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	va_start(args, fmt);
 | 
			
		||||
	ret = _alpm_logaction(handle, fmt, args);
 | 
			
		||||
	ret = _alpm_logaction(handle, prefix, fmt, args);
 | 
			
		||||
	va_end(args);
 | 
			
		||||
 | 
			
		||||
	/* TODO	We should add a prefix to log strings depending on who called us.
 | 
			
		||||
	 * If logaction was called by the frontend:
 | 
			
		||||
	 *   USER: <the frontend log>
 | 
			
		||||
	 * and if called internally:
 | 
			
		||||
	 *   ALPM: <the library log>
 | 
			
		||||
	 * Moreover, the frontend should be able to choose its prefix
 | 
			
		||||
	 * (USER by default?):
 | 
			
		||||
	 *   pacman: "PACMAN"
 | 
			
		||||
	 *   kpacman: "KPACMAN"
 | 
			
		||||
	 * This would allow us to share the log file between several frontends
 | 
			
		||||
	 * and know who does what */
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  log.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
@@ -22,6 +22,8 @@
 | 
			
		||||
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
 | 
			
		||||
#define ALPM_CALLER_PREFIX "ALPM"
 | 
			
		||||
 | 
			
		||||
void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag,
 | 
			
		||||
		const char *fmt, ...) __attribute__((format(printf,3,4)));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,33 +33,34 @@
 | 
			
		||||
 *  GPL. This is from version 1.0.0 of the library, and has been modified
 | 
			
		||||
 *  as following, which may be helpful for future updates:
 | 
			
		||||
 *  * remove "polarssl/config.h" include
 | 
			
		||||
 *  * change include from "polarssl/sha2.h" to "sha2.h"
 | 
			
		||||
 *  * change include from "polarssl/md5.h" to "md5.h"
 | 
			
		||||
 *  * removal of HMAC code
 | 
			
		||||
 *  * removal of SELF_TEST code
 | 
			
		||||
 *  * removal of ipad and opad from the md5_context struct in sha2.h
 | 
			
		||||
 *  * removal of ipad and opad from the md5_context struct in md5.h
 | 
			
		||||
 *  * increase the size of buffer for performance reasons
 | 
			
		||||
 *  * various static changes
 | 
			
		||||
 *  * change 'unsigned long' to uint32_t
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#include "md5.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * 32-bit integer manipulation macros (little endian)
 | 
			
		||||
 */
 | 
			
		||||
#ifndef GET_ULONG_LE
 | 
			
		||||
#define GET_ULONG_LE(n,b,i)                             \
 | 
			
		||||
#ifndef GET_U32_LE
 | 
			
		||||
#define GET_U32_LE(n,b,i)                               \
 | 
			
		||||
{                                                       \
 | 
			
		||||
    (n) = ( (unsigned long) (b)[(i)    ]       )        \
 | 
			
		||||
        | ( (unsigned long) (b)[(i) + 1] <<  8 )        \
 | 
			
		||||
        | ( (unsigned long) (b)[(i) + 2] << 16 )        \
 | 
			
		||||
        | ( (unsigned long) (b)[(i) + 3] << 24 );       \
 | 
			
		||||
    (n) = ( (uint32_t) (b)[(i)    ]       )             \
 | 
			
		||||
        | ( (uint32_t) (b)[(i) + 1] <<  8 )             \
 | 
			
		||||
        | ( (uint32_t) (b)[(i) + 2] << 16 )             \
 | 
			
		||||
        | ( (uint32_t) (b)[(i) + 3] << 24 );            \
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef PUT_ULONG_LE
 | 
			
		||||
#define PUT_ULONG_LE(n,b,i)                             \
 | 
			
		||||
#ifndef PUT_U32_LE
 | 
			
		||||
#define PUT_U32_LE(n,b,i)                               \
 | 
			
		||||
{                                                       \
 | 
			
		||||
    (b)[(i)    ] = (unsigned char) ( (n)       );       \
 | 
			
		||||
    (b)[(i) + 1] = (unsigned char) ( (n) >>  8 );       \
 | 
			
		||||
@@ -84,24 +85,24 @@ static void md5_starts( md5_context *ctx )
 | 
			
		||||
 | 
			
		||||
static void md5_process( md5_context *ctx, const unsigned char data[64] )
 | 
			
		||||
{
 | 
			
		||||
    unsigned long X[16], A, B, C, D;
 | 
			
		||||
    uint32_t X[16], A, B, C, D;
 | 
			
		||||
 | 
			
		||||
    GET_ULONG_LE( X[ 0], data,  0 );
 | 
			
		||||
    GET_ULONG_LE( X[ 1], data,  4 );
 | 
			
		||||
    GET_ULONG_LE( X[ 2], data,  8 );
 | 
			
		||||
    GET_ULONG_LE( X[ 3], data, 12 );
 | 
			
		||||
    GET_ULONG_LE( X[ 4], data, 16 );
 | 
			
		||||
    GET_ULONG_LE( X[ 5], data, 20 );
 | 
			
		||||
    GET_ULONG_LE( X[ 6], data, 24 );
 | 
			
		||||
    GET_ULONG_LE( X[ 7], data, 28 );
 | 
			
		||||
    GET_ULONG_LE( X[ 8], data, 32 );
 | 
			
		||||
    GET_ULONG_LE( X[ 9], data, 36 );
 | 
			
		||||
    GET_ULONG_LE( X[10], data, 40 );
 | 
			
		||||
    GET_ULONG_LE( X[11], data, 44 );
 | 
			
		||||
    GET_ULONG_LE( X[12], data, 48 );
 | 
			
		||||
    GET_ULONG_LE( X[13], data, 52 );
 | 
			
		||||
    GET_ULONG_LE( X[14], data, 56 );
 | 
			
		||||
    GET_ULONG_LE( X[15], data, 60 );
 | 
			
		||||
    GET_U32_LE( X[ 0], data,  0 );
 | 
			
		||||
    GET_U32_LE( X[ 1], data,  4 );
 | 
			
		||||
    GET_U32_LE( X[ 2], data,  8 );
 | 
			
		||||
    GET_U32_LE( X[ 3], data, 12 );
 | 
			
		||||
    GET_U32_LE( X[ 4], data, 16 );
 | 
			
		||||
    GET_U32_LE( X[ 5], data, 20 );
 | 
			
		||||
    GET_U32_LE( X[ 6], data, 24 );
 | 
			
		||||
    GET_U32_LE( X[ 7], data, 28 );
 | 
			
		||||
    GET_U32_LE( X[ 8], data, 32 );
 | 
			
		||||
    GET_U32_LE( X[ 9], data, 36 );
 | 
			
		||||
    GET_U32_LE( X[10], data, 40 );
 | 
			
		||||
    GET_U32_LE( X[11], data, 44 );
 | 
			
		||||
    GET_U32_LE( X[12], data, 48 );
 | 
			
		||||
    GET_U32_LE( X[13], data, 52 );
 | 
			
		||||
    GET_U32_LE( X[14], data, 56 );
 | 
			
		||||
    GET_U32_LE( X[15], data, 60 );
 | 
			
		||||
 | 
			
		||||
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
 | 
			
		||||
 | 
			
		||||
@@ -211,7 +212,7 @@ static void md5_process( md5_context *ctx, const unsigned char data[64] )
 | 
			
		||||
static void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen )
 | 
			
		||||
{
 | 
			
		||||
    size_t fill;
 | 
			
		||||
    unsigned long left;
 | 
			
		||||
    uint32_t left;
 | 
			
		||||
 | 
			
		||||
    if( ilen <= 0 )
 | 
			
		||||
        return;
 | 
			
		||||
@@ -219,10 +220,10 @@ static void md5_update( md5_context *ctx, const unsigned char *input, size_t ile
 | 
			
		||||
    left = ctx->total[0] & 0x3F;
 | 
			
		||||
    fill = 64 - left;
 | 
			
		||||
 | 
			
		||||
    ctx->total[0] += (unsigned long) ilen;
 | 
			
		||||
    ctx->total[0] += (uint32_t) ilen;
 | 
			
		||||
    ctx->total[0] &= 0xFFFFFFFF;
 | 
			
		||||
 | 
			
		||||
    if( ctx->total[0] < (unsigned long) ilen )
 | 
			
		||||
    if( ctx->total[0] < (uint32_t) ilen )
 | 
			
		||||
        ctx->total[1]++;
 | 
			
		||||
 | 
			
		||||
    if( left && ilen >= fill )
 | 
			
		||||
@@ -262,16 +263,16 @@ static const unsigned char md5_padding[64] =
 | 
			
		||||
 */
 | 
			
		||||
static void md5_finish( md5_context *ctx, unsigned char output[16] )
 | 
			
		||||
{
 | 
			
		||||
    unsigned long last, padn;
 | 
			
		||||
    unsigned long high, low;
 | 
			
		||||
    uint32_t last, padn;
 | 
			
		||||
    uint32_t high, low;
 | 
			
		||||
    unsigned char msglen[8];
 | 
			
		||||
 | 
			
		||||
    high = ( ctx->total[0] >> 29 )
 | 
			
		||||
         | ( ctx->total[1] <<  3 );
 | 
			
		||||
    low  = ( ctx->total[0] <<  3 );
 | 
			
		||||
 | 
			
		||||
    PUT_ULONG_LE( low,  msglen, 0 );
 | 
			
		||||
    PUT_ULONG_LE( high, msglen, 4 );
 | 
			
		||||
    PUT_U32_LE( low,  msglen, 0 );
 | 
			
		||||
    PUT_U32_LE( high, msglen, 4 );
 | 
			
		||||
 | 
			
		||||
    last = ctx->total[0] & 0x3F;
 | 
			
		||||
    padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
 | 
			
		||||
@@ -279,10 +280,10 @@ static void md5_finish( md5_context *ctx, unsigned char output[16] )
 | 
			
		||||
    md5_update( ctx, (unsigned char *) md5_padding, padn );
 | 
			
		||||
    md5_update( ctx, msglen, 8 );
 | 
			
		||||
 | 
			
		||||
    PUT_ULONG_LE( ctx->state[0], output,  0 );
 | 
			
		||||
    PUT_ULONG_LE( ctx->state[1], output,  4 );
 | 
			
		||||
    PUT_ULONG_LE( ctx->state[2], output,  8 );
 | 
			
		||||
    PUT_ULONG_LE( ctx->state[3], output, 12 );
 | 
			
		||||
    PUT_U32_LE( ctx->state[0], output,  0 );
 | 
			
		||||
    PUT_U32_LE( ctx->state[1], output,  4 );
 | 
			
		||||
    PUT_U32_LE( ctx->state[2], output,  8 );
 | 
			
		||||
    PUT_U32_LE( ctx->state[3], output, 12 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  package.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
 | 
			
		||||
@@ -21,8 +21,6 @@
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
@@ -48,7 +46,7 @@ int SYMEXPORT alpm_pkg_free(alpm_pkg_t *pkg)
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
 | 
			
		||||
	/* Only free packages loaded in user space */
 | 
			
		||||
	if(pkg->origin == PKG_FROM_FILE) {
 | 
			
		||||
	if(pkg->origin == ALPM_PKG_FROM_FILE) {
 | 
			
		||||
		_alpm_pkg_free(pkg);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -64,12 +62,12 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	/* We only inspect packages from sync repositories */
 | 
			
		||||
	ASSERT(pkg->origin == PKG_FROM_SYNCDB,
 | 
			
		||||
	ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
 | 
			
		||||
			RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
 | 
			
		||||
	fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
 | 
			
		||||
 | 
			
		||||
	retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_CSUM_MD5);
 | 
			
		||||
	retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
 | 
			
		||||
 | 
			
		||||
	if(retval == 0) {
 | 
			
		||||
		return 0;
 | 
			
		||||
@@ -87,12 +85,13 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
 | 
			
		||||
 * populated package structures. */
 | 
			
		||||
static const char *_pkg_get_desc(alpm_pkg_t *pkg)        { return pkg->desc; }
 | 
			
		||||
static const char *_pkg_get_url(alpm_pkg_t *pkg)         { return pkg->url; }
 | 
			
		||||
static time_t _pkg_get_builddate(alpm_pkg_t *pkg)        { return pkg->builddate; }
 | 
			
		||||
static time_t _pkg_get_installdate(alpm_pkg_t *pkg)      { return pkg->installdate; }
 | 
			
		||||
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg)   { return pkg->builddate; }
 | 
			
		||||
static alpm_time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
 | 
			
		||||
static const char *_pkg_get_packager(alpm_pkg_t *pkg)    { return pkg->packager; }
 | 
			
		||||
static const char *_pkg_get_arch(alpm_pkg_t *pkg)        { return pkg->arch; }
 | 
			
		||||
static off_t _pkg_get_isize(alpm_pkg_t *pkg)             { return pkg->isize; }
 | 
			
		||||
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg)    { return pkg->reason; }
 | 
			
		||||
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
 | 
			
		||||
static alpm_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
 | 
			
		||||
static int _pkg_has_scriptlet(alpm_pkg_t *pkg)           { return pkg->scriptlet; }
 | 
			
		||||
 | 
			
		||||
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg)   { return pkg->licenses; }
 | 
			
		||||
@@ -122,6 +121,23 @@ static int _pkg_changelog_close(const alpm_pkg_t UNUSED *pkg,
 | 
			
		||||
	return EOF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct archive *_pkg_mtree_open(alpm_pkg_t UNUSED *pkg)
 | 
			
		||||
{
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _pkg_mtree_next(const alpm_pkg_t UNUSED *pkg,
 | 
			
		||||
		struct archive UNUSED *archive, struct archive_entry UNUSED **entry)
 | 
			
		||||
{
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _pkg_mtree_close(const alpm_pkg_t UNUSED *pkg,
 | 
			
		||||
		struct archive UNUSED *archive)
 | 
			
		||||
{
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
 | 
			
		||||
 | 
			
		||||
/** The standard package operations struct. Get fields directly from the
 | 
			
		||||
@@ -136,6 +152,7 @@ struct pkg_operations default_pkg_ops = {
 | 
			
		||||
	.get_arch        = _pkg_get_arch,
 | 
			
		||||
	.get_isize       = _pkg_get_isize,
 | 
			
		||||
	.get_reason      = _pkg_get_reason,
 | 
			
		||||
	.get_validation  = _pkg_get_validation,
 | 
			
		||||
	.has_scriptlet   = _pkg_has_scriptlet,
 | 
			
		||||
 | 
			
		||||
	.get_licenses    = _pkg_get_licenses,
 | 
			
		||||
@@ -152,6 +169,10 @@ struct pkg_operations default_pkg_ops = {
 | 
			
		||||
	.changelog_read  = _pkg_changelog_read,
 | 
			
		||||
	.changelog_close = _pkg_changelog_close,
 | 
			
		||||
 | 
			
		||||
	.mtree_open      = _pkg_mtree_open,
 | 
			
		||||
	.mtree_next      = _pkg_mtree_next,
 | 
			
		||||
	.mtree_close     = _pkg_mtree_close,
 | 
			
		||||
 | 
			
		||||
	.force_load      = _pkg_force_load,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -200,14 +221,14 @@ const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
 | 
			
		||||
	return pkg->ops->get_url(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
 | 
			
		||||
alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	return pkg->ops->get_builddate(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
 | 
			
		||||
alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
@@ -270,6 +291,13 @@ alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
 | 
			
		||||
	return pkg->ops->get_reason(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	return pkg->ops->get_validation(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
@@ -344,7 +372,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
	ASSERT(pkg->origin != PKG_FROM_FILE, return NULL);
 | 
			
		||||
	ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
 | 
			
		||||
	return pkg->origin_data.db;
 | 
			
		||||
@@ -375,6 +403,31 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
 | 
			
		||||
	return pkg->ops->changelog_close(pkg, fp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Open a package mtree file for reading. */
 | 
			
		||||
struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	return pkg->ops->mtree_open(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Read entry from an open mtree file. */
 | 
			
		||||
int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archive,
 | 
			
		||||
	struct archive_entry **entry)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	return pkg->ops->mtree_next(pkg, archive, entry);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Close a package mtree file for reading. */
 | 
			
		||||
int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
	return pkg->ops->mtree_close(pkg, archive);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	ASSERT(pkg != NULL, return -1);
 | 
			
		||||
@@ -382,7 +435,8 @@ int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
 | 
			
		||||
	return pkg->ops->has_scriptlet(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs)
 | 
			
		||||
static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs,
 | 
			
		||||
		int optional)
 | 
			
		||||
{
 | 
			
		||||
	const alpm_list_t *i;
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
@@ -390,7 +444,14 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs)
 | 
			
		||||
	for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
 | 
			
		||||
		alpm_pkg_t *cachepkg = i->data;
 | 
			
		||||
		alpm_list_t *j;
 | 
			
		||||
		for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
 | 
			
		||||
 | 
			
		||||
		if(optional == 0) {
 | 
			
		||||
			j = alpm_pkg_get_depends(cachepkg);
 | 
			
		||||
		} else {
 | 
			
		||||
			j = alpm_pkg_get_optdepends(cachepkg);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for(; j; j = j->next) {
 | 
			
		||||
			if(_alpm_depcmp(pkg, j->data)) {
 | 
			
		||||
				const char *cachepkgname = cachepkg->name;
 | 
			
		||||
				if(alpm_list_find_str(*reqs, cachepkgname) == NULL) {
 | 
			
		||||
@@ -401,8 +462,7 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Compute the packages requiring a given package. */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
 | 
			
		||||
static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
 | 
			
		||||
{
 | 
			
		||||
	const alpm_list_t *i;
 | 
			
		||||
	alpm_list_t *reqs = NULL;
 | 
			
		||||
@@ -411,19 +471,19 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
 | 
			
		||||
	ASSERT(pkg != NULL, return NULL);
 | 
			
		||||
	pkg->handle->pm_errno = 0;
 | 
			
		||||
 | 
			
		||||
	if(pkg->origin == PKG_FROM_FILE) {
 | 
			
		||||
	if(pkg->origin == ALPM_PKG_FROM_FILE) {
 | 
			
		||||
		/* The sane option; search locally for things that require this. */
 | 
			
		||||
		find_requiredby(pkg, pkg->handle->db_local, &reqs);
 | 
			
		||||
		find_requiredby(pkg, pkg->handle->db_local, &reqs, optional);
 | 
			
		||||
	} else {
 | 
			
		||||
		/* We have a DB package. if it is a local package, then we should
 | 
			
		||||
		 * only search the local DB; else search all known sync databases. */
 | 
			
		||||
		db = pkg->origin_data.db;
 | 
			
		||||
		if(db->status & DB_STATUS_LOCAL) {
 | 
			
		||||
			find_requiredby(pkg, db, &reqs);
 | 
			
		||||
			find_requiredby(pkg, db, &reqs, optional);
 | 
			
		||||
		} else {
 | 
			
		||||
			for(i = pkg->handle->dbs_sync; i; i = i->next) {
 | 
			
		||||
				db = i->data;
 | 
			
		||||
				find_requiredby(pkg, db, &reqs);
 | 
			
		||||
				find_requiredby(pkg, db, &reqs, optional);
 | 
			
		||||
			}
 | 
			
		||||
			reqs = alpm_list_msort(reqs, alpm_list_count(reqs), _alpm_str_cmp);
 | 
			
		||||
		}
 | 
			
		||||
@@ -431,6 +491,19 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
 | 
			
		||||
	return reqs;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Compute the packages requiring a given package. */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	return compute_requiredby(pkg, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Compute the packages optionally requiring a given package. */
 | 
			
		||||
alpm_list_t SYMEXPORT *alpm_pkg_compute_optionalfor(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	return compute_requiredby(pkg, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
alpm_file_t *_alpm_file_copy(alpm_file_t *dest,
 | 
			
		||||
@@ -443,24 +516,24 @@ alpm_file_t *_alpm_file_copy(alpm_file_t *dest,
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Helper function for comparing files list entries
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_files_cmp(const void *f1, const void *f2)
 | 
			
		||||
{
 | 
			
		||||
	const alpm_file_t *file1 = f1;
 | 
			
		||||
	const alpm_file_t *file2 = f2;
 | 
			
		||||
	return strcmp(file1->name, file2->name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_new(void)
 | 
			
		||||
{
 | 
			
		||||
	alpm_pkg_t* pkg;
 | 
			
		||||
	alpm_pkg_t *pkg;
 | 
			
		||||
 | 
			
		||||
	CALLOC(pkg, 1, sizeof(alpm_pkg_t), return NULL);
 | 
			
		||||
 | 
			
		||||
	return pkg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_list_t *list_depdup(alpm_list_t *old)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i, *new = NULL;
 | 
			
		||||
	for(i = old; i; i = i->next) {
 | 
			
		||||
		new = alpm_list_add(new, _alpm_dep_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	return new;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Duplicate a package data struct.
 | 
			
		||||
 * @param pkg the package to duplicate
 | 
			
		||||
@@ -509,10 +582,19 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
 | 
			
		||||
	newpkg->reason = pkg->reason;
 | 
			
		||||
 | 
			
		||||
	newpkg->licenses   = alpm_list_strdup(pkg->licenses);
 | 
			
		||||
	for(i = pkg->replaces; i; i = i->next) {
 | 
			
		||||
		newpkg->replaces = alpm_list_add(newpkg->replaces, _alpm_dep_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	newpkg->replaces   = list_depdup(pkg->replaces);
 | 
			
		||||
	newpkg->groups     = alpm_list_strdup(pkg->groups);
 | 
			
		||||
	for(i = pkg->backup; i; i = i->next) {
 | 
			
		||||
		newpkg->backup = alpm_list_add(newpkg->backup, _alpm_backup_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	newpkg->depends    = list_depdup(pkg->depends);
 | 
			
		||||
	newpkg->optdepends = list_depdup(pkg->optdepends);
 | 
			
		||||
	newpkg->conflicts  = list_depdup(pkg->conflicts);
 | 
			
		||||
	newpkg->provides   = list_depdup(pkg->provides);
 | 
			
		||||
	for(i = pkg->deltas; i; i = i->next) {
 | 
			
		||||
		newpkg->deltas = alpm_list_add(newpkg->deltas, _alpm_delta_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(pkg->files.count) {
 | 
			
		||||
		size_t filenum;
 | 
			
		||||
		size_t len = sizeof(alpm_file_t) * pkg->files.count;
 | 
			
		||||
@@ -524,28 +606,15 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		newpkg->files.count = pkg->files.count;
 | 
			
		||||
	}
 | 
			
		||||
	for(i = pkg->backup; i; i = i->next) {
 | 
			
		||||
		newpkg->backup = alpm_list_add(newpkg->backup, _alpm_backup_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	for(i = pkg->depends; i; i = i->next) {
 | 
			
		||||
		newpkg->depends = alpm_list_add(newpkg->depends, _alpm_dep_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	newpkg->optdepends = alpm_list_strdup(pkg->optdepends);
 | 
			
		||||
	for(i = pkg->conflicts; i; i = i->next) {
 | 
			
		||||
		newpkg->conflicts = alpm_list_add(newpkg->conflicts, _alpm_dep_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	for(i = pkg->provides; i; i = i->next) {
 | 
			
		||||
		newpkg->provides = alpm_list_add(newpkg->provides, _alpm_dep_dup(i->data));
 | 
			
		||||
	}
 | 
			
		||||
	for(i = pkg->deltas; i; i = i->next) {
 | 
			
		||||
		newpkg->deltas = alpm_list_add(newpkg->deltas, _alpm_delta_dup(i->data));
 | 
			
		||||
		/* deliberately do not copy resolved_path as this is only used
 | 
			
		||||
		 * during conflict checking and the sorting of list does not readily
 | 
			
		||||
		 * allow keeping its efficient memory usage when copying */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* internal */
 | 
			
		||||
	newpkg->infolevel = pkg->infolevel;
 | 
			
		||||
	newpkg->origin = pkg->origin;
 | 
			
		||||
	if(newpkg->origin == PKG_FROM_FILE) {
 | 
			
		||||
	if(newpkg->origin == ALPM_PKG_FROM_FILE) {
 | 
			
		||||
		newpkg->origin_data.file = strdup(pkg->origin_data.file);
 | 
			
		||||
	} else {
 | 
			
		||||
		newpkg->origin_data.db = pkg->origin_data.db;
 | 
			
		||||
@@ -561,6 +630,12 @@ cleanup:
 | 
			
		||||
	RET_ERR(pkg->handle, ALPM_ERR_MEMORY, -1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void free_deplist(alpm_list_t *deps)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_dep_free);
 | 
			
		||||
	alpm_list_free(deps);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void _alpm_pkg_free(alpm_pkg_t *pkg)
 | 
			
		||||
{
 | 
			
		||||
	if(pkg == NULL) {
 | 
			
		||||
@@ -579,39 +654,48 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
 | 
			
		||||
	FREE(pkg->arch);
 | 
			
		||||
 | 
			
		||||
	FREELIST(pkg->licenses);
 | 
			
		||||
	alpm_list_free_inner(pkg->replaces, (alpm_list_fn_free)_alpm_dep_free);
 | 
			
		||||
	alpm_list_free(pkg->replaces);
 | 
			
		||||
	free_deplist(pkg->replaces);
 | 
			
		||||
	FREELIST(pkg->groups);
 | 
			
		||||
	if(pkg->files.count) {
 | 
			
		||||
		size_t i;
 | 
			
		||||
		for(i = 0; i < pkg->files.count; i++) {
 | 
			
		||||
			free(pkg->files.files[i].name);
 | 
			
		||||
		size_t i, j, k;
 | 
			
		||||
		if(pkg->files.resolved_path) {
 | 
			
		||||
			for(i = 0, j = 0; i < pkg->files.count; i++) {
 | 
			
		||||
				for(k = j; k <= pkg->files.count; k++) {
 | 
			
		||||
					if(pkg->files.resolved_path[i] == pkg->files.files[k].name) {
 | 
			
		||||
						pkg->files.files[k].name = NULL;
 | 
			
		||||
						j = k + 1;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				free(pkg->files.resolved_path[i]);
 | 
			
		||||
			}
 | 
			
		||||
			free(pkg->files.resolved_path);
 | 
			
		||||
		}
 | 
			
		||||
		for(j = 0; j < pkg->files.count; j++) {
 | 
			
		||||
			FREE(pkg->files.files[j].name);
 | 
			
		||||
		}
 | 
			
		||||
		free(pkg->files.files);
 | 
			
		||||
	}
 | 
			
		||||
	alpm_list_free_inner(pkg->backup, (alpm_list_fn_free)_alpm_backup_free);
 | 
			
		||||
	alpm_list_free(pkg->backup);
 | 
			
		||||
	alpm_list_free_inner(pkg->depends, (alpm_list_fn_free)_alpm_dep_free);
 | 
			
		||||
	alpm_list_free(pkg->depends);
 | 
			
		||||
	FREELIST(pkg->optdepends);
 | 
			
		||||
	alpm_list_free_inner(pkg->conflicts, (alpm_list_fn_free)_alpm_dep_free);
 | 
			
		||||
	alpm_list_free(pkg->conflicts);
 | 
			
		||||
	alpm_list_free_inner(pkg->provides, (alpm_list_fn_free)_alpm_dep_free);
 | 
			
		||||
	alpm_list_free(pkg->provides);
 | 
			
		||||
	free_deplist(pkg->depends);
 | 
			
		||||
	free_deplist(pkg->optdepends);
 | 
			
		||||
	free_deplist(pkg->conflicts);
 | 
			
		||||
	free_deplist(pkg->provides);
 | 
			
		||||
	alpm_list_free_inner(pkg->deltas, (alpm_list_fn_free)_alpm_delta_free);
 | 
			
		||||
	alpm_list_free(pkg->deltas);
 | 
			
		||||
	alpm_list_free(pkg->delta_path);
 | 
			
		||||
	alpm_list_free(pkg->removes);
 | 
			
		||||
 | 
			
		||||
	if(pkg->origin == PKG_FROM_FILE) {
 | 
			
		||||
	if(pkg->origin == ALPM_PKG_FROM_FILE) {
 | 
			
		||||
		FREE(pkg->origin_data.file);
 | 
			
		||||
	}
 | 
			
		||||
	FREE(pkg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This function should be used when removing a target from upgrade/sync target list
 | 
			
		||||
 * Case 1: If pkg is a loaded package file (PKG_FROM_FILE), it will be freed.
 | 
			
		||||
 * Case 2: If pkg is a pkgcache entry (PKG_FROM_CACHE), it won't be freed,
 | 
			
		||||
 * Case 1: If pkg is a loaded package file (ALPM_PKG_FROM_FILE), it will be freed.
 | 
			
		||||
 * Case 2: If pkg is a pkgcache entry (ALPM_PKG_FROM_CACHE), it won't be freed,
 | 
			
		||||
 *         only the transaction specific fields of pkg will be freed.
 | 
			
		||||
 */
 | 
			
		||||
void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
 | 
			
		||||
@@ -620,7 +704,7 @@ void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(pkg->origin == PKG_FROM_FILE) {
 | 
			
		||||
	if(pkg->origin == ALPM_PKG_FROM_FILE) {
 | 
			
		||||
		_alpm_pkg_free(pkg);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
@@ -647,7 +731,7 @@ int _alpm_pkg_cmp(const void *p1, const void *p2)
 | 
			
		||||
/* Test for existence of a package in a alpm_list_t*
 | 
			
		||||
 * of alpm_pkg_t*
 | 
			
		||||
 */
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle)
 | 
			
		||||
alpm_pkg_t SYMEXPORT *alpm_pkg_find(alpm_list_t *haystack, const char *needle)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *lp;
 | 
			
		||||
	unsigned long needle_hash;
 | 
			
		||||
@@ -690,14 +774,14 @@ int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
 | 
			
		||||
	alpm_list_t *groups = NULL;
 | 
			
		||||
 | 
			
		||||
	/* first see if the package is ignored */
 | 
			
		||||
	if(alpm_list_find_str(handle->ignorepkg, pkg->name)) {
 | 
			
		||||
	if(alpm_list_find(handle->ignorepkg, pkg->name, _alpm_fnmatch)) {
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* next see if the package is in a group that is ignored */
 | 
			
		||||
	for(groups = handle->ignoregroup; groups; groups = groups->next) {
 | 
			
		||||
	for(groups = alpm_pkg_get_groups(pkg); groups; groups = groups->next) {
 | 
			
		||||
		char *grp = groups->data;
 | 
			
		||||
		if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) {
 | 
			
		||||
		if(alpm_list_find(handle->ignoregroup, grp, _alpm_fnmatch)) {
 | 
			
		||||
			return 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  package.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
 | 
			
		||||
 *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
 | 
			
		||||
 *  Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
 | 
			
		||||
@@ -24,10 +24,11 @@
 | 
			
		||||
#ifndef _ALPM_PACKAGE_H
 | 
			
		||||
#define _ALPM_PACKAGE_H
 | 
			
		||||
 | 
			
		||||
#include "config.h" /* ensure off_t is correct length */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h> /* off_t */
 | 
			
		||||
#include <time.h> /* time_t */
 | 
			
		||||
 | 
			
		||||
/* libarchive */
 | 
			
		||||
#include <archive.h>
 | 
			
		||||
#include <archive_entry.h>
 | 
			
		||||
 | 
			
		||||
#include "alpm.h"
 | 
			
		||||
#include "backup.h"
 | 
			
		||||
@@ -44,12 +45,13 @@
 | 
			
		||||
struct pkg_operations {
 | 
			
		||||
	const char *(*get_desc) (alpm_pkg_t *);
 | 
			
		||||
	const char *(*get_url) (alpm_pkg_t *);
 | 
			
		||||
	time_t (*get_builddate) (alpm_pkg_t *);
 | 
			
		||||
	time_t (*get_installdate) (alpm_pkg_t *);
 | 
			
		||||
	alpm_time_t (*get_builddate) (alpm_pkg_t *);
 | 
			
		||||
	alpm_time_t (*get_installdate) (alpm_pkg_t *);
 | 
			
		||||
	const char *(*get_packager) (alpm_pkg_t *);
 | 
			
		||||
	const char *(*get_arch) (alpm_pkg_t *);
 | 
			
		||||
	off_t (*get_isize) (alpm_pkg_t *);
 | 
			
		||||
	alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
 | 
			
		||||
	alpm_pkgvalidation_t (*get_validation) (alpm_pkg_t *);
 | 
			
		||||
	int (*has_scriptlet) (alpm_pkg_t *);
 | 
			
		||||
 | 
			
		||||
	alpm_list_t *(*get_licenses) (alpm_pkg_t *);
 | 
			
		||||
@@ -66,6 +68,10 @@ struct pkg_operations {
 | 
			
		||||
	size_t (*changelog_read) (void *, size_t, const alpm_pkg_t *, void *);
 | 
			
		||||
	int (*changelog_close) (const alpm_pkg_t *, void *);
 | 
			
		||||
 | 
			
		||||
	struct archive *(*mtree_open) (alpm_pkg_t *);
 | 
			
		||||
	int (*mtree_next) (const alpm_pkg_t *, struct archive *, struct archive_entry **);
 | 
			
		||||
	int (*mtree_close) (const alpm_pkg_t *, struct archive *);
 | 
			
		||||
 | 
			
		||||
	int (*force_load) (alpm_pkg_t *);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -89,8 +95,8 @@ struct __alpm_pkg_t {
 | 
			
		||||
	char *base64_sig;
 | 
			
		||||
	char *arch;
 | 
			
		||||
 | 
			
		||||
	time_t builddate;
 | 
			
		||||
	time_t installdate;
 | 
			
		||||
	alpm_time_t builddate;
 | 
			
		||||
	alpm_time_t installdate;
 | 
			
		||||
 | 
			
		||||
	off_t size;
 | 
			
		||||
	off_t isize;
 | 
			
		||||
@@ -99,6 +105,7 @@ struct __alpm_pkg_t {
 | 
			
		||||
	int scriptlet;
 | 
			
		||||
 | 
			
		||||
	alpm_pkgreason_t reason;
 | 
			
		||||
	alpm_pkgvalidation_t validation;
 | 
			
		||||
	alpm_dbinfrq_t infolevel;
 | 
			
		||||
	alpm_pkgfrom_t origin;
 | 
			
		||||
	/* origin == PKG_FROM_FILE, use pkg->origin_data.file
 | 
			
		||||
@@ -127,22 +134,20 @@ struct __alpm_pkg_t {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
 | 
			
		||||
int _alpm_files_cmp(const void *f1, const void *f2);
 | 
			
		||||
 | 
			
		||||
alpm_pkg_t* _alpm_pkg_new(void);
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_new(void);
 | 
			
		||||
int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr);
 | 
			
		||||
void _alpm_pkg_free(alpm_pkg_t *pkg);
 | 
			
		||||
void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 | 
			
		||||
		const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
 | 
			
		||||
		alpm_siglist_t **sigdata);
 | 
			
		||||
		alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation);
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
 | 
			
		||||
		const char *pkgfile, int full);
 | 
			
		||||
 | 
			
		||||
int _alpm_pkg_cmp(const void *p1, const void *p2);
 | 
			
		||||
int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg);
 | 
			
		||||
alpm_pkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle);
 | 
			
		||||
int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_PACKAGE_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  pkghash.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2011-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -26,42 +26,51 @@
 | 
			
		||||
 *
 | 
			
		||||
 * The maximum table size is the last prime under 1,000,000.  That is
 | 
			
		||||
 * more than an order of magnitude greater than the number of packages
 | 
			
		||||
 * in any Linux distribution.
 | 
			
		||||
 * in any Linux distribution, and well under UINT_MAX.
 | 
			
		||||
 */
 | 
			
		||||
static const size_t prime_list[] =
 | 
			
		||||
static const unsigned int prime_list[] =
 | 
			
		||||
{
 | 
			
		||||
	11ul, 13ul, 17ul, 19ul, 23ul, 29ul, 31ul, 37ul, 41ul, 43ul, 47ul,
 | 
			
		||||
	53ul, 59ul, 61ul, 67ul, 71ul, 73ul, 79ul, 83ul, 89ul, 97ul, 103ul,
 | 
			
		||||
	109ul, 113ul, 127ul, 137ul, 139ul, 149ul, 157ul, 167ul, 179ul, 193ul,
 | 
			
		||||
	199ul, 211ul, 227ul, 241ul, 257ul, 277ul, 293ul, 313ul, 337ul, 359ul,
 | 
			
		||||
	383ul, 409ul, 439ul, 467ul, 503ul, 541ul, 577ul, 619ul, 661ul, 709ul,
 | 
			
		||||
	761ul, 823ul, 887ul, 953ul, 1031ul, 1109ul, 1193ul, 1289ul, 1381ul,
 | 
			
		||||
	1493ul, 1613ul, 1741ul, 1879ul, 2029ul, 2179ul, 2357ul, 2549ul,
 | 
			
		||||
	2753ul, 2971ul, 3209ul, 3469ul, 3739ul, 4027ul, 4349ul, 4703ul,
 | 
			
		||||
	5087ul, 5503ul, 5953ul, 6427ul, 6949ul, 7517ul, 8123ul, 8783ul,
 | 
			
		||||
	9497ul, 10273ul, 11113ul, 12011ul, 12983ul, 14033ul, 15173ul,
 | 
			
		||||
	16411ul, 17749ul, 19183ul, 20753ul, 22447ul, 24281ul, 26267ul,
 | 
			
		||||
	28411ul, 30727ul, 33223ul, 35933ul, 38873ul, 42043ul, 45481ul,
 | 
			
		||||
	49201ul, 53201ul, 57557ul, 62233ul, 67307ul, 72817ul, 78779ul,
 | 
			
		||||
	85229ul, 92203ul, 99733ul, 107897ul, 116731ul, 126271ul, 136607ul,
 | 
			
		||||
	147793ul, 159871ul, 172933ul, 187091ul, 202409ul, 218971ul, 236897ul,
 | 
			
		||||
	256279ul, 277261ul, 299951ul, 324503ul, 351061ul, 379787ul, 410857ul,
 | 
			
		||||
	444487ul, 480881ul, 520241ul, 562841ul, 608903ul, 658753ul, 712697ul,
 | 
			
		||||
	771049ul, 834181ul, 902483ul, 976369ul
 | 
			
		||||
	11u, 13u, 17u, 19u, 23u, 29u, 31u, 37u, 41u, 43u, 47u,
 | 
			
		||||
	53u, 59u, 61u, 67u, 71u, 73u, 79u, 83u, 89u, 97u, 103u,
 | 
			
		||||
	109u, 113u, 127u, 137u, 139u, 149u, 157u, 167u, 179u, 193u,
 | 
			
		||||
	199u, 211u, 227u, 241u, 257u, 277u, 293u, 313u, 337u, 359u,
 | 
			
		||||
	383u, 409u, 439u, 467u, 503u, 541u, 577u, 619u, 661u, 709u,
 | 
			
		||||
	761u, 823u, 887u, 953u, 1031u, 1109u, 1193u, 1289u, 1381u,
 | 
			
		||||
	1493u, 1613u, 1741u, 1879u, 2029u, 2179u, 2357u, 2549u,
 | 
			
		||||
	2753u, 2971u, 3209u, 3469u, 3739u, 4027u, 4349u, 4703u,
 | 
			
		||||
	5087u, 5503u, 5953u, 6427u, 6949u, 7517u, 8123u, 8783u,
 | 
			
		||||
	9497u, 10273u, 11113u, 12011u, 12983u, 14033u, 15173u,
 | 
			
		||||
	16411u, 17749u, 19183u, 20753u, 22447u, 24281u, 26267u,
 | 
			
		||||
	28411u, 30727u, 33223u, 35933u, 38873u, 42043u, 45481u,
 | 
			
		||||
	49201u, 53201u, 57557u, 62233u, 67307u, 72817u, 78779u,
 | 
			
		||||
	85229u, 92203u, 99733u, 107897u, 116731u, 126271u, 136607u,
 | 
			
		||||
	147793u, 159871u, 172933u, 187091u, 202409u, 218971u, 236897u,
 | 
			
		||||
	256279u, 277261u, 299951u, 324503u, 351061u, 379787u, 410857u,
 | 
			
		||||
	444487u, 480881u, 520241u, 562841u, 608903u, 658753u, 712697u,
 | 
			
		||||
	771049u, 834181u, 902483u, 976369u
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Allocate a hash table with at least "size" buckets */
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_create(size_t size)
 | 
			
		||||
/* How far forward do we look when linear probing for a spot? */
 | 
			
		||||
static const unsigned int stride = 1;
 | 
			
		||||
/* What is the maximum load percentage of our hash table? */
 | 
			
		||||
static const double max_hash_load = 0.68;
 | 
			
		||||
/* Initial load percentage given a certain size */
 | 
			
		||||
static const double initial_hash_load = 0.58;
 | 
			
		||||
 | 
			
		||||
/* Allocate a hash table with space for at least "size" elements */
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_create(unsigned int size)
 | 
			
		||||
{
 | 
			
		||||
	alpm_pkghash_t *hash = NULL;
 | 
			
		||||
	size_t i, loopsize;
 | 
			
		||||
	unsigned int i, loopsize;
 | 
			
		||||
 | 
			
		||||
	CALLOC(hash, 1, sizeof(alpm_pkghash_t), return NULL);
 | 
			
		||||
	size = size / initial_hash_load + 1;
 | 
			
		||||
 | 
			
		||||
	loopsize = sizeof(prime_list) / sizeof(*prime_list);
 | 
			
		||||
	for(i = 0; i < loopsize; i++) {
 | 
			
		||||
		if(prime_list[i] > size) {
 | 
			
		||||
			hash->buckets = prime_list[i];
 | 
			
		||||
			hash->limit = hash->buckets * max_hash_load;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -78,15 +87,19 @@ alpm_pkghash_t *_alpm_pkghash_create(size_t size)
 | 
			
		||||
	return hash;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t get_hash_position(unsigned long name_hash, alpm_pkghash_t *hash)
 | 
			
		||||
static unsigned int get_hash_position(unsigned long name_hash,
 | 
			
		||||
		alpm_pkghash_t *hash)
 | 
			
		||||
{
 | 
			
		||||
	size_t position;
 | 
			
		||||
	unsigned int position;
 | 
			
		||||
 | 
			
		||||
	position = name_hash % hash->buckets;
 | 
			
		||||
 | 
			
		||||
	/* collision resolution using open addressing with linear probing */
 | 
			
		||||
	while(hash->hash_table[position] != NULL) {
 | 
			
		||||
		position = (position + 1) % hash->buckets;
 | 
			
		||||
		position += stride;
 | 
			
		||||
		while(position >= hash->buckets) {
 | 
			
		||||
			position -= hash->buckets;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return position;
 | 
			
		||||
@@ -96,7 +109,7 @@ static size_t get_hash_position(unsigned long name_hash, alpm_pkghash_t *hash)
 | 
			
		||||
static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
 | 
			
		||||
{
 | 
			
		||||
	alpm_pkghash_t *newhash;
 | 
			
		||||
	size_t newsize, position, i;
 | 
			
		||||
	unsigned int newsize, i;
 | 
			
		||||
 | 
			
		||||
	/* Hash tables will need resized in two cases:
 | 
			
		||||
	 *  - adding packages to the local database
 | 
			
		||||
@@ -129,8 +142,7 @@ static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
 | 
			
		||||
	for(i = 0; i < oldhash->buckets; i++) {
 | 
			
		||||
		if(oldhash->hash_table[i] != NULL) {
 | 
			
		||||
			alpm_pkg_t *package = oldhash->hash_table[i]->data;
 | 
			
		||||
 | 
			
		||||
			position = get_hash_position(package->name_hash, newhash);
 | 
			
		||||
			unsigned int position = get_hash_position(package->name_hash, newhash);
 | 
			
		||||
 | 
			
		||||
			newhash->hash_table[position] = oldhash->hash_table[i];
 | 
			
		||||
			oldhash->hash_table[i] = NULL;
 | 
			
		||||
@@ -144,16 +156,17 @@ static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
 | 
			
		||||
	return newhash;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t *hash, alpm_pkg_t *pkg, int sorted)
 | 
			
		||||
static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
		int sorted)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *ptr;
 | 
			
		||||
	size_t position;
 | 
			
		||||
	unsigned int position;
 | 
			
		||||
 | 
			
		||||
	if(pkg == NULL || hash == NULL) {
 | 
			
		||||
		return hash;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if((hash->entries + 1) / MAX_HASH_LOAD > hash->buckets) {
 | 
			
		||||
	if(hash->entries >= hash->limit) {
 | 
			
		||||
		hash = rehash(hash);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -189,7 +202,8 @@ alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg)
 | 
			
		||||
	return pkghash_add_pkg(hash, pkg, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t move_one_entry(alpm_pkghash_t *hash, size_t start, size_t end)
 | 
			
		||||
static unsigned int move_one_entry(alpm_pkghash_t *hash,
 | 
			
		||||
		unsigned int start, unsigned int end)
 | 
			
		||||
{
 | 
			
		||||
	/* Iterate backwards from 'end' to 'start', seeing if any of the items
 | 
			
		||||
	 * would hash to 'start'. If we find one, we move it there and break.  If
 | 
			
		||||
@@ -201,7 +215,7 @@ static size_t move_one_entry(alpm_pkghash_t *hash, size_t start, size_t end)
 | 
			
		||||
	while(end != start) {
 | 
			
		||||
		alpm_list_t *i = hash->hash_table[end];
 | 
			
		||||
		alpm_pkg_t *info = i->data;
 | 
			
		||||
		size_t new_position = get_hash_position(info->name_hash, hash);
 | 
			
		||||
		unsigned int new_position = get_hash_position(info->name_hash, hash);
 | 
			
		||||
 | 
			
		||||
		if(new_position == start) {
 | 
			
		||||
			hash->hash_table[start] = i;
 | 
			
		||||
@@ -212,7 +226,7 @@ static size_t move_one_entry(alpm_pkghash_t *hash, size_t start, size_t end)
 | 
			
		||||
		/* the odd math ensures we are always positive, e.g.
 | 
			
		||||
		 * e.g. (0 - 1) % 47      == -1
 | 
			
		||||
		 * e.g. (47 + 0 - 1) % 47 == 46 */
 | 
			
		||||
		end = (hash->buckets + end - 1) % hash->buckets;
 | 
			
		||||
		end = (hash->buckets + end - stride) % hash->buckets;
 | 
			
		||||
	}
 | 
			
		||||
	return end;
 | 
			
		||||
}
 | 
			
		||||
@@ -230,7 +244,7 @@ alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
		alpm_pkg_t **data)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *i;
 | 
			
		||||
	size_t position;
 | 
			
		||||
	unsigned int position;
 | 
			
		||||
 | 
			
		||||
	if(data) {
 | 
			
		||||
		*data = NULL;
 | 
			
		||||
@@ -246,7 +260,7 @@ alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
 | 
			
		||||
		if(info->name_hash == pkg->name_hash &&
 | 
			
		||||
					strcmp(info->name, pkg->name) == 0) {
 | 
			
		||||
			size_t stop, prev;
 | 
			
		||||
			unsigned int stop, prev;
 | 
			
		||||
 | 
			
		||||
			/* remove from list and hash */
 | 
			
		||||
			hash->list = alpm_list_remove_item(hash->list, i);
 | 
			
		||||
@@ -260,11 +274,17 @@ alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
			/* Potentially move entries following removed entry to keep open
 | 
			
		||||
			 * addressing collision resolution working. We start by finding the
 | 
			
		||||
			 * next null bucket to know how far we have to look. */
 | 
			
		||||
			stop = (position + 1) % hash->buckets;
 | 
			
		||||
			while(hash->hash_table[stop] != NULL && stop != position) {
 | 
			
		||||
				stop = (stop + 1) % hash->buckets;
 | 
			
		||||
			stop = position + stride;
 | 
			
		||||
			while(stop >= hash->buckets) {
 | 
			
		||||
				stop -= hash->buckets;
 | 
			
		||||
			}
 | 
			
		||||
			stop = (hash->buckets + stop - 1) % hash->buckets;
 | 
			
		||||
			while(hash->hash_table[stop] != NULL && stop != position) {
 | 
			
		||||
				stop += stride;
 | 
			
		||||
				while(stop >= hash->buckets) {
 | 
			
		||||
					stop -= hash->buckets;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			stop = (hash->buckets + stop - stride) % hash->buckets;
 | 
			
		||||
 | 
			
		||||
			/* We now search backwards from stop to position. If we find an
 | 
			
		||||
			 * item that now hashes to position, we will move it, and then try
 | 
			
		||||
@@ -277,7 +297,10 @@ alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
			return hash;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		position = (position + 1) % hash->buckets;
 | 
			
		||||
		position += stride;
 | 
			
		||||
		while(position >= hash->buckets) {
 | 
			
		||||
			position -= hash->buckets;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return hash;
 | 
			
		||||
@@ -285,8 +308,8 @@ alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
 | 
			
		||||
 | 
			
		||||
void _alpm_pkghash_free(alpm_pkghash_t *hash)
 | 
			
		||||
{
 | 
			
		||||
	size_t i;
 | 
			
		||||
	if(hash != NULL) {
 | 
			
		||||
		unsigned int i;
 | 
			
		||||
		for(i = 0; i < hash->buckets; i++) {
 | 
			
		||||
			free(hash->hash_table[i]);
 | 
			
		||||
		}
 | 
			
		||||
@@ -299,7 +322,7 @@ alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	alpm_list_t *lp;
 | 
			
		||||
	unsigned long name_hash;
 | 
			
		||||
	size_t position;
 | 
			
		||||
	unsigned int position;
 | 
			
		||||
 | 
			
		||||
	if(name == NULL || hash == NULL) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
@@ -316,7 +339,10 @@ alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name)
 | 
			
		||||
			return info;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		position = (position + 1) % hash->buckets;
 | 
			
		||||
		position += stride;
 | 
			
		||||
		while(position >= hash->buckets) {
 | 
			
		||||
			position -= hash->buckets;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  pkghash.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2011 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *  Copyright (c) 2011-2013 Pacman Development Team <pacman-dev@archlinux.org>
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -35,17 +35,19 @@
 | 
			
		||||
struct __alpm_pkghash_t {
 | 
			
		||||
	/** data held by the hash table */
 | 
			
		||||
	alpm_list_t **hash_table;
 | 
			
		||||
	/** number of buckets in hash table */
 | 
			
		||||
	size_t buckets;
 | 
			
		||||
	/** number of entries in hash table */
 | 
			
		||||
	size_t entries;
 | 
			
		||||
	/** head node of the hash table data in normal list format */
 | 
			
		||||
	alpm_list_t *list;
 | 
			
		||||
	/** number of buckets in hash table */
 | 
			
		||||
	unsigned int buckets;
 | 
			
		||||
	/** number of entries in hash table */
 | 
			
		||||
	unsigned int entries;
 | 
			
		||||
	/** max number of entries before a resize is needed */
 | 
			
		||||
	unsigned int limit;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct __alpm_pkghash_t alpm_pkghash_t;
 | 
			
		||||
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_create(size_t size);
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_create(unsigned int size);
 | 
			
		||||
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
 | 
			
		||||
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
 | 
			
		||||
@@ -55,6 +57,4 @@ void _alpm_pkghash_free(alpm_pkghash_t *hash);
 | 
			
		||||
 | 
			
		||||
alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name);
 | 
			
		||||
 | 
			
		||||
#define MAX_HASH_LOAD 0.7
 | 
			
		||||
 | 
			
		||||
#endif /* _ALPM_PKGHASH_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +1,34 @@
 | 
			
		||||
# Set of available languages.
 | 
			
		||||
ar
 | 
			
		||||
ca
 | 
			
		||||
cs
 | 
			
		||||
da
 | 
			
		||||
de
 | 
			
		||||
el
 | 
			
		||||
en_GB
 | 
			
		||||
eo
 | 
			
		||||
es
 | 
			
		||||
fa
 | 
			
		||||
fi
 | 
			
		||||
fr
 | 
			
		||||
gl
 | 
			
		||||
hr
 | 
			
		||||
hu
 | 
			
		||||
id
 | 
			
		||||
it
 | 
			
		||||
ja
 | 
			
		||||
kk
 | 
			
		||||
ko
 | 
			
		||||
lt
 | 
			
		||||
nb
 | 
			
		||||
nl
 | 
			
		||||
pl
 | 
			
		||||
pt
 | 
			
		||||
pt_BR
 | 
			
		||||
ro
 | 
			
		||||
ru
 | 
			
		||||
sk
 | 
			
		||||
sl
 | 
			
		||||
sr
 | 
			
		||||
sr@latin
 | 
			
		||||
sv
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user