diff --git a/aports.lua b/aports.lua
index 87b4cf7c57254647f8b0ce0db003b5cb99af118c..3f7e9ae147c88e44aa5c146e21301ffdac814603 100755
--- a/aports.lua
+++ b/aports.lua
@@ -207,6 +207,16 @@ function Aports:foreach_pkg(pkg, f)
 	end
 end
 
+function Aports:foreach_aport(f)
+	self:foreach(function(pkgname)
+		self:foreach_pkg(pkgname, function(i, pkg)
+			if pkgname == pkg.pkgname then
+				f(pkg)
+			end
+		end)
+	end)
+end
+
 function new(repodirs)
 	local h = Aports
 	h.repodirs = repodirs